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