赞
踩
- a = matrix(c(1,1,2,0),nc = 2);a#生成矩阵a并在屏幕上显示
- t(a)#矩阵的转置
运行结果展示
det(a)#矩阵的行列式
结果展示
两种方式实现矩阵的内积
- a = matrix(c(1,1,2,0),nc = 2);a
- c = matrix(c(0,1,1,0),nc = 2);c
- a%*%c #求两矩阵的内积
结果展示
- a = matrix(c(1,1,2,0),nc = 2);a
- b = matrix(c(1,0,0,1),nc = 2);b
- crossprod(a,b) #等价于t(a)%*%b
- t(a)%*%b #与crossprod(a,b)结果进行比较
结果展示
矩阵外积的三种方式
- x = matrix(c(1,2,3),nc = 3);x
- y = matrix(c(1,2,3),nr = 1);y
- x%o%y #求矩阵外积
结果展示
- x = matrix(c(1,2,3),nc = 3);x
- y = matrix(c(1,2,3),nr = 1);y
- outer(x,y)
结果展示
- x = matrix(c(1,2,3),nc = 3);x
- y = matrix(c(1,2,3),nr = 1);y
- tcrossprod(x,y)
- x%*%t(y) #与tcrossprod(x,y)进行对比
结果展示
- A = matrix(c(1:4),nc = 2);A
- B = matrix(c(2:5),nc = 2);B
- A*B
结果展示
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。