Previous Next Contents Generated Index Doc Set Home



Rank-1 Update to a Real Symmetric Matrix in Packed Storage

The subroutines described in this section compute the following result for a real symmetric matrix A in packed storage and a vector x:

Calling Sequence

CALL DSPR 
(UPLO, N, DALPHA, DX, INCX, DA)
CALL SSPR 
(UPLO, N, SALPHA, SX, INCX, SA)






void dspr 
(char uplo, int n, double dalpha, double *dx, int incx, 
double *da)
void sspr 
(char uplo, int n, float salpha, float *sx, int incx, 
float *sa)

Arguments

UPLO

Indicates whether the values in a matrix reside in the upper or lower triangle of the array in which the matrix is stored. The legal values for UPLO are listed below. Any value not listed below is illegal.

'L' or 'l'

Only the lower triangle of the array will be referenced.

'U' or 'u'

Only the upper triangle of the array will be referenced.

N

Size of a matrix with N rows and N columns. N 0.

xALPHA

Scalar that scales the input value of the matrix A.

xX

X and INCX describe a vector of length N. 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.

xA

One-dimensional array that contains the input matrix. The matrix is in packed storage; the array must have at least enough elements to store the non-redundant elements of the matrix.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LENGTA, N
      PARAMETER        (N = 3)
      PARAMETER        (LENGTA = (N * N + N) / 2)
C
      DOUBLE PRECISION  ALPHA, AP(LENGTA), X(N)
      INTEGER           I
C
      EXTERNAL DSPR
C
C     Initialize the array A to store in symmetric packed form the
C     matrix A shown below.  Initialize the array X to store the
C     vector x shown below.
C
C         100  200  300        1
C     A = 200  400  500    x = 2
C         300  500  600        3
C
      DATA AP / 100.0, 200.0, 300.0, 400.0, 500.0, 600.0 /
      DATA X / 1.0, 2.0, 3.0 /
C
      PRINT 1000
      PRINT 1010, AP(1), AP(2), AP(3)
      PRINT 1010, AP(2), AP(4), AP(5)
      PRINT 1010, AP(3), AP(5), AP(6)
      PRINT 1020
      PRINT 1030, AP
      PRINT 1040
      PRINT 1050, (X(I), I = 1, N)
      ALPHA = 1.0D0
      CALL DSPR ('LOWER TRIANGULAR A', N, ALPHA, X, 1, AP)
      PRINT 1060
      PRINT 1010, AP(1), AP(2), AP(3)
      PRINT 1010, AP(2), AP(4), AP(5)
      PRINT 1010, AP(3), AP(5), AP(6)
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 3(2X, F5.1))
 1020 FORMAT (/1X, 'A in packed form:')
 1030 FORMAT (1X, 6(2X, F5.1))
 1040 FORMAT (/1X, 'x:')
 1050 FORMAT (1X, 2X, F5.1)
 1060 FORMAT (/1X, 'Axx'':')
C
      END
 

Sample Output

 
 A in full form:
   100.0  200.0  300.0
   200.0  400.0  500.0
   300.0  500.0  600.0



 A in packed form:
   100.0  200.0  300.0  400.0  500.0  600.0



 x:
     1.0
     2.0
     3.0



 Axx':
   101.0  202.0  303.0
   202.0  404.0  506.0
   303.0  506.0  609.0






Previous Next Contents Generated Index Doc Set Home