00001 /* dsptrd.f -- translated by f2c (version 20061008). 00002 You must link the resulting object file with libf2c: 00003 on Microsoft Windows system, link with libf2c.lib; 00004 on Linux or Unix systems, link with .../path/to/libf2c.a -lm 00005 or, if you install libf2c.a in a standard place, with -lf2c -lm 00006 -- in that order, at the end of the command line, as in 00007 cc *.o -lf2c -lm 00008 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 00009 00010 http://www.netlib.org/f2c/libf2c.zip 00011 */ 00012 00013 #include "f2c.h" 00014 #include "blaswrap.h" 00015 00016 /* Table of constant values */ 00017 00018 static integer c__1 = 1; 00019 static doublereal c_b8 = 0.; 00020 static doublereal c_b14 = -1.; 00021 00022 /* Subroutine */ int dsptrd_(char *uplo, integer *n, doublereal *ap, 00023 doublereal *d__, doublereal *e, doublereal *tau, integer *info) 00024 { 00025 /* System generated locals */ 00026 integer i__1, i__2; 00027 00028 /* Local variables */ 00029 integer i__, i1, ii, i1i1; 00030 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *, 00031 integer *); 00032 doublereal taui; 00033 extern /* Subroutine */ int dspr2_(char *, integer *, doublereal *, 00034 doublereal *, integer *, doublereal *, integer *, doublereal *); 00035 doublereal alpha; 00036 extern logical lsame_(char *, char *); 00037 extern /* Subroutine */ int daxpy_(integer *, doublereal *, doublereal *, 00038 integer *, doublereal *, integer *), dspmv_(char *, integer *, 00039 doublereal *, doublereal *, doublereal *, integer *, doublereal *, 00040 doublereal *, integer *); 00041 logical upper; 00042 extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *, 00043 integer *, doublereal *), xerbla_(char *, integer *); 00044 00045 00046 /* -- LAPACK routine (version 3.2) -- */ 00047 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00048 /* November 2006 */ 00049 00050 /* .. Scalar Arguments .. */ 00051 /* .. */ 00052 /* .. Array Arguments .. */ 00053 /* .. */ 00054 00055 /* Purpose */ 00056 /* ======= */ 00057 00058 /* DSPTRD reduces a real symmetric matrix A stored in packed form to */ 00059 /* symmetric tridiagonal form T by an orthogonal similarity */ 00060 /* transformation: Q**T * A * Q = T. */ 00061 00062 /* Arguments */ 00063 /* ========= */ 00064 00065 /* UPLO (input) CHARACTER*1 */ 00066 /* = 'U': Upper triangle of A is stored; */ 00067 /* = 'L': Lower triangle of A is stored. */ 00068 00069 /* N (input) INTEGER */ 00070 /* The order of the matrix A. N >= 0. */ 00071 00072 /* AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2) */ 00073 /* On entry, the upper or lower triangle of the symmetric matrix */ 00074 /* A, packed columnwise in a linear array. The j-th column of A */ 00075 /* is stored in the array AP as follows: */ 00076 /* if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j; */ 00077 /* if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n. */ 00078 /* On exit, if UPLO = 'U', the diagonal and first superdiagonal */ 00079 /* of A are overwritten by the corresponding elements of the */ 00080 /* tridiagonal matrix T, and the elements above the first */ 00081 /* superdiagonal, with the array TAU, represent the orthogonal */ 00082 /* matrix Q as a product of elementary reflectors; if UPLO */ 00083 /* = 'L', the diagonal and first subdiagonal of A are over- */ 00084 /* written by the corresponding elements of the tridiagonal */ 00085 /* matrix T, and the elements below the first subdiagonal, with */ 00086 /* the array TAU, represent the orthogonal matrix Q as a product */ 00087 /* of elementary reflectors. See Further Details. */ 00088 00089 /* D (output) DOUBLE PRECISION array, dimension (N) */ 00090 /* The diagonal elements of the tridiagonal matrix T: */ 00091 /* D(i) = A(i,i). */ 00092 00093 /* E (output) DOUBLE PRECISION array, dimension (N-1) */ 00094 /* The off-diagonal elements of the tridiagonal matrix T: */ 00095 /* E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'. */ 00096 00097 /* TAU (output) DOUBLE PRECISION array, dimension (N-1) */ 00098 /* The scalar factors of the elementary reflectors (see Further */ 00099 /* Details). */ 00100 00101 /* INFO (output) INTEGER */ 00102 /* = 0: successful exit */ 00103 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00104 00105 /* Further Details */ 00106 /* =============== */ 00107 00108 /* If UPLO = 'U', the matrix Q is represented as a product of elementary */ 00109 /* reflectors */ 00110 00111 /* Q = H(n-1) . . . H(2) H(1). */ 00112 00113 /* Each H(i) has the form */ 00114 00115 /* H(i) = I - tau * v * v' */ 00116 00117 /* where tau is a real scalar, and v is a real vector with */ 00118 /* v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in AP, */ 00119 /* overwriting A(1:i-1,i+1), and tau is stored in TAU(i). */ 00120 00121 /* If UPLO = 'L', the matrix Q is represented as a product of elementary */ 00122 /* reflectors */ 00123 00124 /* Q = H(1) H(2) . . . H(n-1). */ 00125 00126 /* Each H(i) has the form */ 00127 00128 /* H(i) = I - tau * v * v' */ 00129 00130 /* where tau is a real scalar, and v is a real vector with */ 00131 /* v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in AP, */ 00132 /* overwriting A(i+2:n,i), and tau is stored in TAU(i). */ 00133 00134 /* ===================================================================== */ 00135 00136 /* .. Parameters .. */ 00137 /* .. */ 00138 /* .. Local Scalars .. */ 00139 /* .. */ 00140 /* .. External Subroutines .. */ 00141 /* .. */ 00142 /* .. External Functions .. */ 00143 /* .. */ 00144 /* .. Executable Statements .. */ 00145 00146 /* Test the input parameters */ 00147 00148 /* Parameter adjustments */ 00149 --tau; 00150 --e; 00151 --d__; 00152 --ap; 00153 00154 /* Function Body */ 00155 *info = 0; 00156 upper = lsame_(uplo, "U"); 00157 if (! upper && ! lsame_(uplo, "L")) { 00158 *info = -1; 00159 } else if (*n < 0) { 00160 *info = -2; 00161 } 00162 if (*info != 0) { 00163 i__1 = -(*info); 00164 xerbla_("DSPTRD", &i__1); 00165 return 0; 00166 } 00167 00168 /* Quick return if possible */ 00169 00170 if (*n <= 0) { 00171 return 0; 00172 } 00173 00174 if (upper) { 00175 00176 /* Reduce the upper triangle of A. */ 00177 /* I1 is the index in AP of A(1,I+1). */ 00178 00179 i1 = *n * (*n - 1) / 2 + 1; 00180 for (i__ = *n - 1; i__ >= 1; --i__) { 00181 00182 /* Generate elementary reflector H(i) = I - tau * v * v' */ 00183 /* to annihilate A(1:i-1,i+1) */ 00184 00185 dlarfg_(&i__, &ap[i1 + i__ - 1], &ap[i1], &c__1, &taui); 00186 e[i__] = ap[i1 + i__ - 1]; 00187 00188 if (taui != 0.) { 00189 00190 /* Apply H(i) from both sides to A(1:i,1:i) */ 00191 00192 ap[i1 + i__ - 1] = 1.; 00193 00194 /* Compute y := tau * A * v storing y in TAU(1:i) */ 00195 00196 dspmv_(uplo, &i__, &taui, &ap[1], &ap[i1], &c__1, &c_b8, &tau[ 00197 1], &c__1); 00198 00199 /* Compute w := y - 1/2 * tau * (y'*v) * v */ 00200 00201 alpha = taui * -.5 * ddot_(&i__, &tau[1], &c__1, &ap[i1], & 00202 c__1); 00203 daxpy_(&i__, &alpha, &ap[i1], &c__1, &tau[1], &c__1); 00204 00205 /* Apply the transformation as a rank-2 update: */ 00206 /* A := A - v * w' - w * v' */ 00207 00208 dspr2_(uplo, &i__, &c_b14, &ap[i1], &c__1, &tau[1], &c__1, & 00209 ap[1]); 00210 00211 ap[i1 + i__ - 1] = e[i__]; 00212 } 00213 d__[i__ + 1] = ap[i1 + i__]; 00214 tau[i__] = taui; 00215 i1 -= i__; 00216 /* L10: */ 00217 } 00218 d__[1] = ap[1]; 00219 } else { 00220 00221 /* Reduce the lower triangle of A. II is the index in AP of */ 00222 /* A(i,i) and I1I1 is the index of A(i+1,i+1). */ 00223 00224 ii = 1; 00225 i__1 = *n - 1; 00226 for (i__ = 1; i__ <= i__1; ++i__) { 00227 i1i1 = ii + *n - i__ + 1; 00228 00229 /* Generate elementary reflector H(i) = I - tau * v * v' */ 00230 /* to annihilate A(i+2:n,i) */ 00231 00232 i__2 = *n - i__; 00233 dlarfg_(&i__2, &ap[ii + 1], &ap[ii + 2], &c__1, &taui); 00234 e[i__] = ap[ii + 1]; 00235 00236 if (taui != 0.) { 00237 00238 /* Apply H(i) from both sides to A(i+1:n,i+1:n) */ 00239 00240 ap[ii + 1] = 1.; 00241 00242 /* Compute y := tau * A * v storing y in TAU(i:n-1) */ 00243 00244 i__2 = *n - i__; 00245 dspmv_(uplo, &i__2, &taui, &ap[i1i1], &ap[ii + 1], &c__1, & 00246 c_b8, &tau[i__], &c__1); 00247 00248 /* Compute w := y - 1/2 * tau * (y'*v) * v */ 00249 00250 i__2 = *n - i__; 00251 alpha = taui * -.5 * ddot_(&i__2, &tau[i__], &c__1, &ap[ii + 00252 1], &c__1); 00253 i__2 = *n - i__; 00254 daxpy_(&i__2, &alpha, &ap[ii + 1], &c__1, &tau[i__], &c__1); 00255 00256 /* Apply the transformation as a rank-2 update: */ 00257 /* A := A - v * w' - w * v' */ 00258 00259 i__2 = *n - i__; 00260 dspr2_(uplo, &i__2, &c_b14, &ap[ii + 1], &c__1, &tau[i__], & 00261 c__1, &ap[i1i1]); 00262 00263 ap[ii + 1] = e[i__]; 00264 } 00265 d__[i__] = ap[ii]; 00266 tau[i__] = taui; 00267 ii = i1i1; 00268 /* L20: */ 00269 } 00270 d__[*n] = ap[ii]; 00271 } 00272 00273 return 0; 00274 00275 /* End of DSPTRD */ 00276 00277 } /* dsptrd_ */