I like

antid=: 1 {."0~ -@(-i.)

   antid 4
0 0 0 1
0 0 1 0
0 1 0 0
1 0 0 0


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: [email protected] [mailto:programming-
> [email protected]] Namens Alex Gian
> Verzonden: vrijdag 20 augustus 2010 12:41
> Aan: Programming forum
> Onderwerp: [Jprogramming] Creating a matrix (some polish required)
> 
> The "flipped" identity matrix is quite interesting. (Basically it's the
> identity matrix flipped or mirrored about either the vertical or
> horizontal axis.  IOW, for a 3x3:
> 0 0 1
> 0 1 0
> 1 0 0
> I don't know if it has any special name, I stumbled on it by chance
> while messing around with a simple FSA for a puzzle game.
> Pre-multiplying by this matrix flips any same size matrix vertically,
> post-multiplying flips it horizontally.  Its square is obviously the
> identity matrix.
> 
> Now, I have created this matrix on various systems, (e.g. HP/RPL,
> Scheme, TI-Basic), usually - if an id matrix is provided - just by
> reversing its rows, otherwise just by starting off with the vector, say,
> 0 0 0 1, and then rotating the "1" each time and appending that vector
> to a string, which is eventually converted to a matrix.
> 
> I can do this using loops and explicit coding, but am looking for any
> suggestions to make it into a J one-liner, such that:
> flipidm 4
>   0 0 0 1
>   0 0 1 0
>   0 1 0 0
>   1 0 0 0
> 
> Hope my explanation was clear enough,
> TIA
> 
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to