An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111103/221198de/attachment.pl>
Question about Calculation of Cross Product
4 messages · 阮铮, R. Michael Weylandt, Jeff Newmiller +1 more
Try library(pracma) ? cross Michael Weylandt
On Thu, Nov 3, 2011 at 1:17 AM, ?? <rz1991 at foxmail.com> wrote:
The function of crossprod in R puzzled me. I would like to calculate the cross product of two vectors. According to my text book, it defines like this: a = (ax, ay, az) b = (bx, by, bz) then, the cross product of a and b is: a X b = (ay*bz-az*by, az*bx-ax*bz, ax*by-ay*bz) It can also write in a determinant format. But the crossprod or tcrossprod function in R appeared not calculate the cross product. Suppose I enter this:
a = c(1, 2, 3) b = c(2, 3, 4) ab = crossprod(a, b) ab
? ? [,1] [1,] ? 20
ab = tcrossprod(a, b) ab
? ? [,1] [,2] [,3] [1,] ? ?2 ? ?3 ? ?4 [2,] ? ?4 ? ?6 ? ?8 [3,] ? ?6 ? ?9 ? 12 Does any know how to calculate cross product in R. Or I have to write the function myself? ? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111103/f5ac65b2/attachment.pl>
On 04/11/11 11:30, Jeff Newmiller wrote:
The crossprod function in base R implements the MATRIX cross product, more familiarly known as "matrix multiplication".
The term "crossprod" is thereby rather misleading, nicht wahr?
Wouldn't it be *nice* to put into the help file a wee warning telling
the young naive user (explicitly) that this is *not* the "usual" 3-D
vector cross product? :-)
cheers,
Rolf Turner