dot_product(3f) - [FORTRAN:INTRINSIC:TRANSFORMATIONAL FUNCTION] Dot product function
result = dot_product(vector_a, vector_b)
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).
vector_a The type shall be numeric or LOGICAL, rank 1. vector_b The type shall be numeric if vector_a is of numeric type or LOGICAL if vector_a is of type LOGICAL. vector_b shall be a rank-one array.
If the arguments are numeric, the return value is a scalar of numeric type, INTEGER, REAL, or COMPLEX. If the arguments are LOGICAL, the return value is .true. or .false..
Sample program:
program demo_dot_prod implicit none integer, dimension(3) :: a, b a = [ 1, 2, 3 ] b = [ 4, 5, 6 ] print (3i3), a print * print (3i3), b print * print *, dot_product(a,b) end program demo_dot_prod
[[Fortran 95]] and later
Transformational function
dot_product (3) | March 11, 2021 |