Thomas Lumley <tlumley <at> u.washington.edu> writes: : : W is looking for the vector cross product (a specifically : three-dimensional object important in physics and engineering). The : crossproduct() function provides a matrix product so that crossprod(x,y) : is t(x)%*%y, something completely different. : : For the three-dimensional case you could define the cross and dot products : : "%x%"<-function(a,b) {c(a[2]*b[3]-a[3]*b[2], -a[1]*b[3]+a[3]*b[1], : a[1]*b[2]-a[2]*b[1])}
Alternately, you could get the cofactors from solve: cross3 <- function(a,b) { m <- cbind(a,b,1) solve(m)[3,]*det(m) } ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html