Calculate the cross-product of the Transpose of a Matrix in R Programming – tcrossprod() Function
Last Updated :
03 Jun, 2020
tcrossprod()
function in R Language is used to return the cross-product of the transpose of the specified matrix.
Syntax: tcrossprod(x)
Parameters:
x: numeric matrix
Example 1:
x < - matrix( 1 : 4 , 2 , 2 )
x
tcrossprod(x)
|
Output:
[, 1] [, 2]
[1, ] 1 3
[2, ] 2 4
[, 1] [, 2]
[1, ] 10 14
[2, ] 14 20
Example 2:
x < - matrix( 1 : 9 , 3 , 3 )
x
tcrossprod(x)
|
Output:
[, 1] [, 2] [, 3]
[1, ] 1 4 7
[2, ] 2 5 8
[3, ] 3 6 9
[, 1] [, 2] [, 3]
[1, ] 66 78 90
[2, ] 78 93 108
[3, ] 90 108 126
Share your thoughts in the comments
Please Login to comment...