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 |
|
|
|
|
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.
s, x, y | Subprogram |
Short-precision real | SNDOT |
Long-precision real | DNDOT |
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); |
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.
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
Specified as: a fullword integer. Its value must be 1, 2, 3, or 4.
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
Returned as: a one-dimensional array, containing numbers of the data type indicated in Table 45.
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 |
|
|
|
|
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:
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.
None
This example shows a store positive dot product computation using vectors with positive strides.
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 | * *
S = (20.0, 36.0, 48.0)
This example shows a store negative dot product computation using vectors with positive and negative strides.
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 | | . . . | | . . . | * *
S = (-42.0, -34.0, -30.0)
This example shows an accumulative positive dot product using vectors with positive and negative strides.
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 | | . . . | | . . . | | . . . | * *
S = (32.0, 39.0, 50.0)
This example shows an accumulative negative dot product using vectors with positive and negative strides.
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 | | . . . | | . . . | | . . . | * *
S = (-45.0, -30.0, -11.0)