These subprograms perform the following computation, using the scalar alpha and the vector x:
alpha | x | Subprogram |
Short-precision real | Short-precision real | SSCAL |
Long-precision real | Long-precision real | DSCAL |
Short-precision complex | Short-precision complex | CSCAL |
Long-precision complex | Long-precision complex | ZSCAL |
Short-precision real | Short-precision complex | CSSCAL |
Long-precision real | Long-precision complex | ZDSCAL |
Fortran | CALL SSCAL | DSCAL | CSCAL | ZSCAL | CSSCAL | ZDSCAL (n, alpha, x, incx) |
C and C++ | sscal | dscal | cscal | zscal | csscal | zdscal (n, alpha, x, incx); |
PL/I | CALL SSCAL | DSCAL | CSCAL | ZSCAL | CSSCAL | ZDSCAL (n, alpha, x, incx); |
The fastest way in ESSL to zero out contiguous (stride 1) arrays is to call SSCAL or DSCAL, specifying incx = 1 and alpha = 0.
The computation is expressed as follows:
See reference [79]. If n is 0, no computation is performed. For CSCAL, intermediate results are accumulated in long precision.
None
n < 0
This example shows a vector, x, with a stride of 1.
N ALPHA X INCX | | | | CALL SSCAL( 5 , 2.0 , X , 1 ) X = (1.0, 2.0, 3.0, 4.0, 5.0)
X = (2.0, 4.0, 6.0, 8.0, 10.0)
This example shows vector, x, with a stride greater than 1.
N ALPHA X INCX | | | | CALL SSCAL( 5 , 2.0 , X , 2 ) X = (1.0, . , 2.0, . , 3.0, . , 4.0, . , 5.0)
X = (2.0, . , 4.0, . , 6.0, . , 8.0, . , 10.0)
This example illustrates that when the strides for two similar computations (Example 1 and Example 3) have the same absolute value but have opposite signs, the output is the same. This example is the same as Example 1, except the stride for x is negative (-1). For performance reasons, it is better to specify the positive stride. For x, processing begins at element X(5), which is 5.0, and results are stored beginning at the same element.
N ALPHA X INCX | | | | CALL SSCAL( 5 , 2.0 , X , -1 ) X = (1.0, 2.0, 3.0, 4.0, 5.0)
X = (2.0, 4.0, 6.0, 8.0, 10.0)
This example shows how SSCAL can be used to compute a scalar value. In this case, input vector x contains a scalar value, and the stride is 0. The number of elements to be processed, n, is 1.
N ALPHA X INCX | | | | CALL SSCAL( 1 , 2.0 , X , 0 ) X = (1.0)
X = (2.0)
This example shows a scalar, alpha, and a vector, x, containing complex numbers, where vector x has a stride of 1.
N ALPHA X INCX | | | | CALL CSCAL( 3 ,ALPHA, X , 1 ) ALPHA = (2.0, 3.0) X = ((1.0, 2.0), (2.0, 0.0), (3.0, 5.0))
X = ((-4.0, 7.0), (4.0, 6.0), (-9.0, 19.0))
This example shows a scalar, alpha, containing a real number, and a vector, x, containing complex numbers, where vector x has a stride of 1.
N ALPHA X INCX | | | | CALL CSSCAL( 3 , 2.0 , X , 1 ) X = ((1.0, 2.0), (2.0, 0.0), (3.0, 5.0))
X = ((2.0, 4.0), (4.0, 0.0), (6.0, 10.0))