crossprod(x, y = x)
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.
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 pbmat <- c(9, 5, 14) crossprod(amat, bmat)