Previous Next Contents Generated Index Doc Set Home



Copy a Vector

The subroutines described in this section copy vector x into vector y.

Calling Sequence

CALL DCOPY 
(N, DX, INCX, DY, INCY)
CALL SCOPY 
(N, SX, INCX, SY, INCY)
CALL ZCOPY 
(N, ZX, INCX, ZY, INCY)
CALL CCOPY 
(N, CX, INCX, CY, INCY)






void dcopy 
(int n, double *dx, int incx, double *dy, int incy)
void scopy 
(int n, float *sx, int incx, float *sy, int incy)
void zcopy 
(int n, doublecomplex *zx, int incx, doublecomplex *zy, 
int incy)
void ccopy 
(int n, complex *cx, int incx, complex *cy, int incy)

Arguments

N

Number of elements in the vector. N 0.

xX

Input vector X; the size of array X must be at least max(1,N*|INCX|).

INCX

Specifies the storage spacing between successive elements of the vector X. A value of one indicates that the elements of the vector are consecutive in memory.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X then the elements of the vector will be a row of X.

If X refers to a two-dimensional array and the value of INCX is equal to the leading dimension of X plus one then the elements of the vector will be a diagonal of X.

xY

Result vector Y; the size of array Y must be at least max(1,N*|INCY|).

INCY

Specifies the storage spacing between successive elements of the vector Y. A value of one indicates that the elements of the vector are consecutive in memory.

If Y refers to a two-dimensional array and the value of INCY is equal to the leading dimension of Y then the elements of the vector will be a row of Y.

If Y refers to a two-dimensional array and the value of INCY is equal to the leading dimension of Y plus one then the elements of the vector will be a diagonal of Y.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           N
      PARAMETER        (N = 3)
C
      INTEGER           I, INCX, INCY, J
      DOUBLE PRECISION  A(N,N), B(N,N)
C
      EXTERNAL          DCOPY
C
C     Initialize the array A to store the matrix A shown below.
C
C         1  4  7
C     A = 2  5  8
C         3  6  9
C
      DATA A / 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0, 6.0D0,
     $         7.0D0, 8.0D0, 9.0D0 /
C
      PRINT 1000
      PRINT 1010, ((A(I,J), J = 1, N), I = 1, N)
      INCX = 0
      INCY = 1
C
C     Use DCOPY to initialize all element of B to zero.
C
      CALL DCOPY (N * N, 0.0D0, INCX, B, INCY)
C
C     Copy A' into B.
C
      INCX = 1
      INCY = N
      DO 10, I = 1, N
         CALL DCOPY (N, A(1,I), INCX, B(I,1), INCY)
   10 CONTINUE
      PRINT 1020
      PRINT 1010, ((B(I,J), J = 1, N), I = 1, N)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (3(3(2X, F3.1) / ))
 1020 FORMAT (1X, 'A'':')
C
      END
 

Sample Output




 A:
  1.0  4.0  7.0
  2.0  5.0  8.0
  3.0  6.0  9.0



 A':
  1.0  2.0  3.0
  4.0  5.0  6.0
  7.0  8.0  9.0






Previous Next Contents Generated Index Doc Set Home