sppt03.c
Go to the documentation of this file.
00001 /* sppt03.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_b13 = -1.f;
00020 static real c_b15 = 0.f;
00021 
00022 /* Subroutine */ int sppt03_(char *uplo, integer *n, real *a, real *ainv, 
00023         real *work, integer *ldwork, real *rwork, real *rcond, real *resid)
00024 {
00025     /* System generated locals */
00026     integer work_dim1, work_offset, i__1, i__2;
00027 
00028     /* Local variables */
00029     integer i__, j, jj;
00030     real eps;
00031     extern logical lsame_(char *, char *);
00032     real anorm;
00033     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00034             integer *), sspmv_(char *, integer *, real *, real *, real *, 
00035             integer *, real *, real *, integer *);
00036     extern doublereal slamch_(char *), slange_(char *, integer *, 
00037             integer *, real *, integer *, real *);
00038     real ainvnm;
00039     extern doublereal slansp_(char *, char *, integer *, real *, real *);
00040 
00041 
00042 /*  -- LAPACK test routine (version 3.1) -- */
00043 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00044 /*     November 2006 */
00045 
00046 /*     .. Scalar Arguments .. */
00047 /*     .. */
00048 /*     .. Array Arguments .. */
00049 /*     .. */
00050 
00051 /*  Purpose */
00052 /*  ======= */
00053 
00054 /*  SPPT03 computes the residual for a symmetric packed matrix times its */
00055 /*  inverse: */
00056 /*     norm( I - A*AINV ) / ( N * norm(A) * norm(AINV) * EPS ), */
00057 /*  where EPS is the machine epsilon. */
00058 
00059 /*  Arguments */
00060 /*  ========== */
00061 
00062 /*  UPLO    (input) CHARACTER*1 */
00063 /*          Specifies whether the upper or lower triangular part of the */
00064 /*          symmetric matrix A is stored: */
00065 /*          = 'U':  Upper triangular */
00066 /*          = 'L':  Lower triangular */
00067 
00068 /*  N       (input) INTEGER */
00069 /*          The number of rows and columns of the matrix A.  N >= 0. */
00070 
00071 /*  A       (input) REAL array, dimension (N*(N+1)/2) */
00072 /*          The original symmetric matrix A, stored as a packed */
00073 /*          triangular matrix. */
00074 
00075 /*  AINV    (input) REAL array, dimension (N*(N+1)/2) */
00076 /*          The (symmetric) inverse of the matrix A, stored as a packed */
00077 /*          triangular matrix. */
00078 
00079 /*  WORK    (workspace) REAL array, dimension (LDWORK,N) */
00080 
00081 /*  LDWORK  (input) INTEGER */
00082 /*          The leading dimension of the array WORK.  LDWORK >= max(1,N). */
00083 
00084 /*  RWORK   (workspace) REAL array, dimension (N) */
00085 
00086 /*  RCOND   (output) REAL */
00087 /*          The reciprocal of the condition number of A, computed as */
00088 /*          ( 1/norm(A) ) / norm(AINV). */
00089 
00090 /*  RESID   (output) REAL */
00091 /*          norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS ) */
00092 
00093 /*  ===================================================================== */
00094 
00095 /*     .. Parameters .. */
00096 /*     .. */
00097 /*     .. Local Scalars .. */
00098 /*     .. */
00099 /*     .. External Functions .. */
00100 /*     .. */
00101 /*     .. Intrinsic Functions .. */
00102 /*     .. */
00103 /*     .. External Subroutines .. */
00104 /*     .. */
00105 /*     .. Executable Statements .. */
00106 
00107 /*     Quick exit if N = 0. */
00108 
00109     /* Parameter adjustments */
00110     --a;
00111     --ainv;
00112     work_dim1 = *ldwork;
00113     work_offset = 1 + work_dim1;
00114     work -= work_offset;
00115     --rwork;
00116 
00117     /* Function Body */
00118     if (*n <= 0) {
00119         *rcond = 1.f;
00120         *resid = 0.f;
00121         return 0;
00122     }
00123 
00124 /*     Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */
00125 
00126     eps = slamch_("Epsilon");
00127     anorm = slansp_("1", uplo, n, &a[1], &rwork[1]);
00128     ainvnm = slansp_("1", uplo, n, &ainv[1], &rwork[1]);
00129     if (anorm <= 0.f || ainvnm == 0.f) {
00130         *rcond = 0.f;
00131         *resid = 1.f / eps;
00132         return 0;
00133     }
00134     *rcond = 1.f / anorm / ainvnm;
00135 
00136 /*     UPLO = 'U': */
00137 /*     Copy the leading N-1 x N-1 submatrix of AINV to WORK(1:N,2:N) and */
00138 /*     expand it to a full matrix, then multiply by A one column at a */
00139 /*     time, moving the result one column to the left. */
00140 
00141     if (lsame_(uplo, "U")) {
00142 
00143 /*        Copy AINV */
00144 
00145         jj = 1;
00146         i__1 = *n - 1;
00147         for (j = 1; j <= i__1; ++j) {
00148             scopy_(&j, &ainv[jj], &c__1, &work[(j + 1) * work_dim1 + 1], &
00149                     c__1);
00150             i__2 = j - 1;
00151             scopy_(&i__2, &ainv[jj], &c__1, &work[j + (work_dim1 << 1)], 
00152                     ldwork);
00153             jj += j;
00154 /* L10: */
00155         }
00156         jj = (*n - 1) * *n / 2 + 1;
00157         i__1 = *n - 1;
00158         scopy_(&i__1, &ainv[jj], &c__1, &work[*n + (work_dim1 << 1)], ldwork);
00159 
00160 /*        Multiply by A */
00161 
00162         i__1 = *n - 1;
00163         for (j = 1; j <= i__1; ++j) {
00164             sspmv_("Upper", n, &c_b13, &a[1], &work[(j + 1) * work_dim1 + 1], 
00165                     &c__1, &c_b15, &work[j * work_dim1 + 1], &c__1)
00166                     ;
00167 /* L20: */
00168         }
00169         sspmv_("Upper", n, &c_b13, &a[1], &ainv[jj], &c__1, &c_b15, &work[*n *
00170                  work_dim1 + 1], &c__1);
00171 
00172 /*     UPLO = 'L': */
00173 /*     Copy the trailing N-1 x N-1 submatrix of AINV to WORK(1:N,1:N-1) */
00174 /*     and multiply by A, moving each column to the right. */
00175 
00176     } else {
00177 
00178 /*        Copy AINV */
00179 
00180         i__1 = *n - 1;
00181         scopy_(&i__1, &ainv[2], &c__1, &work[work_dim1 + 1], ldwork);
00182         jj = *n + 1;
00183         i__1 = *n;
00184         for (j = 2; j <= i__1; ++j) {
00185             i__2 = *n - j + 1;
00186             scopy_(&i__2, &ainv[jj], &c__1, &work[j + (j - 1) * work_dim1], &
00187                     c__1);
00188             i__2 = *n - j;
00189             scopy_(&i__2, &ainv[jj + 1], &c__1, &work[j + j * work_dim1], 
00190                     ldwork);
00191             jj = jj + *n - j + 1;
00192 /* L30: */
00193         }
00194 
00195 /*        Multiply by A */
00196 
00197         for (j = *n; j >= 2; --j) {
00198             sspmv_("Lower", n, &c_b13, &a[1], &work[(j - 1) * work_dim1 + 1], 
00199                     &c__1, &c_b15, &work[j * work_dim1 + 1], &c__1)
00200                     ;
00201 /* L40: */
00202         }
00203         sspmv_("Lower", n, &c_b13, &a[1], &ainv[1], &c__1, &c_b15, &work[
00204                 work_dim1 + 1], &c__1);
00205 
00206     }
00207 
00208 /*     Add the identity matrix to WORK . */
00209 
00210     i__1 = *n;
00211     for (i__ = 1; i__ <= i__1; ++i__) {
00212         work[i__ + i__ * work_dim1] += 1.f;
00213 /* L50: */
00214     }
00215 
00216 /*     Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) */
00217 
00218     *resid = slange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00219 
00220     *resid = *resid * *rcond / eps / (real) (*n);
00221 
00222     return 0;
00223 
00224 /*     End of SPPT03 */
00225 
00226 } /* sppt03_ */


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