As the J Engine (JE) implements more tricks it becomes harder and harder
to time individual operations.
For example: what is the speed of
}. list
? That depends. If you are using it in passing, as in
1 + }. list
the }. is 'virtual': very fast, almost free, because it makes a pointer
to the subarray of 'list' that it needs. But if you assign the result,
as in
name =. }. list
the JE has to realize the value, which requires copying it.
When you measure
ts '}.@i.&>: 100000000'
all the time is going into the i., which allocates a huge array and
writes into it, almost all not in cache. The }. is virtual. And in
ts '1+ i.100000000'
the result of i. is marked as inplaceable, so adding 1 is done without
allocating a new block, and without having to read from two addresses,
making the operation faster than you would expect.
Henry Rich
On 1/1/2019 9:59 PM, Jimmy Gauvin wrote:
Hi,
all the additions in 1 + i. 5 (or >:5) seem wasteful, I prefer generating
one more and dropping the first :
}. i. >:5
1 2 3 4 5
but there might be some special code because both appear to have similar
performance :
On Tue, Jan 1, 2019 at 1:13 PM 'Pascal Jasmin' via Programming <
[email protected]> wrote
iota =: i. : (+ i.)
1 iota 51 2 3 4 5
iota is 0 based if monadic, right argument based if dyadic.
if there were more "ascii op codes" an ideal design for every verb would
have the monadic version be a "default argument" version of a dyadic form.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm