Previous Next Contents Generated Index Doc Set Home



Rank-1 Update to a General Matrix

The subroutines described in this section compute one of the following results for a general matrix A and vectors x and y.

DGER, SGER, ZGERU, and CGERU compute:

ZGERC and CGERC compute:

Calling Sequence

CALL DGER 
(M, N, DALPHA, DX, INCX, DY, INCY, DA, LDA)
CALL SGER 
(M, N, SALPHA, SX, INCX, SY, INCY, SA, LDA)
CALL ZGERC
(M, N, ZALPHA, ZX, INCX, ZY, INCY, ZA, LDA)
CALL ZGERU 
(M, N, ZALPHA, ZX, INCX, ZY, INCY, ZA, LDA)
CALL CGERC 
(M, N, CALPHA, CX, INCX, CY, INCY, CA, LDA)
CALL CGERU 
(M, N, CALPHA, CX, INCX, CY, INCY, CA, LDA)






void dger
(int m, int n, double dalpha, double *dx, int incx, 
double *dy, int incy, double *da, int lda)
void sger
(int m, int n, float salpha, float *sx, int incx, float 
*sy, int incy, float *sa, int lda)
void zgerc
(int m, int n, doublecomplex *zalpha, doublecomplex 
*zx, int incx, doublecomplex *zy, int incy, 
doublecomplex *za, int lda)
void zgeru 
(int m, int n, doublecomplex *zalpha, doublecomplex 
*zx, int incx, doublecomplex *zy, int incy, 
doublecomplex *za, int lda)
void cgerc
(int m, int n, complex *calpha, complex *cx, int incx, 
complex *cy, int incy, complex *ca, int lda)
void cgeru 
(int m, int n, complex *calpha, complex *cx, int incx, 
complex *cy, int incy, complex *ca, int lda)

Arguments

M

Number of rows in the matrix A. M 0.

N

Number of columns in the matrix A. N 0.

xALPHA

Scalar that scales the input value of the matrix A.

xX

X and INCX describe a vector of length M. X contains an input vector.

INCX

Scalar that contains the storage spacing between successive elements of the vector. INCX 0. If INCX = 1, then elements of the vector are contiguous in memory. INCX may take on values besides 1 to allow the programmer to extract from a matrix a vector that is not stored in contiguous memory locations.

If X is a one-dimensional array and INCX = -1 then the array will be accessed in reverse order.

If X is a two-dimensional array and INCX = LDA then the vector will be a row of the array.

If X is a two-dimensional array and INCX = LDA+1 then the vector will be a diagonal of the array.

xY

Y and INCY describe a vector of length N. Y contains an input vector.

INCY

Scalar that contains the storage spacing between successive elements of the vector Y. INCY 0. If INCY = 1, then elements of the vector are contiguous in memory. INCY may take on values besides 1 to allow the programmer to extract from a matrix a vector that is not stored in contiguous memory locations.

If Y is a one-dimensional array and INCY = -1 then the array will be accessed in reverse order.

If Y is a two-dimensional array and INCY = LDA then the vector will be a row of the array.

If Y is a two-dimensional array and INCY = LDA+1 then the vector will be a diagonal of the array.

xA

Two-dimensional array.

On entry, the input matrix.

On exit, the result matrix.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1,M).

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER LDA, M, N
      PARAMETER        (M = 4)
      PARAMETER        (LDA = M)
      PARAMETER        (N = 3)
C
      DOUBLE PRECISION  A(LDA,N), ALPHA, X(M), Y(N)
      INTEGER           I, J
C
      EXTERNAL          DGER
      INTRINSIC         DBLE
C
C     Initialize the array A to store the general matrix A, and
C     initialize the arrays X and Y to store the vectors x and y
C     shown below:
C
C         100  100  100        1        1
C     A = 100  100  100    x = 2    y = 2
C         100  100  100        3        3
C         100  100  100        4
C
      DO 110, J = 1, N
        DO 100, I = 1, M
          A(I,J) = 1.0D2
  100   CONTINUE
        Y(J) = DBLE (J)
  110 CONTINUE
      DO 120, I = 1, M
        X(I) = DBLE (I)
  120 CONTINUE
      PRINT 1000
      DO 130, I = 1, M
        PRINT 1010, (A(I,J), J = 1, N)
  130 CONTINUE
      PRINT 1020
      DO 140, I = 1, N
        PRINT 1030, X(I), Y(I)
  140 CONTINUE
      PRINT 1030, X(M)
      ALPHA = 1.0D0
      CALL DGER (M, N, ALPHA, X, 1, Y, 1, A, LDA)
      PRINT 1040
      DO 150, I = 1, M
        PRINT 1010, (A(I,J), J = 1, N)
  150 CONTINUE
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (1X, 3(2X, F5.1))
 1020 FORMAT (/1X, '   x ', 2X, '   y ')
 1030 FORMAT (1X, F5.1, 2X, F5.1)
 1040 FORMAT (/1X, 'A + xy'':')
C
      END
 

Sample Output

 
 A:
   100.0  100.0  100.0
   100.0  100.0  100.0
   100.0  100.0  100.0
   100.0  100.0  100.0



    x      y 
   1.0    1.0
   2.0    2.0
   3.0    3.0
   4.0



 A + xy':
   101.0  102.0  103.0
   102.0  104.0  106.0
   103.0  106.0  109.0
   104.0  108.0  112.0






Previous Next Contents Generated Index Doc Set Home