[Jprogramming] an inverse to oblique
Roger Hui
rogerhui.canada at gmail.com
Wed Feb 17 19:48:26 UTC 2016
Instead of portrait and landscape matrices, I myself use tall and wide
matrices, terminology I first heard used by Eugene McDonnell.
On Wed, Feb 17, 2016 at 11:18 AM, Mike Day <mike_liz.day at tiscali.co.uk>
wrote:
> I started with the rectangular case, so have this rather more complicated
> monad:
>
> deo =: 13 : 's$i{;y[ i =. /:;</.i.s =. (((+/(],%)>./)@:(#every)))y'
>
> I was a bit surprised that the result is tacit.
> deo
> (+/ (% , ]) >./)@:(#&>) $ ; {~ [: /: [: ; [: </. [: i. (+/ (] , %)
> >./)@:(#&>)
>
> As Marshall observes, it's not possible to deduce the orientation of
> the rectangle. The verb here assumes a landscape shape.
>
> Unfortunately, the result is wrong if the original was portrait...
>
> eg
> [land =: </.(a.{~97+i.25){~i.3 8
> +-+--+---+---+---+---+---+---+--+-+
> |a|bi|cjq|dkr|els|fmt|gnu|hov|pw|x|
> +-+--+---+---+---+---+---+---+--+-+
>
> [port =: </.(a.{~97+i.25){~i.8 3
> +-+--+---+---+---+---+---+---+--+-+
> |a|bd|ceg|fhj|ikm|lnp|oqs|rtv|uw|x|
> +-+--+---+---+---+---+---+---+--+-+
>
> deo land NB. ok
> abcdefgh
> ijklmnop
> qrstuvwx
>
> deo port NB. !!!
> abcfilor
> dehknqtu
> gjmpsvwx
>
> This dyad allows us to specify landscape or portrait with the
> optional left argument; explicit odd x forces portrait; the default
> is landscape.
>
> deod =: 3 : 0
> 0 deod y
> :
> s =. (((+/(] (x |.,) %)>./)@:(#every)))y
> i =. /:;</.i.s
> s$i{;y
> )
>
> deod land
> abcdefgh
> ijklmnop
> qrstuvwx
>
> 1 deod port
> abc
> def
> ghi
> jkl
> mno
> pqr
> stu
> vwx
>
> I've assumed that the input is properly derived from oblique
> boxing of a rectangular array.
>
> Mike
>
>
>
> On 17/02/2016 17:42, Marshall Lochbaum wrote:
>
>> deoblique =: ($:~ [: ((1+i.,i:)>./) #@>) : ([ $ (/:&; </.@:i.)~)
>>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
More information about the Programming
mailing list