These subprograms copy vector x to another vector, y:
x, y | Subprogram |
Short-precision real | SCOPY |
Long-precision real | DCOPY |
Short-precision complex | CCOPY |
Long-precision complex | ZCOPY |
Fortran | CALL SCOPY | DCOPY | CCOPY | ZCOPY (n, x, incx, y, incy) |
C and C++ | scopy | dcopy | ccopy | zcopy (n, x, incx, y, incy); |
PL/I | CALL SCOPY | DCOPY | CCOPY | ZCOPY (n, x, incx, y, incy); |
The copy is expressed as follows:
See reference [79]. If n is 0, no copy is performed.
None
n < 0
This example shows input vector x and output vector y with positive strides.
N X INCX Y INCY | | | | | CALL SCOPY( 5 , X , 1 , Y , 2 ) X = (1.0, 2.0, 3.0, 4.0, 5.0)
Y = (1.0, . , 2.0, . , 3.0, . , 4.0, . , 5.0)
This example shows how to obtain a reverse copy of the input vector x by specifying strides with the same absolute value, but with opposite signs, for input vector x and output vector y. For y, which has a negative stride, results are stored beginning at element Y(5).
N X INCX Y INCY | | | | | CALL SCOPY( 5 , X , 1 , Y , -1 ) X = (1.0, 2.0, 3.0, 4.0, 5.0)
Y = (5.0, 4.0, 3.0, 2.0, 1.0)
This example shows an input vector, x, with 0 stride. Vector x is treated like a vector of length n, all of whose elements are the same as the single element in x. This is a technique for replicating an element of a vector.
N X INCX Y INCY | | | | | CALL SCOPY( 5 , X , 0 , Y , 1 ) X = (13.0)
Y = (13.0, 13.0, 13.0, 13.0, 13.0)
This example shows input vector x and output vector y, containing complex numbers and having positive strides.
N X INCX Y INCY | | | | | CALL CCOPY( 4 , X , 1 , Y , 2 ) X = ((1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0))
Y = ((1.0, 1.0), . , (2.0, 2.0), . , (3.0, 3.0), . , (4.0, 4.0))