http://www.jsoftware.com/jwiki/Essays/Identity%20Matrix
34 ways to create the identity matrix. Adapt one to create the anti-diagonal matrix. e.g. method 23: a23=: |....@i. a23 5 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 ----- Original Message ----- From: Alex Gian <[email protected]> Date: Friday, August 20, 2010 3:42 Subject: [Jprogramming] Creating a matrix (some polish required) To: Programming forum <[email protected]> > 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
