>>
<<
Ndx
Usr
Pri
Phr
Dic
Rel
Voc
!:
wd
Help
Dictionary
10. Classification (with Selection and Inner Product)
The complete classification table can be used in a variety of ways,
including use with various inner products. For example:
cct=: #:@i.@(2: ^ #)
m=: 2 3 5 ,: 4 2 1
n=: |: cct 0{m
m ; n ; m +/ . * n
+-----+---------------+----------------+
|2 3 5|0 0 0 0 1 1 1 1|0 5 3 8 2 7 5 10|
|4 2 1|0 0 1 1 0 0 1 1|0 1 2 3 4 5 6 7|
| |0 1 0 1 0 1 0 1| |
+-----+---------------+----------------+
The pattern of the inner product can be seen more
clearly in the following display: the element in a given
row and column of the matrix product p
in the lower right box corresponds to the row of the left argument
and the column of the right argument. Thus:
('' ; n) ,: (m ; p=: m +/ . * n)
+-----+----------------+
| |0 0 0 0 1 1 1 1 |
| |0 0 1 1 0 0 1 1 |
| |0 1 0 1 0 1 0 1 |
+-----+----------------+
|2 3 5|0 5 3 8 2 7 5 10|
|4 2 1|0 1 2 3 4 5 6 7|
+-----+----------------+
(+/r*c) ; (r*c) ; (r=: 0{m) ; (c=: 3{"1 n) ; (<0 3){p
+-+-----+-----+-----+-+
|8|0 3 5|2 3 5|0 1 1|8|
+-+-----+-----+-----+-+
Just as the ordinary matrix product yields sums over products,
the inner product */ . ^ yields products over powers.
Hence, m */ . ^ n produces products
over all possible subsets of the rows of m:
m */ . ^ n
1 5 3 15 2 10 6 30
1 1 2 2 4 4 8 8
Also see the use of the key adverb (/.)
for classification.
>>
<<
Ndx
Usr
Pri
Phr
Dic
Rel
Voc
!:
wd
Help
Dictionary