Fortran几个函数(DOT_PRODUCT+MATMUL+TRANSPOSE+RESHAPE)
来源:互联网 发布:大数据架构师 知乎 编辑:程序博客网 时间:2024/06/03 18:24
DOT_PRODUCT函数(点积)
DOT_PRODUCT(VECTOR_A, VECTOR_B) computes the dot product multiplication of two vectors VECTOR_A and VECTOR_B. The two vectors may be either numeric or logical and must be arrays of rank one and of equal size. If the vectors are INTEGER or REAL, the result is SUM(VECTOR_A*VECTOR_B). If the vectors are COMPLEX, the result is SUM(CONJG(VECTOR_A)*VECTOR_B). If the vectors are LOGICAL, the result is ANY(VECTOR_A .AND. VECTOR_B).
Examples
DOT_PRODUCT ((/1, 2, 3/), (/3, 4, 5/)) has the value 26 (calculated as follows: ((1 x 3) + (2 x 4) + (3 x 5)) = 26 ).
DOT_PRODUCT ((/ (1.0, 2.0), (2.0, 3.0) /), (/ (1.0, 1.0), (1.0, 4.0) /)) has the value (17.0, 4.0). !complex function application.
DOT_PRODUCT ((/ .TRUE., .FALSE. /), (/ .FALSE., .TRUE. /)) has the value false.
The following shows another example:
I = DOT_PRODUCT((/1,2,3/), (/4,5,6/)) ! returns the value 32
MATMUL函数(矩阵的相乘)
Performs a matrix multiplication on numeric or logical arguments.
A is matrix
[ 2 3 4 ] [ 3 4 5 ],B is matrix [ 2 3 ] [ 3 4 ] [ 4 5 ],X is vector (1, 2), and Y is vector (1, 2, 3).
The result of MATMUL (A, B) is the matrix-matrix product AB with the value
[ 29 38 ] [ 38 50 ].
The result of MATMUL (X, A) is the vector-matrix product XA with the value (8, 11, 14).
The result of MATMUL (A, Y) is the matrix-vector product AY with the value (20, 26).
The following shows another example:
INTEGER a(2,3), b(3,2), c(2), d(3), e(2,2), f(3), g(2) a = RESHAPE((/1, 2, 3, 4, 5, 6/), (/2, 3/)) ! a is 1 3 5 ! 2 4 6 b = RESHAPE((/1, 2, 3, 4, 5, 6/), (/3, 2/)) ! b is 1 4 ! 2 5 ! 3 6 c = (/1, 2/) ! c is [1 2] d = (/1, 2, 3/) ! d is [1 2 3] e = MATMUL(a, b) ! returns 22 49 ! 28 64 f = MATMUL(c,a) ! returns [5 11 17] g = MATMUL(a,d) ! returns [22 28] WRITE(*,*) e, f, g END
TRANSPOSE函数(数组转置)
Description:
Transpose an array of rank two. Element (i, j) of the result has the value MATRIX(j, i), for all i, j.
B is the array
[ 2 3 4 ] [ 5 6 7 ] [ 8 9 1 ].TRANSPOSE (B) has the value [ 2 5 8 ] [ 3 6 9 ] [ 4 7 1 ].
The following shows another example:
INTEGER array(2, 3), result(3, 2) array = RESHAPE((/1, 2, 3, 4, 5, 6/), (/2, 3/)) ! array is 1 3 5 ! 2 4 6 result = TRANSPOSE(array) ! result is 1 2 ! 3 4 ! 5 6 END?
RESHAPE函数(矩阵重组)
Description:
Reshapes SOURCE to correspond to SHAPE. If necessary, the new array may be padded with elements from PAD or permuted as defined by ORDER.
RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 3/)) has the value
[ 3 5 7 ] [ 4 6 8 ].RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 4/), (/1, 1/), (/2, 1/)) has the value [ 3 4 5 6 ] [ 7 8 1 1 ].
The following shows another example:
INTEGER AR1( 2, 5) REAL F(5,3,8) REAL C(8,3,5) AR1 = RESHAPE((/1,2,3,4,5,6/),(/2,5/),(/0,0/),(/2,1/)) ! returns 1 2 3 4 5 ! 6 0 0 0 0 ! ! Change Fortran array order to C array order C = RESHAPE(F, (/8,3,5/), ORDER = (/3, 2, 1/)) END
阅读全文
0 0
- Fortran几个函数(DOT_PRODUCT+MATMUL+TRANSPOSE+RESHAPE)
- Fortran几个函数(DOT_PRODUCT+MATMUL+TRANSPOSE+RESHAPE)
- numpy的常用函数reshape、matmul
- Python numpy函数:reshape()
- matmul
- reshape函数
- Numpy中的transpose函数
- tf.transpose()函数
- Python的transpose()函数
- fortran函数
- Fortran 函数
- numpy常用函数(power、sum、tile、transpose等)
- numpy常用函数(power、sum、tile、transpose等)
- Fortran学习笔记6(函数、子程序)
- tf.transpose函数的用法
- 计算机图形学 -- Reshape函数
- MATLAB reshape()函数
- matlab reshape 函数
- matlabday01
- Android RecyclerView 获取数据实现添加,删除功能
- 链栈实现
- 获得WINDOWS下所有用户的信息
- 欢迎使用CSDN-markdown编辑器
- Fortran几个函数(DOT_PRODUCT+MATMUL+TRANSPOSE+RESHAPE)
- angularJS商品表格
- spring中各个类的作用
- 欢迎使用CSDN-markdown编辑器
- String、StringBuffer与StringBuilder之间区别
- zookeeper基本讲解
- OpenMAX编程-组件
- Android属性动画入门介绍
- 动画