Matrix Cross Product

DESCRIPTION:
Returns a matrix which is the cross product of two given matrices, i.e., the matrix product of the transpose of the first matrix with the second.

USAGE:
crossprod(x, y = x)

REQUIRED ARGUMENTS:
x:
matrix or vector, numeric or complex.
Missing values (NA) are allowed.

OPTIONAL ARGUMENTS:
y:
numeric or complex matrix or vector, having the same number of rows as x.
Missing values (NA) are allowed.

VALUE:
matrix representing the cross product of x and y, defined as t(x) %*% y, where %*% is matrix multiplication and t is transposition. Thus the [i,j]th element of the result is sum(x[,i]*y[,j]).

DETAILS:
Any computation involving NA results in NA.

Vectors are taken to be columns, so crossprod(vec1,vec2) is a one by one matrix with the element being the dot product of the two vectors.


SEE ALSO:
matrix , Matrix-product , outer .

EXAMPLES:
amat <- matrix(c(19,8,11,2,18,17,15,19,10), nrow = 3)
crossprod(amat) # if amat has dimmensions of n(rows) and p(cols)
                # the resultant matrix will be p by p

bmat <- c(9, 5, 14) crossprod(amat, bmat)