http://www.jsoftware.com/jwiki/Essays/Identity_Matrix may give you some ideas. For the identity matrix itself there are over 30 ways.
----- Original Message ----- From: Raul Miller <[EMAIL PROTECTED]> Date: Saturday, October 11, 2008 11:40 Subject: [Jprogramming] diagonal arrays To: Programming forum <[email protected]> > Given a vector, put it on the diagonal of an array: > > (<0 1)&|:inv 2 7 9 20 > |index error > (+/ .*(e.(<0 1 2 )&|:)@i.@(3##)) 2 7 9 20 > 2 0 0 0 > 0 7 0 0 > 0 0 9 0 > 0 0 0 20 > (, $~ 2##)@(,"0 1*&0)2 7 9 20 > 2 0 0 0 > 0 7 0 0 > 0 0 9 0 > 0 0 0 20 > > Are there more concise approaches, that work? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
