This might well be in Roger's essay, but it's so
concise and beautiful that I can't resist sending
it anyway!
(*=) 2 7 9 20 NB. I'm forcing a line throw
2 0 0 0
0 7 0 0
0 0 9 0
0 0 0 20
Mike
Roger Hui wrote:
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
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.173 / Virus Database: 270.8.0/1717 - Release Date: 09/10/2008 16:56
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm