IBM Books

Engineering and Scientific Subroutine Library for AIX Version 3 Release 3: Guide and Reference

SNDOT and DNDOT--Compute Special Dot Products N Times

These subprograms compute one of the following special dot products n times:

si <-- xi * yi Store positive dot product
si <-- -xi * yi Store negative dot product
si <-- si+xi * yi Accumulate positive dot product
si <-- si-xi * yi Accumulate negative dot product
for i = 1, n



where each si is an element in vector s, and each xi and yi are vectors contained in vectors (or matrices) x and y, respectively.

Table 45. Data Types

s, x, y Subprogram
Short-precision real SNDOT
Long-precision real DNDOT

Syntax

Fortran CALL SNDOT | DNDOT (n, m, s, incs, isw, x, incxi, incxo, y, incyi, incyo)
C and C++ sndot | dndot (n, m, s, incs, isw, x, incxi, incxo, y, incyi, incyo);
PL/I CALL SNDOT | DNDOT (n, m, s, incs, isw, x, incxi, incxo, y, incyi, incyo);

On Entry

n
is the number of dot product computations to be performed and the number of elements in the vector s. Specified as: a fullword integer; n >= 0.

m
is the number of elements in vectors xi and yi for each dot product computation. Specified as: a fullword integer; m >= 0.

s
is the vector s, containing the n scalar values si, where: If isw = 1 or 2, si is not used in the computation (no input value specified.)

If isw = 3 or 4, si is used in the computation (input value specified.)

Specified as: a one-dimensional array of (at least) length 1+(n-1)|incs|, containing numbers of the data type indicated in Table 45.

incs
is the stride for vector s. Specified as: a fullword integer; incs > 0 or incs < 0.

isw
indicates the type of computation to perform, depending on the value specified:

If isw = 1,    si <-- xi * yi

If isw = 2,    si <-- -xi * yi

If isw = 3,    si <-- si + xi * yi

If isw = 4,    si <-- si - xi * yi

where i = 1, n

Specified as: a fullword integer. Its value must be 1, 2, 3, or 4.

x
is the vector (or matrix) x, containing the xi vectors of length m, used in the n dot product computations. Specified as: a one- or two-dimensional array of (at least) length (1+(n-1)(incxo))+(m-1)|incxi|, containing numbers of the data type indicated in Table 45.

incxi
is the stride for x in the inner loop--that is, the stride identifying the elements in each vector xi. Specified as: a fullword integer. It can have any value.

incxo
is the stride for x in the outer loop--that is, the stride identifying each vector xi in x. Specified as: a fullword integer; incxo >= 0.

y
is the vector (or matrix) y, containing the yi vectors of length m, used in the n dot product computations. Specified as: a one- or two-dimensional array of (at least) length (1+(n-1)(incyo)) + (m-1)|incyi|, containing numbers of the data type indicated in Table 45.

incyi
is the stride for y in the inner loop--that is, the stride identifying the elements in each vector yi. Specified as: a fullword integer. It can have any value.

incyo
is the stride for y in the outer loop--that is, the stride identifying each vector yi in y. Specified as: a fullword integer; incyo >= 0.

On Return

s
is the vector s of length n, containing the results of the n dot product computations. The type of dot product computation depends of the value specified for isw.

If isw = 1,    si <-- xi * yi

If isw = 2,    si <-- -xi * yi

If isw = 3,    si <-- si + xi * yi

If isw = 4,    si <-- si - xi * yi

where i = 1, n

Returned as: a one-dimensional array, containing numbers of the data type indicated in Table 45.

Function

The four possible computations that can be performed by these subprograms are:

si <-- xi * yi Store positive dot product
si <-- -xi * yi Store negative dot product
si <-- si+xi * yi Accumulate positive dot product
si <-- si-xi * yi Accumulate negative dot product
for i = 1, n



where each si is a scalar element in the vector s of length n, and each of the n xi and yi vectors of length m are contained in vectors (or matrices) x and y, respectively. Each computation uses the dot product, which is expressed:

xi * yi = u1v1 + u2v2 + ... + umvm

where ui and vi are elements of xi and yi, respectively. To find the elements for the computation, it uses:

If m or n is 0, no computation is performed. For SNDOT, intermediate results are accumulated in long precision.

Error Conditions

Computational Errors

None

Input-Argument Errors
  1. n < 0
  2. m < 0
  3. incs = 0
  4. isw < 1 or isw > 4
  5. incxo < 0
  6. incyo < 0

Example 1

This example shows a store positive dot product computation using vectors with positive strides.

Call Statement and Input
            N   M   S  INCS ISW  X  INCXI INCXO  Y  INCYI INCYO
            |   |   |   |    |   |    |     |    |    |     |
CALL SNDOT( 3 , 4 , S , 1  , 1 , X ,  1  ,  4  , Y ,  1  ,  4  )
 
        *               *
        | 1.0  2.0  3.0 |
X    =  | 2.0  3.0  4.0 |
        | 3.0  4.0  5.0 |
        | 4.0  5.0  6.0 |
        *               *
 
        *               *
        | 4.0  3.0  2.0 |
Y    =  | 3.0  2.0  1.0 |
        | 2.0  1.0  4.0 |
        | 1.0  4.0  3.0 |
        *               *

Output
S        =  (20.0, 36.0, 48.0)

Example 2

This example shows a store negative dot product computation using vectors with positive and negative strides.

Call Statement and Input
            N   M   S   INCS ISW  X  INCXI INCXO  Y  INCYI INCYO
            |   |   |    |    |   |    |     |    |    |     |
CALL SNDOT( 3 , 4 , S , -1  , 2 , X ,  2  , 10  , Y , -1  ,  6  )
        *               *
        | 1.0  2.0  3.0 |
        |  .    .    .  |
        | 2.0  3.0  4.0 |
        |  .    .    .  |
X    =  | 3.0  4.0  5.0 |
        |  .    .    .  |
        | 4.0  5.0  6.0 |
        |  .    .    .  |
        |  .    .    .  |
        |  .    .    .  |
        *               *
        *               *
        | 4.0  3.0  2.0 |
        | 3.0  2.0  1.0 |
Y    =  | 2.0  1.0  4.0 |
        | 1.0  4.0  3.0 |
        |  .    .    .  |
        |  .    .    .  |
        *               *

Output
S        =  (-42.0, -34.0, -30.0)

Example 3

This example shows an accumulative positive dot product using vectors with positive and negative strides.

Call Statement and Input
            N   M   S  INCS ISW  X  INCXI INCXO  Y  INCYI INCYO
            |   |   |   |    |   |    |     |    |    |     |
CALL SNDOT( 3 , 4 , S , 1  , 3 , X , -2  , 10  , Y ,  2  , 10  )
 
S        =  (2.0, 5.0, 8.0)
        *               *
        | 1.0  2.0  3.0 |
        |  .    .    .  |
        | 2.0  3.0  4.0 |
        |  .    .    .  |
X    =  | 3.0  4.0  5.0 |
        |  .    .    .  |
        | 4.0  5.0  6.0 |
        |  .    .    .  |
        |  .    .    .  |
        |  .    .    .  |
        *               *
        *               *
        | 4.0  3.0  2.0 |
        |  .    .    .  |
        | 3.0  2.0  1.0 |
        |  .    .    .  |
Y    =  | 2.0  1.0  4.0 |
        |  .    .    .  |
        | 1.0  4.0  3.0 |
        |  .    .    .  |
        |  .    .    .  |
        |  .    .    .  |
        *               *

Output
S        =  (32.0, 39.0, 50.0)

Example 4

This example shows an accumulative negative dot product using vectors with positive and negative strides.

Call Statement and Input
            N   M   S   INCS ISW  X  INCXI INCXO  Y  INCYI INCYO
            |   |   |    |    |   |    |     |    |    |     |
CALL SNDOT( 3 , 4 , S , -1  , 4 , X ,  1  ,  6  , Y ,  2  , 10  )
S        =  (3.0, 6.0, 9.0)
        *               *
        | 1.0  2.0  3.0 |
        | 2.0  3.0  4.0 |
X    =  | 3.0  4.0  5.0 |
        | 4.0  5.0  6.0 |
        |  .    .    .  |
        |  .    .    .  |
        *               *
        *               *
        | 4.0  3.0  2.0 |
        |  .    .    .  |
        | 3.0  2.0  1.0 |
        |  .    .    .  |
Y    =  | 2.0  1.0  4.0 |
        |  .    .    .  |
        | 1.0  4.0  3.0 |
        |  .    .    .  |
        |  .    .    .  |
        |  .    .    .  |
        *               *

Output
S        =  (-45.0, -30.0, -11.0)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]