Nabble-fora are in a sickly state, refusing full perusal, so excuse me if 
this's been answered..
I wanted an x-dimensional y-rank identity matrix.

With an auxilliary verb to get a main diagonal from an arbitrarily-dimensional 
square array verb:

md=: (|:~(<@i.@#@$))

I assured the following verb yields 1s in the main diagonal and 0s elsewhere:

id=: 4 : 0
q=.x(|:@(([,])$i.@]))y
x (1 q}([$])$0:) y
)

I still do not understand why the below one-liner doesn't suffice, given all 
individual parts work as intended. Substituting the 1 for, say, a 2 or 9, 
results in that many filled elements in the first face with that same number (1 
1, 2 2s, 9 9s, etc.).

(1 (|:@((],[)$i.@[)) }([$])$0:)

Anyways, I was immediate struck down, discovering that (+/ .*) doesn't exactly 
work for >2-dimensional arrays, because of the recursive minor-based action of 
the dot product, making increasingly ranked array spit out more and more 
dimensioned results. Worse still, discussing matrix multiplication with two 
colleagues, I more or less got 'oddly-dimensioned tensor products are iffy'.
I was told to first define the multiplication, which would then yield the 
identity matrix, as opposed to what I did- extending the 2D cased.
I'll be looking through some multilinear algebra in my spare time, but I was 
wondering if there's an accepted way in J )or the other APL family language) 
for multidimensional multiplication, or if it's best decided on a case by case 
basis.

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

Reply via email to