The two expressions for computing the product are
expected to require the same amount of time.
The difference is in the way the random numbers
are generated,  ?256$0 vs. [EMAIL PROTECTED] etc., but you were
not timing that.  (BTW the latter is faster and leaner.)

One way to get more speed is to use a smarter algorithm.
>From the short description of the application previously
provided I was not sure how you can be smarter, 
so I'll use an analogy.

In stock prices there is a quantity called VWAP,
volume weighted average price.  Suppose you are
required to compute the VWAP for the day on the 
tick data as they pour in many times a second.  
You can not afford to recompute the VWAP from 
scratch on every tick (actually that is an inner product!).
Instead, maintain running totals, and with the new tick 
you just need to maintain that total, using 1 multiply, 
2 additions, and 1 divide.

   v=: v+nv
   vp=: vp + nv*np
   vwap=: vp%v



----- Original Message -----
From: efittery <[EMAIL PROTECTED]>
Date: Tuesday, November 20, 2007 23:15
Subject: Re: Re: [Jprogramming] speed of matrix*vector operation
To: [email protected]

> > Try
> > A=: ?256$0
> >  B=: ?256 312$0
> >  1000 (6!:2) 'A +/ .* B'
> 
> tried the above and got 0.003414
> 
> vector =: 256 [EMAIL PROTECTED] 0
> matrix=: 256 312 [EMAIL PROTECTED] 0
> 1000 (6!:2) 'output =: vector +/ .* matrix'
> 
> I my above approach and got 0.0034282
> 
> They both came out about the same
> 
> I need to get a quad-core 64bit processor if I want more speed.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to