Bill has found the proximate cause of the problem.  I will try to fix it.

Nothing to do with that: you should try to avoid calculating ;/I. For m}, use the new scatter amend, which you already know about. For {, use

(1 + I (<"1@[ { ]) M)

which avoids the boxing.

Henry Rich

On 11/12/2019 2:17 AM, Ben Gorte wrote:
Dear J'ers

I'm using large 3D arrays (voxels), such as
    M =: ?400 400 400$100

To add 1 to a bunch of voxels at positions

I =: ?100 3$400

I go like:

timespacex 'M =: (1+(;/I){M) (;/I) } M'

1.3e_5 42048

This was in version 8.07:

JVERSION

Engine: j807/j64/linux

Release: commercial/2018-10-04T15:00:41

Library: 8.07.26


In version 9.01, however: timespacex 'M =: (1+(;/I){M) (;/I) } M'

0.238664 5.36912e8


It became thousands of times slower! I'm doing this hundreds of thousands
of times and it takes weeks instead of minutes.


A multi-dimensional index for amend does not need to be boxed in j901, but:

timespacex 'M =: (1+(;/I){M) I } M'

0.238302 5.36894e8
gives pretty much the same result.
This is with:

JVERSION

Engine: j901/j64avx2/linux

Beta-p: commercial/2019-11-06T09:48:25

Library: 9.01.10

I was wondering whether it happend in { or }, but to my great surprise:
     timespacex 'new =: 1+(;/I) { M'

8e_6 21824
     timespacex 'M =: new (;/I) } M'

6e_6 20992

So the solution is to do it in two steps !?!?

With unboxed I in step 2, I get even:

timespacex 'M =: new I } M'

2e_6 2560


Am I missing a point? Could I have foreseen this?

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

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

Reply via email to