DOT_PRODUCT(3) - [ARRAY:TRANSFORMATIONAL] Dot product of two vectors
result = dot_product(vector_a, vector_b)
TYPE(kind=KIND) function dot_product(vector_a, vector_b)TYPE(kind=KIND),intent(in) :: vector_a(:) TYPE(kind=KIND),intent(in) :: vector_b(:)
The two vectors may be either numeric or logical and must be arrays of rank one and of equal size.
o VECTOR_A, VECTOR_B may be any numeric or logical type array of rank one of the same size o the two vectors need not be of the same kind, but both must be logical or numeric for any given call. o the result is the same type and kind of the vector that is the higher type that the other vector is optionally promoted to if they differ.
DOT_PRODUCT(3) computes the dot product multiplication of two vectors VECTOR_A and VECTOR_B.
o VECTOR_A : A rank 1 vector of values o 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 of the same size as VECTOR_A.
If the arguments are numeric, the return value is a scalar of numeric type. If the arguments are logical, the return value is .true. or [char46]false..
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)
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_prodResults:
> 1 2 3 > > 4 5 6 > > 32
Fortran 95
SUM(3), CONJG(3), ANY(3)
Fortran intrinsic descriptions (license: MIT) @urbanjost
Nemo Release 3.1 | dot_product (3fortran) | November 02, 2024 |