Clicky

Fortran Wiki
dot_product

Description

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).

Standard

Fortran 95 and later

Class

Transformational function

Syntax

result = dot_product(vector_a, vector_b)

Arguments

  • 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.

Return value

If the arguments are numeric, the return value is a scaler of numeric type, integer, real, or complex. If the arguments are logical, the return value is .true. or .false..

Example

program test_dot_prod
    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 test_dot_prod

category: intrinsics