# R program to illustrate# crossprod function# Initializing a matrix with# 2 rows and 2 columns
x <- matrix(1:4,2,2)# Getting the matrix representation
x
# Calling the crossprod() function
crossprod(x)
R
输出
[,1][,2][1,]13[2,]24[,1][,2][1,]511[2,]1125
R
例2 :
# R program to illustrate# crossprod function# Initializing a matrix with# 3 rows and 3 columns
x <- matrix(1:9,3,3)# Getting the matrix representation
x
# Calling the crossprod() function
crossprod(x)