zspt03.c
Go to the documentation of this file.
00001 /* zspt03.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 zspt03_(char *uplo, integer *n, doublecomplex *a, 
00021         doublecomplex *ainv, doublecomplex *work, integer *ldw, doublereal *
00022         rwork, doublereal *rcond, doublereal *resid)
00023 {
00024     /* System generated locals */
00025     integer work_dim1, work_offset, i__1, i__2, i__3, i__4, i__5;
00026     doublecomplex z__1, z__2;
00027 
00028     /* Local variables */
00029     integer i__, j, k;
00030     doublecomplex t;
00031     doublereal eps;
00032     integer icol, jcol, kcol, nall;
00033     extern logical lsame_(char *, char *);
00034     doublereal anorm;
00035     extern /* Double Complex */ VOID zdotu_(doublecomplex *, integer *, 
00036             doublecomplex *, integer *, doublecomplex *, integer *);
00037     extern doublereal dlamch_(char *), zlange_(char *, integer *, 
00038             integer *, doublecomplex *, integer *, doublereal *);
00039     doublereal ainvnm;
00040     extern doublereal zlansp_(char *, char *, integer *, doublecomplex *, 
00041             doublereal *);
00042 
00043 
00044 /*  -- LAPACK test routine (version 3.1) -- */
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 /*  ZSPT03 computes the residual for a complex symmetric packed matrix */
00057 /*  times its inverse: */
00058 /*     norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ), */
00059 /*  where EPS is the machine epsilon. */
00060 
00061 /*  Arguments */
00062 /*  ========== */
00063 
00064 /*  UPLO    (input) CHARACTER*1 */
00065 /*          Specifies whether the upper or lower triangular part of the */
00066 /*          complex symmetric matrix A is stored: */
00067 /*          = 'U':  Upper triangular */
00068 /*          = 'L':  Lower triangular */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of rows and columns of the matrix A.  N >= 0. */
00072 
00073 /*  A       (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00074 /*          The original complex symmetric matrix A, stored as a packed */
00075 /*          triangular matrix. */
00076 
00077 /*  AINV    (input) COMPLEX*16 array, dimension (N*(N+1)/2) */
00078 /*          The (symmetric) inverse of the matrix A, stored as a packed */
00079 /*          triangular matrix. */
00080 
00081 /*  WORK    (workspace) COMPLEX*16 array, dimension (LDWORK,N) */
00082 
00083 /*  LDWORK  (input) INTEGER */
00084 /*          The leading dimension of the array WORK.  LDWORK >= max(1,N). */
00085 
00086 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (N) */
00087 
00088 /*  RCOND   (output) DOUBLE PRECISION */
00089 /*          The reciprocal of the condition number of A, computed as */
00090 /*          ( 1/norm(A) ) / norm(AINV). */
00091 
00092 /*  RESID   (output) DOUBLE PRECISION */
00093 /*          norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS ) */
00094 
00095 /*  ===================================================================== */
00096 
00097 /*     .. Parameters .. */
00098 /*     .. */
00099 /*     .. Local Scalars .. */
00100 /*     .. */
00101 /*     .. External Functions .. */
00102 /*     .. */
00103 /*     .. Intrinsic Functions .. */
00104 /*     .. */
00105 /*     .. Executable Statements .. */
00106 
00107 /*     Quick exit if N = 0. */
00108 
00109     /* Parameter adjustments */
00110     --a;
00111     --ainv;
00112     work_dim1 = *ldw;
00113     work_offset = 1 + work_dim1;
00114     work -= work_offset;
00115     --rwork;
00116 
00117     /* Function Body */
00118     if (*n <= 0) {
00119         *rcond = 1.;
00120         *resid = 0.;
00121         return 0;
00122     }
00123 
00124 /*     Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */
00125 
00126     eps = dlamch_("Epsilon");
00127     anorm = zlansp_("1", uplo, n, &a[1], &rwork[1]);
00128     ainvnm = zlansp_("1", uplo, n, &ainv[1], &rwork[1]);
00129     if (anorm <= 0. || ainvnm <= 0.) {
00130         *rcond = 0.;
00131         *resid = 1. / eps;
00132         return 0;
00133     }
00134     *rcond = 1. / anorm / ainvnm;
00135 
00136 /*     Case where both A and AINV are upper triangular: */
00137 /*     Each element of - A * AINV is computed by taking the dot product */
00138 /*     of a row of A with a column of AINV. */
00139 
00140     if (lsame_(uplo, "U")) {
00141         i__1 = *n;
00142         for (i__ = 1; i__ <= i__1; ++i__) {
00143             icol = (i__ - 1) * i__ / 2 + 1;
00144 
00145 /*           Code when J <= I */
00146 
00147             i__2 = i__;
00148             for (j = 1; j <= i__2; ++j) {
00149                 jcol = (j - 1) * j / 2 + 1;
00150                 zdotu_(&z__1, &j, &a[icol], &c__1, &ainv[jcol], &c__1);
00151                 t.r = z__1.r, t.i = z__1.i;
00152                 jcol = jcol + (j << 1) - 1;
00153                 kcol = icol - 1;
00154                 i__3 = i__;
00155                 for (k = j + 1; k <= i__3; ++k) {
00156                     i__4 = kcol + k;
00157                     i__5 = jcol;
00158                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00159                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00160                             * ainv[i__5].r;
00161                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00162                     t.r = z__1.r, t.i = z__1.i;
00163                     jcol += k;
00164 /* L10: */
00165                 }
00166                 kcol += i__ << 1;
00167                 i__3 = *n;
00168                 for (k = i__ + 1; k <= i__3; ++k) {
00169                     i__4 = kcol;
00170                     i__5 = jcol;
00171                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00172                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00173                             * ainv[i__5].r;
00174                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00175                     t.r = z__1.r, t.i = z__1.i;
00176                     kcol += k;
00177                     jcol += k;
00178 /* L20: */
00179                 }
00180                 i__3 = i__ + j * work_dim1;
00181                 z__1.r = -t.r, z__1.i = -t.i;
00182                 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00183 /* L30: */
00184             }
00185 
00186 /*           Code when J > I */
00187 
00188             i__2 = *n;
00189             for (j = i__ + 1; j <= i__2; ++j) {
00190                 jcol = (j - 1) * j / 2 + 1;
00191                 zdotu_(&z__1, &i__, &a[icol], &c__1, &ainv[jcol], &c__1);
00192                 t.r = z__1.r, t.i = z__1.i;
00193                 --jcol;
00194                 kcol = icol + (i__ << 1) - 1;
00195                 i__3 = j;
00196                 for (k = i__ + 1; k <= i__3; ++k) {
00197                     i__4 = kcol;
00198                     i__5 = jcol + k;
00199                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00200                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00201                             * ainv[i__5].r;
00202                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00203                     t.r = z__1.r, t.i = z__1.i;
00204                     kcol += k;
00205 /* L40: */
00206                 }
00207                 jcol += j << 1;
00208                 i__3 = *n;
00209                 for (k = j + 1; k <= i__3; ++k) {
00210                     i__4 = kcol;
00211                     i__5 = jcol;
00212                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00213                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00214                             * ainv[i__5].r;
00215                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00216                     t.r = z__1.r, t.i = z__1.i;
00217                     kcol += k;
00218                     jcol += k;
00219 /* L50: */
00220                 }
00221                 i__3 = i__ + j * work_dim1;
00222                 z__1.r = -t.r, z__1.i = -t.i;
00223                 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00224 /* L60: */
00225             }
00226 /* L70: */
00227         }
00228     } else {
00229 
00230 /*        Case where both A and AINV are lower triangular */
00231 
00232         nall = *n * (*n + 1) / 2;
00233         i__1 = *n;
00234         for (i__ = 1; i__ <= i__1; ++i__) {
00235 
00236 /*           Code when J <= I */
00237 
00238             icol = nall - (*n - i__ + 1) * (*n - i__ + 2) / 2 + 1;
00239             i__2 = i__;
00240             for (j = 1; j <= i__2; ++j) {
00241                 jcol = nall - (*n - j) * (*n - j + 1) / 2 - (*n - i__);
00242                 i__3 = *n - i__ + 1;
00243                 zdotu_(&z__1, &i__3, &a[icol], &c__1, &ainv[jcol], &c__1);
00244                 t.r = z__1.r, t.i = z__1.i;
00245                 kcol = i__;
00246                 jcol = j;
00247                 i__3 = j - 1;
00248                 for (k = 1; k <= i__3; ++k) {
00249                     i__4 = kcol;
00250                     i__5 = jcol;
00251                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00252                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00253                             * ainv[i__5].r;
00254                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00255                     t.r = z__1.r, t.i = z__1.i;
00256                     jcol = jcol + *n - k;
00257                     kcol = kcol + *n - k;
00258 /* L80: */
00259                 }
00260                 jcol -= j;
00261                 i__3 = i__ - 1;
00262                 for (k = j; k <= i__3; ++k) {
00263                     i__4 = kcol;
00264                     i__5 = jcol + k;
00265                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00266                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00267                             * ainv[i__5].r;
00268                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00269                     t.r = z__1.r, t.i = z__1.i;
00270                     kcol = kcol + *n - k;
00271 /* L90: */
00272                 }
00273                 i__3 = i__ + j * work_dim1;
00274                 z__1.r = -t.r, z__1.i = -t.i;
00275                 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00276 /* L100: */
00277             }
00278 
00279 /*           Code when J > I */
00280 
00281             icol = nall - (*n - i__) * (*n - i__ + 1) / 2;
00282             i__2 = *n;
00283             for (j = i__ + 1; j <= i__2; ++j) {
00284                 jcol = nall - (*n - j + 1) * (*n - j + 2) / 2 + 1;
00285                 i__3 = *n - j + 1;
00286                 zdotu_(&z__1, &i__3, &a[icol - *n + j], &c__1, &ainv[jcol], &
00287                         c__1);
00288                 t.r = z__1.r, t.i = z__1.i;
00289                 kcol = i__;
00290                 jcol = j;
00291                 i__3 = i__ - 1;
00292                 for (k = 1; k <= i__3; ++k) {
00293                     i__4 = kcol;
00294                     i__5 = jcol;
00295                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00296                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00297                             * ainv[i__5].r;
00298                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00299                     t.r = z__1.r, t.i = z__1.i;
00300                     jcol = jcol + *n - k;
00301                     kcol = kcol + *n - k;
00302 /* L110: */
00303                 }
00304                 kcol -= i__;
00305                 i__3 = j - 1;
00306                 for (k = i__; k <= i__3; ++k) {
00307                     i__4 = kcol + k;
00308                     i__5 = jcol;
00309                     z__2.r = a[i__4].r * ainv[i__5].r - a[i__4].i * ainv[i__5]
00310                             .i, z__2.i = a[i__4].r * ainv[i__5].i + a[i__4].i 
00311                             * ainv[i__5].r;
00312                     z__1.r = t.r + z__2.r, z__1.i = t.i + z__2.i;
00313                     t.r = z__1.r, t.i = z__1.i;
00314                     jcol = jcol + *n - k;
00315 /* L120: */
00316                 }
00317                 i__3 = i__ + j * work_dim1;
00318                 z__1.r = -t.r, z__1.i = -t.i;
00319                 work[i__3].r = z__1.r, work[i__3].i = z__1.i;
00320 /* L130: */
00321             }
00322 /* L140: */
00323         }
00324     }
00325 
00326 /*     Add the identity matrix to WORK . */
00327 
00328     i__1 = *n;
00329     for (i__ = 1; i__ <= i__1; ++i__) {
00330         i__2 = i__ + i__ * work_dim1;
00331         i__3 = i__ + i__ * work_dim1;
00332         z__1.r = work[i__3].r + 1., z__1.i = work[i__3].i;
00333         work[i__2].r = z__1.r, work[i__2].i = z__1.i;
00334 /* L150: */
00335     }
00336 
00337 /*     Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) */
00338 
00339     *resid = zlange_("1", n, n, &work[work_offset], ldw, &rwork[1])
00340             ;
00341 
00342     *resid = *resid * *rcond / eps / (doublereal) (*n);
00343 
00344     return 0;
00345 
00346 /*     End of ZSPT03 */
00347 
00348 } /* zspt03_ */


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