Fortran Coder

楼主: shrine
打印 上一主题 下一主题

[数值问题] 请问双双精度变量赋值时后缀加什么?

[复制链接]

490

帖子

4

主题

0

精华

大宗师

F 币
3298 元
贡献
1948 点

水王勋章元老勋章热心勋章

楼主
发表于 2017-11-9 15:40:41 | 显示全部楼层
本帖最后由 pasuka 于 2017-11-9 15:42 编辑
shrine 发表于 2017-11-9 13:48
感谢一直以来的帮助
再请教一个语法问题,行向量和矩阵中的一列相乘难道不是一个数么
为何这段代码说c的形 ...
首先,翻阅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] 纯文本查看 复制代码
program test_rank
  integer :: a
  real, allocatable :: b(:,:)
  print *, rank(a), rank(b) ! Prints:  0  2
end program test_rank

您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-5 04:01

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表