00001 /* dstevd.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 00020 /* Subroutine */ int dstevd_(char *jobz, integer *n, doublereal *d__, 00021 doublereal *e, doublereal *z__, integer *ldz, doublereal *work, 00022 integer *lwork, integer *iwork, integer *liwork, integer *info) 00023 { 00024 /* System generated locals */ 00025 integer z_dim1, z_offset, i__1; 00026 doublereal d__1; 00027 00028 /* Builtin functions */ 00029 double sqrt(doublereal); 00030 00031 /* Local variables */ 00032 doublereal eps, rmin, rmax, tnrm; 00033 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 00034 integer *); 00035 doublereal sigma; 00036 extern logical lsame_(char *, char *); 00037 integer lwmin; 00038 logical wantz; 00039 extern doublereal dlamch_(char *); 00040 integer iscale; 00041 extern /* Subroutine */ int dstedc_(char *, integer *, doublereal *, 00042 doublereal *, doublereal *, integer *, doublereal *, integer *, 00043 integer *, integer *, integer *); 00044 doublereal safmin; 00045 extern /* Subroutine */ int xerbla_(char *, integer *); 00046 doublereal bignum; 00047 extern doublereal dlanst_(char *, integer *, doublereal *, doublereal *); 00048 extern /* Subroutine */ int dsterf_(integer *, doublereal *, doublereal *, 00049 integer *); 00050 integer liwmin; 00051 doublereal smlnum; 00052 logical lquery; 00053 00054 00055 /* -- LAPACK driver routine (version 3.2) -- */ 00056 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00057 /* November 2006 */ 00058 00059 /* .. Scalar Arguments .. */ 00060 /* .. */ 00061 /* .. Array Arguments .. */ 00062 /* .. */ 00063 00064 /* Purpose */ 00065 /* ======= */ 00066 00067 /* DSTEVD computes all eigenvalues and, optionally, eigenvectors of a */ 00068 /* real symmetric tridiagonal matrix. If eigenvectors are desired, it */ 00069 /* uses a divide and conquer algorithm. */ 00070 00071 /* The divide and conquer algorithm makes very mild assumptions about */ 00072 /* floating point arithmetic. It will work on machines with a guard */ 00073 /* digit in add/subtract, or on those binary machines without guard */ 00074 /* digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or */ 00075 /* Cray-2. It could conceivably fail on hexadecimal or decimal machines */ 00076 /* without guard digits, but we know of none. */ 00077 00078 /* Arguments */ 00079 /* ========= */ 00080 00081 /* JOBZ (input) CHARACTER*1 */ 00082 /* = 'N': Compute eigenvalues only; */ 00083 /* = 'V': Compute eigenvalues and eigenvectors. */ 00084 00085 /* N (input) INTEGER */ 00086 /* The order of the matrix. N >= 0. */ 00087 00088 /* D (input/output) DOUBLE PRECISION array, dimension (N) */ 00089 /* On entry, the n diagonal elements of the tridiagonal matrix */ 00090 /* A. */ 00091 /* On exit, if INFO = 0, the eigenvalues in ascending order. */ 00092 00093 /* E (input/output) DOUBLE PRECISION array, dimension (N-1) */ 00094 /* On entry, the (n-1) subdiagonal elements of the tridiagonal */ 00095 /* matrix A, stored in elements 1 to N-1 of E. */ 00096 /* On exit, the contents of E are destroyed. */ 00097 00098 /* Z (output) DOUBLE PRECISION array, dimension (LDZ, N) */ 00099 /* If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal */ 00100 /* eigenvectors of the matrix A, with the i-th column of Z */ 00101 /* holding the eigenvector associated with D(i). */ 00102 /* If JOBZ = 'N', then Z is not referenced. */ 00103 00104 /* LDZ (input) INTEGER */ 00105 /* The leading dimension of the array Z. LDZ >= 1, and if */ 00106 /* JOBZ = 'V', LDZ >= max(1,N). */ 00107 00108 /* WORK (workspace/output) DOUBLE PRECISION array, */ 00109 /* dimension (LWORK) */ 00110 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */ 00111 00112 /* LWORK (input) INTEGER */ 00113 /* The dimension of the array WORK. */ 00114 /* If JOBZ = 'N' or N <= 1 then LWORK must be at least 1. */ 00115 /* If JOBZ = 'V' and N > 1 then LWORK must be at least */ 00116 /* ( 1 + 4*N + N**2 ). */ 00117 00118 /* If LWORK = -1, then a workspace query is assumed; the routine */ 00119 /* only calculates the optimal sizes of the WORK and IWORK */ 00120 /* arrays, returns these values as the first entries of the WORK */ 00121 /* and IWORK arrays, and no error message related to LWORK or */ 00122 /* LIWORK is issued by XERBLA. */ 00123 00124 /* IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */ 00125 /* On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. */ 00126 00127 /* LIWORK (input) INTEGER */ 00128 /* The dimension of the array IWORK. */ 00129 /* If JOBZ = 'N' or N <= 1 then LIWORK must be at least 1. */ 00130 /* If JOBZ = 'V' and N > 1 then LIWORK must be at least 3+5*N. */ 00131 00132 /* If LIWORK = -1, then a workspace query is assumed; the */ 00133 /* routine only calculates the optimal sizes of the WORK and */ 00134 /* IWORK arrays, returns these values as the first entries of */ 00135 /* the WORK and IWORK arrays, and no error message related to */ 00136 /* LWORK or LIWORK is issued by XERBLA. */ 00137 00138 /* INFO (output) INTEGER */ 00139 /* = 0: successful exit */ 00140 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00141 /* > 0: if INFO = i, the algorithm failed to converge; i */ 00142 /* off-diagonal elements of E did not converge to zero. */ 00143 00144 /* ===================================================================== */ 00145 00146 /* .. Parameters .. */ 00147 /* .. */ 00148 /* .. Local Scalars .. */ 00149 /* .. */ 00150 /* .. External Functions .. */ 00151 /* .. */ 00152 /* .. External Subroutines .. */ 00153 /* .. */ 00154 /* .. Intrinsic Functions .. */ 00155 /* .. */ 00156 /* .. Executable Statements .. */ 00157 00158 /* Test the input parameters. */ 00159 00160 /* Parameter adjustments */ 00161 --d__; 00162 --e; 00163 z_dim1 = *ldz; 00164 z_offset = 1 + z_dim1; 00165 z__ -= z_offset; 00166 --work; 00167 --iwork; 00168 00169 /* Function Body */ 00170 wantz = lsame_(jobz, "V"); 00171 lquery = *lwork == -1 || *liwork == -1; 00172 00173 *info = 0; 00174 liwmin = 1; 00175 lwmin = 1; 00176 if (*n > 1 && wantz) { 00177 /* Computing 2nd power */ 00178 i__1 = *n; 00179 lwmin = (*n << 2) + 1 + i__1 * i__1; 00180 liwmin = *n * 5 + 3; 00181 } 00182 00183 if (! (wantz || lsame_(jobz, "N"))) { 00184 *info = -1; 00185 } else if (*n < 0) { 00186 *info = -2; 00187 } else if (*ldz < 1 || wantz && *ldz < *n) { 00188 *info = -6; 00189 } 00190 00191 if (*info == 0) { 00192 work[1] = (doublereal) lwmin; 00193 iwork[1] = liwmin; 00194 00195 if (*lwork < lwmin && ! lquery) { 00196 *info = -8; 00197 } else if (*liwork < liwmin && ! lquery) { 00198 *info = -10; 00199 } 00200 } 00201 00202 if (*info != 0) { 00203 i__1 = -(*info); 00204 xerbla_("DSTEVD", &i__1); 00205 return 0; 00206 } else if (lquery) { 00207 return 0; 00208 } 00209 00210 /* Quick return if possible */ 00211 00212 if (*n == 0) { 00213 return 0; 00214 } 00215 00216 if (*n == 1) { 00217 if (wantz) { 00218 z__[z_dim1 + 1] = 1.; 00219 } 00220 return 0; 00221 } 00222 00223 /* Get machine constants. */ 00224 00225 safmin = dlamch_("Safe minimum"); 00226 eps = dlamch_("Precision"); 00227 smlnum = safmin / eps; 00228 bignum = 1. / smlnum; 00229 rmin = sqrt(smlnum); 00230 rmax = sqrt(bignum); 00231 00232 /* Scale matrix to allowable range, if necessary. */ 00233 00234 iscale = 0; 00235 tnrm = dlanst_("M", n, &d__[1], &e[1]); 00236 if (tnrm > 0. && tnrm < rmin) { 00237 iscale = 1; 00238 sigma = rmin / tnrm; 00239 } else if (tnrm > rmax) { 00240 iscale = 1; 00241 sigma = rmax / tnrm; 00242 } 00243 if (iscale == 1) { 00244 dscal_(n, &sigma, &d__[1], &c__1); 00245 i__1 = *n - 1; 00246 dscal_(&i__1, &sigma, &e[1], &c__1); 00247 } 00248 00249 /* For eigenvalues only, call DSTERF. For eigenvalues and */ 00250 /* eigenvectors, call DSTEDC. */ 00251 00252 if (! wantz) { 00253 dsterf_(n, &d__[1], &e[1], info); 00254 } else { 00255 dstedc_("I", n, &d__[1], &e[1], &z__[z_offset], ldz, &work[1], lwork, 00256 &iwork[1], liwork, info); 00257 } 00258 00259 /* If matrix was scaled, then rescale eigenvalues appropriately. */ 00260 00261 if (iscale == 1) { 00262 d__1 = 1. / sigma; 00263 dscal_(n, &d__1, &d__[1], &c__1); 00264 } 00265 00266 work[1] = (doublereal) lwmin; 00267 iwork[1] = liwmin; 00268 00269 return 0; 00270 00271 /* End of DSTEVD */ 00272 00273 } /* dstevd_ */