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])}

 "%.%%<-function(a,b) sum(a*b)


It would make sense, of course, to check that the arguments actually were
vectors of length 3.



        -thomas

______________________________________________
[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

Reply via email to