I am doing a +//. on a very large array that I need redistribute the
results back to the original positions.
The dictionary has a solution that works well on small arrays[1], but does
not work on my large array since it's using = to self classify
Example:
NB. create 3 fake families across 100 rows
families=: 1,(98$2),3
val=: 100 $1
NB. sum by family
] famTotal =: families +//. val
1 98 1
NB. desired output, result distributed to each row
] desired =: famTotal ((+/ .*)=) families
1 98 98 .... 1
NB. confirms desired matches family total
(~. ( i.~ families)) { desired
4 3 3
For my very large array:
families=.55e6 $ (i.100000)
val =: 55e6 $ 1
famTotal =: families +//. val
desired =: famTotal ((+/ .*)=) families
|out of memory
The reason why is because = families results in a huge array.
How can I accomplish the same goal efficiently?
1 - http://www.jsoftware.com/help/dictionary/d221.htm
2 - http://www.jsoftware.com/jwiki/Vocabulary/eq
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm