zpteqr.c
Go to the documentation of this file.
00001 /* zpteqr.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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__0 = 0;
00021 static integer c__1 = 1;
00022 
00023 /* Subroutine */ int zpteqr_(char *compz, integer *n, doublereal *d__, 
00024         doublereal *e, doublecomplex *z__, integer *ldz, doublereal *work, 
00025         integer *info)
00026 {
00027     /* System generated locals */
00028     integer z_dim1, z_offset, i__1;
00029 
00030     /* Builtin functions */
00031     double sqrt(doublereal);
00032 
00033     /* Local variables */
00034     doublecomplex c__[1]        /* was [1][1] */;
00035     integer i__;
00036     doublecomplex vt[1] /* was [1][1] */;
00037     integer nru;
00038     extern logical lsame_(char *, char *);
00039     extern /* Subroutine */ int xerbla_(char *, integer *);
00040     integer icompz;
00041     extern /* Subroutine */ int zlaset_(char *, integer *, integer *, 
00042             doublecomplex *, doublecomplex *, doublecomplex *, integer *), dpttrf_(integer *, doublereal *, doublereal *, integer *)
00043             , zbdsqr_(char *, integer *, integer *, integer *, integer *, 
00044             doublereal *, doublereal *, doublecomplex *, integer *, 
00045             doublecomplex *, integer *, doublecomplex *, integer *, 
00046             doublereal *, integer *);
00047 
00048 
00049 /*  -- LAPACK routine (version 3.2) -- */
00050 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00051 /*     November 2006 */
00052 
00053 /*     .. Scalar Arguments .. */
00054 /*     .. */
00055 /*     .. Array Arguments .. */
00056 /*     .. */
00057 
00058 /*  Purpose */
00059 /*  ======= */
00060 
00061 /*  ZPTEQR computes all eigenvalues and, optionally, eigenvectors of a */
00062 /*  symmetric positive definite tridiagonal matrix by first factoring the */
00063 /*  matrix using DPTTRF and then calling ZBDSQR to compute the singular */
00064 /*  values of the bidiagonal factor. */
00065 
00066 /*  This routine computes the eigenvalues of the positive definite */
00067 /*  tridiagonal matrix to high relative accuracy.  This means that if the */
00068 /*  eigenvalues range over many orders of magnitude in size, then the */
00069 /*  small eigenvalues and corresponding eigenvectors will be computed */
00070 /*  more accurately than, for example, with the standard QR method. */
00071 
00072 /*  The eigenvectors of a full or band positive definite Hermitian matrix */
00073 /*  can also be found if ZHETRD, ZHPTRD, or ZHBTRD has been used to */
00074 /*  reduce this matrix to tridiagonal form.  (The reduction to */
00075 /*  tridiagonal form, however, may preclude the possibility of obtaining */
00076 /*  high relative accuracy in the small eigenvalues of the original */
00077 /*  matrix, if these eigenvalues range over many orders of magnitude.) */
00078 
00079 /*  Arguments */
00080 /*  ========= */
00081 
00082 /*  COMPZ   (input) CHARACTER*1 */
00083 /*          = 'N':  Compute eigenvalues only. */
00084 /*          = 'V':  Compute eigenvectors of original Hermitian */
00085 /*                  matrix also.  Array Z contains the unitary matrix */
00086 /*                  used to reduce the original matrix to tridiagonal */
00087 /*                  form. */
00088 /*          = 'I':  Compute eigenvectors of tridiagonal matrix also. */
00089 
00090 /*  N       (input) INTEGER */
00091 /*          The order of the matrix.  N >= 0. */
00092 
00093 /*  D       (input/output) DOUBLE PRECISION array, dimension (N) */
00094 /*          On entry, the n diagonal elements of the tridiagonal matrix. */
00095 /*          On normal exit, D contains the eigenvalues, in descending */
00096 /*          order. */
00097 
00098 /*  E       (input/output) DOUBLE PRECISION array, dimension (N-1) */
00099 /*          On entry, the (n-1) subdiagonal elements of the tridiagonal */
00100 /*          matrix. */
00101 /*          On exit, E has been destroyed. */
00102 
00103 /*  Z       (input/output) COMPLEX*16 array, dimension (LDZ, N) */
00104 /*          On entry, if COMPZ = 'V', the unitary matrix used in the */
00105 /*          reduction to tridiagonal form. */
00106 /*          On exit, if COMPZ = 'V', the orthonormal eigenvectors of the */
00107 /*          original Hermitian matrix; */
00108 /*          if COMPZ = 'I', the orthonormal eigenvectors of the */
00109 /*          tridiagonal matrix. */
00110 /*          If INFO > 0 on exit, Z contains the eigenvectors associated */
00111 /*          with only the stored eigenvalues. */
00112 /*          If  COMPZ = 'N', then Z is not referenced. */
00113 
00114 /*  LDZ     (input) INTEGER */
00115 /*          The leading dimension of the array Z.  LDZ >= 1, and if */
00116 /*          COMPZ = 'V' or 'I', LDZ >= max(1,N). */
00117 
00118 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (4*N) */
00119 
00120 /*  INFO    (output) INTEGER */
00121 /*          = 0:  successful exit. */
00122 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00123 /*          > 0:  if INFO = i, and i is: */
00124 /*                <= N  the Cholesky factorization of the matrix could */
00125 /*                      not be performed because the i-th principal minor */
00126 /*                      was not positive definite. */
00127 /*                > N   the SVD algorithm failed to converge; */
00128 /*                      if INFO = N+i, i off-diagonal elements of the */
00129 /*                      bidiagonal factor did not converge to zero. */
00130 
00131 /*  ==================================================================== */
00132 
00133 /*     .. Parameters .. */
00134 /*     .. */
00135 /*     .. External Functions .. */
00136 /*     .. */
00137 /*     .. External Subroutines .. */
00138 /*     .. */
00139 /*     .. Local Arrays .. */
00140 /*     .. */
00141 /*     .. Local Scalars .. */
00142 /*     .. */
00143 /*     .. Intrinsic Functions .. */
00144 /*     .. */
00145 /*     .. Executable Statements .. */
00146 
00147 /*     Test the input parameters. */
00148 
00149     /* Parameter adjustments */
00150     --d__;
00151     --e;
00152     z_dim1 = *ldz;
00153     z_offset = 1 + z_dim1;
00154     z__ -= z_offset;
00155     --work;
00156 
00157     /* Function Body */
00158     *info = 0;
00159 
00160     if (lsame_(compz, "N")) {
00161         icompz = 0;
00162     } else if (lsame_(compz, "V")) {
00163         icompz = 1;
00164     } else if (lsame_(compz, "I")) {
00165         icompz = 2;
00166     } else {
00167         icompz = -1;
00168     }
00169     if (icompz < 0) {
00170         *info = -1;
00171     } else if (*n < 0) {
00172         *info = -2;
00173     } else if (*ldz < 1 || icompz > 0 && *ldz < max(1,*n)) {
00174         *info = -6;
00175     }
00176     if (*info != 0) {
00177         i__1 = -(*info);
00178         xerbla_("ZPTEQR", &i__1);
00179         return 0;
00180     }
00181 
00182 /*     Quick return if possible */
00183 
00184     if (*n == 0) {
00185         return 0;
00186     }
00187 
00188     if (*n == 1) {
00189         if (icompz > 0) {
00190             i__1 = z_dim1 + 1;
00191             z__[i__1].r = 1., z__[i__1].i = 0.;
00192         }
00193         return 0;
00194     }
00195     if (icompz == 2) {
00196         zlaset_("Full", n, n, &c_b1, &c_b2, &z__[z_offset], ldz);
00197     }
00198 
00199 /*     Call DPTTRF to factor the matrix. */
00200 
00201     dpttrf_(n, &d__[1], &e[1], info);
00202     if (*info != 0) {
00203         return 0;
00204     }
00205     i__1 = *n;
00206     for (i__ = 1; i__ <= i__1; ++i__) {
00207         d__[i__] = sqrt(d__[i__]);
00208 /* L10: */
00209     }
00210     i__1 = *n - 1;
00211     for (i__ = 1; i__ <= i__1; ++i__) {
00212         e[i__] *= d__[i__];
00213 /* L20: */
00214     }
00215 
00216 /*     Call ZBDSQR to compute the singular values/vectors of the */
00217 /*     bidiagonal factor. */
00218 
00219     if (icompz > 0) {
00220         nru = *n;
00221     } else {
00222         nru = 0;
00223     }
00224     zbdsqr_("Lower", n, &c__0, &nru, &c__0, &d__[1], &e[1], vt, &c__1, &z__[
00225             z_offset], ldz, c__, &c__1, &work[1], info);
00226 
00227 /*     Square the singular values. */
00228 
00229     if (*info == 0) {
00230         i__1 = *n;
00231         for (i__ = 1; i__ <= i__1; ++i__) {
00232             d__[i__] *= d__[i__];
00233 /* L30: */
00234         }
00235     } else {
00236         *info = *n + *info;
00237     }
00238 
00239     return 0;
00240 
00241 /*     End of ZPTEQR */
00242 
00243 } /* zpteqr_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:43