Mike;

Here be dragons:

  (*=) 2 7 9 2
|length error
|       (*=)2 7 9 2

I wonder if there is something that handles band matrices in general....

Mike Day wrote:
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


--
------------------------------------------------------------------------
|\/| Randy A MacDonald       | APL: If you can say it, it's done.. (ram)
|/\| ramacd <at> nbnet.nb.ca |
|\ |                         | The only real problem with APL is that
BSc(Math) UNBF'83            | it is "still ahead of its time."
Sapere Aude                  |     - Morten Kromberg
Natural Born APL'er          |
-----------------------------------------------------(INTP)----{ gnat }-



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

Reply via email to