本帖最后由 Transpose 于 2021-7-1 10:46 编辑
[Fortran] 纯文本查看 复制代码 real(8) :: P(3, 3);
real(8) :: Stress_T(1, 3);
real(8) :: Stress_V(3, 1);
real(8) :: Stress(3);
real(8) :: temp1(1, 3);
real(8) :: temp2;
temp1 = matmul(Stress_T, P);
temp2 = matmul(temp1, Stress_V);
维度不匹配
(1 ,3) * (3, 1) =(1,1)
是一个二维数组,不是一个数
在使用matmul时,如果输入一维数数组,Fortran会自动判断
对于c=matmul(a,b)
如果a是一维数组,b是二维数组,会自动解析为 a(1,n) b(n,m) 返回一维数组 c(m)
如果a是二维数组,b是一维数组,会自动解析为 a(m,n) b(n,1) 返回一维数组 c(m)
不需要定义为 a(1,3)这种数组
最后的是两个向量乘法,使用dot_product即可
[Fortran] 纯文本查看 复制代码 temp2=dot_product(matmul(stress,P),stress)
|