Re: [Rd] Speeding up matrix multiplies

2010-08-27 Thread James Cloos
I just tried out the effects of using R's NA value¹ with C arithmetic on an amd64 linux box. I always got a NAN result for which R's R_IsNA() would return true. At least on this platform, NAN's propagate w/o a change in their lower 32 bits. If NA is supposed to propagate the way NaN is spec'ed t

Re: [Rd] Speeding up matrix multiplies

2010-08-24 Thread Dirk Eddelbuettel
On 24 August 2010 at 09:13, Göran Broström wrote: | | On 2010-08-24 05:37, Kasper Daniel Hansen wrote: | > On Mon, Aug 23, 2010 at 10:39 PM, Radford Neal wrote: | >>> On Aug 23, 2010, at 7:39 PM, Radford Neal wrote: | >> | In particular, all matrix x vector and vector x matrix products wil

Re: [Rd] Speeding up matrix multiplies

2010-08-24 Thread Göran Broström
On 2010-08-24 05:37, Kasper Daniel Hansen wrote: On Mon, Aug 23, 2010 at 10:39 PM, Radford Neal wrote: On Aug 23, 2010, at 7:39 PM, Radford Neal wrote: In particular, all matrix x vector and vector x matrix products will in this version be done in the matprod routine, not the Fortran routi

Re: [Rd] Speeding up matrix multiplies

2010-08-23 Thread Kasper Daniel Hansen
On Mon, Aug 23, 2010 at 10:39 PM, Radford Neal wrote: >> On Aug 23, 2010, at 7:39 PM, Radford Neal wrote: > >> > In particular, all matrix x vector and vector x matrix products will >> > in this version be done in the matprod routine, not the Fortran routine. >> > And this is the right thing to do

Re: [Rd] Speeding up matrix multiplies

2010-08-23 Thread Radford Neal
> On Aug 23, 2010, at 7:39 PM, Radford Neal wrote: > > In particular, all matrix x vector and vector x matrix products will > > in this version be done in the matprod routine, not the Fortran routine. > > And this is the right thing to do, since the time for the ISNAN check > > before calling the

Re: [Rd] Speeding up matrix multiplies

2010-08-23 Thread Simon Urbanek
On Aug 23, 2010, at 7:39 PM, Radford Neal wrote: > Regarding my previous message on speeding up matrix multiplies, I've > realized that the size of the result matrix is not really the right > criterion for deciding to do the computation without using the Fortran > routine. A better criterion wou

Re: [Rd] Speeding up matrix multiplies

2010-08-23 Thread Radford Neal
Regarding my previous message on speeding up matrix multiplies, I've realized that the size of the result matrix is not really the right criterion for deciding to do the computation without using the Fortran routine. A better criterion would be based on the ratio of the time for the matrix multipl

[Rd] Speeding up matrix multiplies

2010-08-23 Thread Radford Neal
I've looked at the code for matrix multiplies in R, and found that it can speeded up quite a bit, for multiplies that are really vector dot products, and for other multiplies in which the result matrix is small. Here's my test program: u <- seq(0,1,length=1000) v <- seq(0,2,length=1000) A2 <- ma