IBM Books

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

SCOPY, DCOPY, CCOPY, and ZCOPY--Copy a Vector

These subprograms copy vector x to another vector, y:

y<--x

Table 42. Data Types

x, y Subprogram
Short-precision real SCOPY
Long-precision real DCOPY
Short-precision complex CCOPY
Long-precision complex ZCOPY

Syntax

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

On Entry

n
is the number of elements in vectors x and y. Specified as: a fullword integer; n >= 0.

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

incx
is the stride for vector x. Specified as: a fullword integer. It can have any value.

y
See On Return.

incy
is the stride for vector y. Specified as: a fullword integer. It can have any value.

On Return

y
is the vector y of length n. Returned as: a one-dimensional array of (at least) length 1+(n-1)|incy|, containing numbers of the data type indicated in Table 42.

Notes
  1. If you specify the same vector for x and y, incx and incy must be equal; otherwise, results are unpredictable.
  2. If you specify different vectors for x and y, they must have no common elements; otherwise, results are unpredictable. See Concepts.

Function

The copy is expressed as follows:



Copy Graphic

See reference [79]. If n is 0, no copy is performed.

Error Conditions

Computational Errors

None

Input-Argument Errors

n < 0

Example 1

This example shows input vector x and output vector y with positive strides.

Call Statement and Input
            N   X  INCX  Y  INCY
            |   |   |    |   |
CALL SCOPY( 5 , X , 1  , Y , 2  )
 
X        =  (1.0, 2.0, 3.0, 4.0, 5.0)

Output
Y        =  (1.0, . , 2.0, . , 3.0, . , 4.0, . , 5.0)

Example 2

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

Call Statement and Input
            N   X  INCX  Y   INCY
            |   |   |    |    |
CALL SCOPY( 5 , X , 1  , Y , -1  )
 
X        =  (1.0, 2.0, 3.0, 4.0, 5.0)

Output
Y        =  (5.0, 4.0, 3.0, 2.0, 1.0)

Example 3

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.

Call Statement and Input
            N   X  INCX  Y  INCY
            |   |   |    |   |
CALL SCOPY( 5 , X , 0  , Y , 1  )
 
X        =  (13.0)

Output
Y        =  (13.0, 13.0, 13.0, 13.0, 13.0)

Example 4

This example shows input vector x and output vector y, containing complex numbers and having positive strides.

Call Statement and Input
            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))

Output
Y        =  ((1.0, 1.0), . , (2.0, 2.0), . , (3.0, 3.0), . ,
             (4.0, 4.0))


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