In my case, I have a 256 by 312 array that never changes. Every tick, I get a new 1 by 256 vector which I must multiply by the array to get a new 1 by 312 vector.
So every tick, I must do a matrix*vector multiply. Usually, I will be processing anywhere from 1 second to 10 seconds worth of data. 1 second of data consists of 5000 - 1 by 312 vectors. I have hours worth of data to process, so any speed up I can get saves me processing time. I have been thinking of using a quad processor which is 64 bits wide. I assume that will decrease my processing time. Roger Hui wrote: > > 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 > > -- View this message in context: http://www.nabble.com/Re%3A-speed-of-matrix*vector-operation-tf4774233s24193.html#a13976215 Sent from the J Programming mailing list archive at Nabble.com. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
