The crossprod function in base R implements the MATRIX cross product, more familiarly known as "matrix multiplication". --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity.
"R. Michael Weylandt" <michael.weyla...@gmail.com> wrote: Try library(pracma) ? cross Michael Weylandt On Thu, Nov 3, 2011 at 1:17 AM, é®é® <rz1...@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@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. > _____________________________________________ R-help@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. [[alternative HTML version deleted]]
______________________________________________ R-help@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.