Re: [R] vectors cross-product V1 x V2

2011-07-08 Thread Hans Werner Borchers
> RSiteSearch("cross product") > library(pracma) > ?cross > > Speed is usually desired in the context of many similar computations, and is > normally achieved in R by vectorizing computation, so storing the large > number of 3d vectors together in a structure like a Nx3 matrix so the code > can be

Re: [R] vectors cross-product V1 x V2

2011-07-08 Thread Bai
Thank you all. I do have two huge matrix like M1[x,y,z,3] x M2[x,y,z,3]. I'll try it. Best, Bai On Fri, Jul 8, 2011 at 11:56 PM, Jeff Newmiller wrote: > RSiteSearch("cross product") > library(pracma) > ?cross > > Speed is usually desired in the context of many similar computations, and is > norm

Re: [R] vectors cross-product V1 x V2

2011-07-08 Thread Jeff Newmiller
RSiteSearch("cross product") library(pracma) ?cross Speed is usually desired in the context of many similar computations, and is normally achieved in R by vectorizing computation, so storing the large number of 3d vectors together in a structure like a Nx3 matrix so the code can be vectorized

Re: [R] vectors cross-product V1 x V2

2011-07-08 Thread Eik Vettorazzi
Hi, how about this: mm<-cbind(V1,V2) xy<-sapply(1:3,function(x)det(mm[-x,])*(2*(x%%2)-1)) #some checks all.equal(0,as.vector(xy%*%V1)) all.equal(0,as.vector(xy%*%V2)) Am 08.07.2011 08:27, schrieb Bai: > Hi, everyone, > > I need an efficient way to do vectors cross product in R. > > Set vector