|
本帖最后由 pasuka 于 2017-11-9 15:42 编辑
首先,翻阅gfortran帮助文档
https://gcc.gnu.org/onlinedocs/g ... /MATMUL.html#MATMUL
MATMUL — matrix multiplication
Description:
Performs a matrix multiplication on numeric or logical arguments.
Standard:
Fortran 95 and later
Class:
Transformational function
Syntax:
RESULT = MATMUL(MATRIX_A, MATRIX_B)
Arguments:
MATRIX_A An array of INTEGER, REAL, COMPLEX, or LOGICAL type, with a rank of one or two.
MATRIX_B An array of INTEGER, REAL, or COMPLEX type if MATRIX_A is of a numeric type; otherwise, an array of LOGICAL type. The rank shall be one or two, and the first (or only) dimension of MATRIX_B shall be equal to the last (or only) dimension of MATRIX_A.
Return value:
The matrix product of MATRIX_A and MATRIX_B. The type and kind of the result follow the usual type and kind promotion rules, as for the * or .AND. operators.
显然根据文档不难发现,输入和输出变量的rank都不会小于1,那么Fortran里面的rank又是怎么定义的呢?
接着查看rank函数
https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gfortran/RANK.html#RANK
The return value is of type INTEGER and of the default integer kind. For arrays, their rank is returned; for scalars zero is returned.
Example:
[Fortran] 纯文本查看 复制代码 3 | real , allocatable :: b ( : , : ) |
4 | print * , rank ( a ) , rank ( b ) |
|
|