Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

DOT_PRODUCT

Transformational Intrinsic Function (Generic): Performs dot-product multiplication of numeric or logical vectors (rank-one arrays).

result = DOT_PRODUCT (vector_a,vector_b)

vector_a

(Input) Must be a rank-one array of numeric (integer, real, or complex) or logical type.

vector_b

(Input) Must be a rank-one array of numeric type if vector_a is of numeric type, or of logical type if vector_a is of logical type. It must be the same size as vector_a.

Results

The result is a scalar whose type depends on the types of vector_a and vector_b.

If vector_a is of type integer or real, the result value is SUM ( vector_a* vector_b).

If vector_a is of type complex, the result value is SUM (CONJG ( vector_a)* vector_b).

If vector_a is of type logical, the result has the value ANY ( vector_a.AND. vector_b).

If either rank-one array has size zero, the result is zero if the array is of numeric type, and false if the array is of logical type.

Example

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

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