There are various reasons for not implementing special code;
the one I mentioned ("does not occur sufficiently often")
is just one of them.  For x%y vs. x*%y other factors
come into play. e.g. You as a J programmer can easily 
do it yourself; a desire to keep the implementation of 
the dyad * clean and simple; etc.



----- Original Message -----
From: Viktor Cerovski <[EMAIL PROTECTED]>
Date: Tuesday, November 27, 2007 11:18
Subject: Re: Re[Jgeneral] quest for change
To: [email protected]

> Roger Hui wrote:
> > 
> > My judgment is that the special cases described
> > for in the msg for which faster computations exist,
> > do not occur sufficiently often to warrant the
> > special code which would slow down the general cases.
> > I am also skeptical that zero detection in */ would save 
> > "an immense amount of time", or that in practice */y
> > would be performed on a lengthy y .
> > 
> As a demonstration of the speed of the current J implementation,
> one can consider the following:
> 
>    time=:6!:2
> 
>    a=:(,~1000)[EMAIL PROTECTED]     NB. random 
> 1000x1000 matrix
>    100 time 'a%2.5'    NB. divide a by 2.5
> 0.0226511
>    100 time 'a*%2.5'   NB. multiply a by 1/2.5
> 0.0189885
> 
> One interpretation of this result is that since * is faster
> than % in the FPU of the processor, the second expression
> executes faster than the first.  
> 
> This also makes a difference for instance in the case of the 
> vector normalization:
> 
>    mp=:+/ . *
>    nrm=:%:@(mp~)
>    norm1=:%nrm
>    norm2=:[EMAIL PROTECTED]
>   
>    100 time 'norm1"1 a'
> 0.0384147
>    100 time 'norm2"1 a'
> 0.0315959
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to