LAPACK 3.3.1
Linear Algebra PACKage

slatrd.f

Go to the documentation of this file.
00001       SUBROUTINE SLATRD( UPLO, N, NB, A, LDA, E, TAU, W, LDW )
00002 *
00003 *  -- LAPACK auxiliary routine (version 3.3.1) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *  -- April 2011                                                      --
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          UPLO
00010       INTEGER            LDA, LDW, N, NB
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               A( LDA, * ), E( * ), TAU( * ), W( LDW, * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  SLATRD reduces NB rows and columns of a real symmetric matrix A to
00020 *  symmetric tridiagonal form by an orthogonal similarity
00021 *  transformation Q**T * A * Q, and returns the matrices V and W which are
00022 *  needed to apply the transformation to the unreduced part of A.
00023 *
00024 *  If UPLO = 'U', SLATRD reduces the last NB rows and columns of a
00025 *  matrix, of which the upper triangle is supplied;
00026 *  if UPLO = 'L', SLATRD reduces the first NB rows and columns of a
00027 *  matrix, of which the lower triangle is supplied.
00028 *
00029 *  This is an auxiliary routine called by SSYTRD.
00030 *
00031 *  Arguments
00032 *  =========
00033 *
00034 *  UPLO    (input) CHARACTER*1
00035 *          Specifies whether the upper or lower triangular part of the
00036 *          symmetric matrix A is stored:
00037 *          = 'U': Upper triangular
00038 *          = 'L': Lower triangular
00039 *
00040 *  N       (input) INTEGER
00041 *          The order of the matrix A.
00042 *
00043 *  NB      (input) INTEGER
00044 *          The number of rows and columns to be reduced.
00045 *
00046 *  A       (input/output) REAL array, dimension (LDA,N)
00047 *          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
00048 *          n-by-n upper triangular part of A contains the upper
00049 *          triangular part of the matrix A, and the strictly lower
00050 *          triangular part of A is not referenced.  If UPLO = 'L', the
00051 *          leading n-by-n lower triangular part of A contains the lower
00052 *          triangular part of the matrix A, and the strictly upper
00053 *          triangular part of A is not referenced.
00054 *          On exit:
00055 *          if UPLO = 'U', the last NB columns have been reduced to
00056 *            tridiagonal form, with the diagonal elements overwriting
00057 *            the diagonal elements of A; the elements above the diagonal
00058 *            with the array TAU, represent the orthogonal matrix Q as a
00059 *            product of elementary reflectors;
00060 *          if UPLO = 'L', the first NB columns have been reduced to
00061 *            tridiagonal form, with the diagonal elements overwriting
00062 *            the diagonal elements of A; the elements below the diagonal
00063 *            with the array TAU, represent the  orthogonal matrix Q as a
00064 *            product of elementary reflectors.
00065 *          See Further Details.
00066 *
00067 *  LDA     (input) INTEGER
00068 *          The leading dimension of the array A.  LDA >= (1,N).
00069 *
00070 *  E       (output) REAL array, dimension (N-1)
00071 *          If UPLO = 'U', E(n-nb:n-1) contains the superdiagonal
00072 *          elements of the last NB columns of the reduced matrix;
00073 *          if UPLO = 'L', E(1:nb) contains the subdiagonal elements of
00074 *          the first NB columns of the reduced matrix.
00075 *
00076 *  TAU     (output) REAL array, dimension (N-1)
00077 *          The scalar factors of the elementary reflectors, stored in
00078 *          TAU(n-nb:n-1) if UPLO = 'U', and in TAU(1:nb) if UPLO = 'L'.
00079 *          See Further Details.
00080 *
00081 *  W       (output) REAL array, dimension (LDW,NB)
00082 *          The n-by-nb matrix W required to update the unreduced part
00083 *          of A.
00084 *
00085 *  LDW     (input) INTEGER
00086 *          The leading dimension of the array W. LDW >= max(1,N).
00087 *
00088 *  Further Details
00089 *  ===============
00090 *
00091 *  If UPLO = 'U', the matrix Q is represented as a product of elementary
00092 *  reflectors
00093 *
00094 *     Q = H(n) H(n-1) . . . H(n-nb+1).
00095 *
00096 *  Each H(i) has the form
00097 *
00098 *     H(i) = I - tau * v * v**T
00099 *
00100 *  where tau is a real scalar, and v is a real vector with
00101 *  v(i:n) = 0 and v(i-1) = 1; v(1:i-1) is stored on exit in A(1:i-1,i),
00102 *  and tau in TAU(i-1).
00103 *
00104 *  If UPLO = 'L', the matrix Q is represented as a product of elementary
00105 *  reflectors
00106 *
00107 *     Q = H(1) H(2) . . . H(nb).
00108 *
00109 *  Each H(i) has the form
00110 *
00111 *     H(i) = I - tau * v * v**T
00112 *
00113 *  where tau is a real scalar, and v is a real vector with
00114 *  v(1:i) = 0 and v(i+1) = 1; v(i+1:n) is stored on exit in A(i+1:n,i),
00115 *  and tau in TAU(i).
00116 *
00117 *  The elements of the vectors v together form the n-by-nb matrix V
00118 *  which is needed, with W, to apply the transformation to the unreduced
00119 *  part of the matrix, using a symmetric rank-2k update of the form:
00120 *  A := A - V*W**T - W*V**T.
00121 *
00122 *  The contents of A on exit are illustrated by the following examples
00123 *  with n = 5 and nb = 2:
00124 *
00125 *  if UPLO = 'U':                       if UPLO = 'L':
00126 *
00127 *    (  a   a   a   v4  v5 )              (  d                  )
00128 *    (      a   a   v4  v5 )              (  1   d              )
00129 *    (          a   1   v5 )              (  v1  1   a          )
00130 *    (              d   1  )              (  v1  v2  a   a      )
00131 *    (                  d  )              (  v1  v2  a   a   a  )
00132 *
00133 *  where d denotes a diagonal element of the reduced matrix, a denotes
00134 *  an element of the original matrix that is unchanged, and vi denotes
00135 *  an element of the vector defining H(i).
00136 *
00137 *  =====================================================================
00138 *
00139 *     .. Parameters ..
00140       REAL               ZERO, ONE, HALF
00141       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0, HALF = 0.5E+0 )
00142 *     ..
00143 *     .. Local Scalars ..
00144       INTEGER            I, IW
00145       REAL               ALPHA
00146 *     ..
00147 *     .. External Subroutines ..
00148       EXTERNAL           SAXPY, SGEMV, SLARFG, SSCAL, SSYMV
00149 *     ..
00150 *     .. External Functions ..
00151       LOGICAL            LSAME
00152       REAL               SDOT
00153       EXTERNAL           LSAME, SDOT
00154 *     ..
00155 *     .. Intrinsic Functions ..
00156       INTRINSIC          MIN
00157 *     ..
00158 *     .. Executable Statements ..
00159 *
00160 *     Quick return if possible
00161 *
00162       IF( N.LE.0 )
00163      $   RETURN
00164 *
00165       IF( LSAME( UPLO, 'U' ) ) THEN
00166 *
00167 *        Reduce last NB columns of upper triangle
00168 *
00169          DO 10 I = N, N - NB + 1, -1
00170             IW = I - N + NB
00171             IF( I.LT.N ) THEN
00172 *
00173 *              Update A(1:i,i)
00174 *
00175                CALL SGEMV( 'No transpose', I, N-I, -ONE, A( 1, I+1 ),
00176      $                     LDA, W( I, IW+1 ), LDW, ONE, A( 1, I ), 1 )
00177                CALL SGEMV( 'No transpose', I, N-I, -ONE, W( 1, IW+1 ),
00178      $                     LDW, A( I, I+1 ), LDA, ONE, A( 1, I ), 1 )
00179             END IF
00180             IF( I.GT.1 ) THEN
00181 *
00182 *              Generate elementary reflector H(i) to annihilate
00183 *              A(1:i-2,i)
00184 *
00185                CALL SLARFG( I-1, A( I-1, I ), A( 1, I ), 1, TAU( I-1 ) )
00186                E( I-1 ) = A( I-1, I )
00187                A( I-1, I ) = ONE
00188 *
00189 *              Compute W(1:i-1,i)
00190 *
00191                CALL SSYMV( 'Upper', I-1, ONE, A, LDA, A( 1, I ), 1,
00192      $                     ZERO, W( 1, IW ), 1 )
00193                IF( I.LT.N ) THEN
00194                   CALL SGEMV( 'Transpose', I-1, N-I, ONE, W( 1, IW+1 ),
00195      $                        LDW, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
00196                   CALL SGEMV( 'No transpose', I-1, N-I, -ONE,
00197      $                        A( 1, I+1 ), LDA, W( I+1, IW ), 1, ONE,
00198      $                        W( 1, IW ), 1 )
00199                   CALL SGEMV( 'Transpose', I-1, N-I, ONE, A( 1, I+1 ),
00200      $                        LDA, A( 1, I ), 1, ZERO, W( I+1, IW ), 1 )
00201                   CALL SGEMV( 'No transpose', I-1, N-I, -ONE,
00202      $                        W( 1, IW+1 ), LDW, W( I+1, IW ), 1, ONE,
00203      $                        W( 1, IW ), 1 )
00204                END IF
00205                CALL SSCAL( I-1, TAU( I-1 ), W( 1, IW ), 1 )
00206                ALPHA = -HALF*TAU( I-1 )*SDOT( I-1, W( 1, IW ), 1,
00207      $                 A( 1, I ), 1 )
00208                CALL SAXPY( I-1, ALPHA, A( 1, I ), 1, W( 1, IW ), 1 )
00209             END IF
00210 *
00211    10    CONTINUE
00212       ELSE
00213 *
00214 *        Reduce first NB columns of lower triangle
00215 *
00216          DO 20 I = 1, NB
00217 *
00218 *           Update A(i:n,i)
00219 *
00220             CALL SGEMV( 'No transpose', N-I+1, I-1, -ONE, A( I, 1 ),
00221      $                  LDA, W( I, 1 ), LDW, ONE, A( I, I ), 1 )
00222             CALL SGEMV( 'No transpose', N-I+1, I-1, -ONE, W( I, 1 ),
00223      $                  LDW, A( I, 1 ), LDA, ONE, A( I, I ), 1 )
00224             IF( I.LT.N ) THEN
00225 *
00226 *              Generate elementary reflector H(i) to annihilate
00227 *              A(i+2:n,i)
00228 *
00229                CALL SLARFG( N-I, A( I+1, I ), A( MIN( I+2, N ), I ), 1,
00230      $                      TAU( I ) )
00231                E( I ) = A( I+1, I )
00232                A( I+1, I ) = ONE
00233 *
00234 *              Compute W(i+1:n,i)
00235 *
00236                CALL SSYMV( 'Lower', N-I, ONE, A( I+1, I+1 ), LDA,
00237      $                     A( I+1, I ), 1, ZERO, W( I+1, I ), 1 )
00238                CALL SGEMV( 'Transpose', N-I, I-1, ONE, W( I+1, 1 ), LDW,
00239      $                     A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
00240                CALL SGEMV( 'No transpose', N-I, I-1, -ONE, A( I+1, 1 ),
00241      $                     LDA, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
00242                CALL SGEMV( 'Transpose', N-I, I-1, ONE, A( I+1, 1 ), LDA,
00243      $                     A( I+1, I ), 1, ZERO, W( 1, I ), 1 )
00244                CALL SGEMV( 'No transpose', N-I, I-1, -ONE, W( I+1, 1 ),
00245      $                     LDW, W( 1, I ), 1, ONE, W( I+1, I ), 1 )
00246                CALL SSCAL( N-I, TAU( I ), W( I+1, I ), 1 )
00247                ALPHA = -HALF*TAU( I )*SDOT( N-I, W( I+1, I ), 1,
00248      $                 A( I+1, I ), 1 )
00249                CALL SAXPY( N-I, ALPHA, A( I+1, I ), 1, W( I+1, I ), 1 )
00250             END IF
00251 *
00252    20    CONTINUE
00253       END IF
00254 *
00255       RETURN
00256 *
00257 *     End of SLATRD
00258 *
00259       END
 All Files Functions