I see, it's not matrix multiplication. There are several ways:
Given
a=: 4 4$1 1 1 1 1 1 2 2 1 1 3 3 1 1 4 4
mplr =: 2 4$ 1 1 0 0 0 0 1 1
What we were talking about is
mplr (] * (($,)~ $)) 2 # a
1 1 0 0
0 0 1 1
1 1 0 0
0 0 2 2
1 1 0 0
0 0 3 3
1 1 0 0
0 0 4 4
but a much better way is
,/ mplr *"1"2 1 a
1 1 0 0
0 0 1 1
1 1 0 0
0 0 2 2
1 1 0 0
0 0 3 3
1 1 0 0
0 0 4 4
Henry Rich
On 9/5/2012 7:46 PM, pascha wrote:
ok let me give you the big picture. Assume we have:
a=: 4 4$1 1 1 1 1 1 2 2 1 1 3 3 1 1 4 4
1 1 1 1
1 1 2 2
1 1 3 3
1 1 4 4
and double it, 2 # a:
1 1 1 1
1 1 1 1
1 1 2 2
1 1 2 2
1 1 3 3
1 1 3 3
1 1 4 4
1 1 4 4
the multiplier is 2 4$ 1 1 0 0 0 0 1 1
1 1 0 0
0 0 1 1
so if I multiply the doubled matrix by that I'd like to get:
1 1 0 0
0 0 1 1
1 1 0 0
0 0 2 2
1 1 0 0
0 0 3 3
1 1 0 0
0 0 4 4
I called it array by array multiplication (don't know if it's the right
phrase) but for each doubled pairs and not for the whole matrix
Henry Rich wrote:
I still can't understand what you want. If you can give a small
example, indicating input and desired output, we can help you.
Henry Rich
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm