Previous Next Contents Generated Index Doc Set Home



Eigenvalues and Eigenvectors of a Symmetric Matrix in Banded Storage (Simple Driver)

The subroutines described in this section compute the eigenvalues and, optionally, the eigenvectors of a symmetric matrix A in banded storage. The eigenvectors are normalized to have a Euclidean norm of 1. Note that the expert driver xSBEVX is also available.

Calling Sequence

CALL DSBEV 
(JOBZ, UPLO, N, NDIAG, DA, LDA, DW, DZ, LDZ, DWORK, 
INFO)
CALL SSBEV 
(JOBZ, UPLO, N, NDIAG, SA, LDA, SW, SZ, LDZ, SWORK, 
INFO)






void dsbev 
(char jobz, char uplo, int n, int ndiag, double *da, 
int lda, double *dw, double *dz, int ldz, int *info)
void ssbev 
(char jobz, char uplo, int n, int ndiag, float *sa, int 
lda, float *sw, float *sz, int ldz, int *info)

Arguments

JOBZ

Indicates whether to compute eigenvalues only or to compute both eigenvalues and eigenvectors. The legal values for JOBZ are listed below. Any values not listed below are illegal.

'N' or 'n'

Compute eigenvalues only.

'V' or 'v'

Compute both eigenvalues and eigenvectors.

UPLO

Indicates whether xA contains the upper or lower triangle of the matrix. The legal values for UPLO are listed below. Any values not listed below are illegal.

'U' or 'u'

xA contains the upper triangle.

'L' or 'l'

xA contains the lower triangle.

N

Order of the matrix A. N 0.

NDIAG

Number of superdiagonals or subdiagonals of the matrix A. N-1 NDIAG 0 but if N = 0 then NDIAG = 0.

If UPLO = 'U' or 'u', NDIAG is the number of superdiagonals.

If UPLO = 'L' or 'l', NDIAG is the number of subdiagonals.

xA

On entry, the upper or lower triangle of the matrix A.
On exit, A is overwritten.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA NDIAG + 1.

xW

On exit, the N eigenvalues in ascending order.

xZ

On exit, if JOBZ = 'V' or 'v' then Z contains the orthonormal eigenvectors. If JOBZ = 'N' or 'n' then Z is not used.

LDZ

Leading dimension of the array Z as specified in a dimension or type statement. LDZ 1. If JOBZ = 'V' or 'v' then LDZ max(1, N).

xWORK

Scratch array with a dimension of max(1, 3 × N - 2).

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

INFO > 0

Convergence failure.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDEVEC, LDWORK, N, NDIAG
      PARAMETER        (N = 4)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (LDA = NDIAG + 1)
      PARAMETER        (LDEVEC = N)
      PARAMETER        (LDWORK = 3 * N - 2)
C
      DOUBLE PRECISION  A(LDA,N), EVALS(N), EVECS(LDEVEC,N)
      DOUBLE PRECISION  WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DSBEV
      INTRINSIC         ABS
C
C     Initialize the array A to store the symmetric tridiagonal
C     matrix A shown below.
C
C          1   0   0   0
C     A =  0   2   1   0
C          0   1   2   0
C          0   0   0   1
C
      DATA A / 8D8, 1.0D0, 0.0D0, 2.0D0, 1.0D0, 2.0D0, 0.0D0,
     $         1.0D0 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      PRINT 1010, A(2,1), A(1,2),  0.0D0, 0.0D0
      PRINT 1010, A(1,2), A(2,2), A(1,3), 0.0D0
      PRINT 1010,  0.0D0, A(1,3), A(2,3), A(1,4)
      PRINT 1010,  0.0D0,  0.0D0, A(1,4), A(2,4)
      PRINT 1020
      DO 100, IROW = 1, LDA
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  100 CONTINUE
C
C     Compute the eigenvalues and right eigenvectors of A.
C
      CALL DSBEV ('VECTORS AND EIGENVALUES',
     $            'UPPER TRIANGLE A STORED', N, NDIAG, A, LDA,
     $            EVALS, EVECS, LDEVEC, WORK, INFO)
      IF (INFO .NE. 0) THEN
        IF (INFO .LT. 0) THEN
          PRINT 1030, ABS(INFO)
          STOP 1
        ELSE
          PRINT 1040, INFO
          STOP 2
        END IF
      END IF
C
C     Print the eigenvalues and eigenvectors.
C
      PRINT 1050
      DO 120, ICOL = 1, N
        PRINT 1060, EVALS(ICOL), (EVECS(IROW,ICOL), IROW = 1, N)
  120 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(3X, F9.6))
 1020 FORMAT (/1X,
     $        'A in symmetric banded form: ',
     $        ' (* in unused elements)')
 1030 FORMAT (/1X, 'Illegal argument to DSBEV, argument #', I2)
 1040 FORMAT (/1X, 'Convergence failure, INFO = ', I2)
 1050 FORMAT (/1X, 'Eigenvalue', 10X, 'Eigenvector**T')
 1060 FORMAT (1X, F7.2, 6X, '[', 3(F5.3, ', '), F5.3, ']')
C
      END
 

Sample Output

 
 A in full form:
    1.000000    0.000000    0.000000    0.000000
    0.000000    2.000000    1.000000    0.000000
    0.000000    1.000000    2.000000    0.000000
    0.000000    0.000000    0.000000    1.000000



 A in symmetric banded form:  (* in unused elements)
   *********    0.000000    1.000000    0.000000
    1.000000    2.000000    2.000000    1.000000



 Eigenvalue          Eigenvector**T
    1.00      [1.000, 0.000, 0.000, 0.000]
    1.00      [0.000, -.707, 0.707, 0.000]
    1.00      [0.000, 0.000, 0.000, 1.000]
    3.00      [0.000, 0.707, 0.707, 0.000]






Previous Next Contents Generated Index Doc Set Home