I have looked further into the matter.

   y=: 1000 * 1e6 [EMAIL PROTECTED] 0
   7!:2 '<.y'
12583552

One expects that it should take 4 bytes per
element but it takes more than 8.  The problem 
is that  <.y  uses an intermediate result which 
is float and then converts it into integers 
if possible, to accommodate cases like <.1e20 .  
So in the cases

   integer <.@:* float
   integer <.@ * float

the problem lies in the monad <. .  In contrast,

   integer <[EMAIL PROTECTED] integer

does not suffer from this problem because the
entire operation can be done internally using
integer operations.

A way to improve the monad <. (and >.) is to
assume that the final result is all integers, 
expected to be by far the most common case, 
and handle the case where the result must be 
floats as an exception.  We will see after this 
is done whether it is worthwhile to implement 
integer <[EMAIL PROTECTED] float  in special code.





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

Reply via email to