In the "Item amend" thread [1], EelVex wrote:
>  The question is "how to do it efficiently", mostly in time, 
>  ideally in space too.

What's the fastest and leanest way to merge a matrix into a vector along
the lines of item amend, for a large number of merge specifications?

Let's start with our two current candidates:

   X=: 50e5 10 ?@$ 10
   A=: i.10 10

   B=:]`(A"_)}"_1 X
   C=: X {"0 1"_1 _ |: A       NB. |: omitted in original post; fixed now

   B-:C
1

   10 ts 'B=:]`(A"_)}"_1 X'
2.01936 4.5408e9
   10 ts 'C=: X {"0 1"_1 _ |: A'
7.69318 5.36878e8

   0j1 ": 100 * 2.01936 4.5408e9 % 7.69318 5.36878e8
26.2 845.8

So "item amend" is about 25x faster than {, but { is three orders of
magnitude leaner than } .  

What other methods can improve on these results?  Is it possible to have an
expression where A is an input which is competitive with } (where A is
fixed)?

-Dan

[1] "Item amend ~: index error." :
    http://www.jsoftware.com/pipermail/programming/2014-March/036480.html
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to