dppt03.c
Go to the documentation of this file.
00001 /* dppt03.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 doublereal c_b13 = -1.;
00020 static doublereal c_b15 = 0.;
00021 
00022 /* Subroutine */ int dppt03_(char *uplo, integer *n, doublereal *a, 
00023         doublereal *ainv, doublereal *work, integer *ldwork, doublereal *
00024         rwork, doublereal *rcond, doublereal *resid)
00025 {
00026     /* System generated locals */
00027     integer work_dim1, work_offset, i__1, i__2;
00028 
00029     /* Local variables */
00030     integer i__, j, jj;
00031     doublereal eps;
00032     extern logical lsame_(char *, char *);
00033     doublereal anorm;
00034     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00035             doublereal *, integer *), dspmv_(char *, integer *, doublereal *, 
00036             doublereal *, doublereal *, integer *, doublereal *, doublereal *, 
00037              integer *);
00038     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00039             integer *, doublereal *, integer *, doublereal *), 
00040             dlansp_(char *, char *, integer *, doublereal *, doublereal *);
00041     doublereal ainvnm;
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 /*  DPPT03 computes the residual for a symmetric packed matrix times its */
00057 /*  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 /*          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) DOUBLE PRECISION array, dimension (N*(N+1)/2) */
00074 /*          The original symmetric matrix A, stored as a packed */
00075 /*          triangular matrix. */
00076 
00077 /*  AINV    (input) DOUBLE PRECISION 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) DOUBLE PRECISION 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 /*     .. External Subroutines .. */
00106 /*     .. */
00107 /*     .. Executable Statements .. */
00108 
00109 /*     Quick exit if N = 0. */
00110 
00111     /* Parameter adjustments */
00112     --a;
00113     --ainv;
00114     work_dim1 = *ldwork;
00115     work_offset = 1 + work_dim1;
00116     work -= work_offset;
00117     --rwork;
00118 
00119     /* Function Body */
00120     if (*n <= 0) {
00121         *rcond = 1.;
00122         *resid = 0.;
00123         return 0;
00124     }
00125 
00126 /*     Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */
00127 
00128     eps = dlamch_("Epsilon");
00129     anorm = dlansp_("1", uplo, n, &a[1], &rwork[1]);
00130     ainvnm = dlansp_("1", uplo, n, &ainv[1], &rwork[1]);
00131     if (anorm <= 0. || ainvnm == 0.) {
00132         *rcond = 0.;
00133         *resid = 1. / eps;
00134         return 0;
00135     }
00136     *rcond = 1. / anorm / ainvnm;
00137 
00138 /*     UPLO = 'U': */
00139 /*     Copy the leading N-1 x N-1 submatrix of AINV to WORK(1:N,2:N) and */
00140 /*     expand it to a full matrix, then multiply by A one column at a */
00141 /*     time, moving the result one column to the left. */
00142 
00143     if (lsame_(uplo, "U")) {
00144 
00145 /*        Copy AINV */
00146 
00147         jj = 1;
00148         i__1 = *n - 1;
00149         for (j = 1; j <= i__1; ++j) {
00150             dcopy_(&j, &ainv[jj], &c__1, &work[(j + 1) * work_dim1 + 1], &
00151                     c__1);
00152             i__2 = j - 1;
00153             dcopy_(&i__2, &ainv[jj], &c__1, &work[j + (work_dim1 << 1)], 
00154                     ldwork);
00155             jj += j;
00156 /* L10: */
00157         }
00158         jj = (*n - 1) * *n / 2 + 1;
00159         i__1 = *n - 1;
00160         dcopy_(&i__1, &ainv[jj], &c__1, &work[*n + (work_dim1 << 1)], ldwork);
00161 
00162 /*        Multiply by A */
00163 
00164         i__1 = *n - 1;
00165         for (j = 1; j <= i__1; ++j) {
00166             dspmv_("Upper", n, &c_b13, &a[1], &work[(j + 1) * work_dim1 + 1], 
00167                     &c__1, &c_b15, &work[j * work_dim1 + 1], &c__1)
00168                     ;
00169 /* L20: */
00170         }
00171         dspmv_("Upper", n, &c_b13, &a[1], &ainv[jj], &c__1, &c_b15, &work[*n *
00172                  work_dim1 + 1], &c__1);
00173 
00174 /*     UPLO = 'L': */
00175 /*     Copy the trailing N-1 x N-1 submatrix of AINV to WORK(1:N,1:N-1) */
00176 /*     and multiply by A, moving each column to the right. */
00177 
00178     } else {
00179 
00180 /*        Copy AINV */
00181 
00182         i__1 = *n - 1;
00183         dcopy_(&i__1, &ainv[2], &c__1, &work[work_dim1 + 1], ldwork);
00184         jj = *n + 1;
00185         i__1 = *n;
00186         for (j = 2; j <= i__1; ++j) {
00187             i__2 = *n - j + 1;
00188             dcopy_(&i__2, &ainv[jj], &c__1, &work[j + (j - 1) * work_dim1], &
00189                     c__1);
00190             i__2 = *n - j;
00191             dcopy_(&i__2, &ainv[jj + 1], &c__1, &work[j + j * work_dim1], 
00192                     ldwork);
00193             jj = jj + *n - j + 1;
00194 /* L30: */
00195         }
00196 
00197 /*        Multiply by A */
00198 
00199         for (j = *n; j >= 2; --j) {
00200             dspmv_("Lower", n, &c_b13, &a[1], &work[(j - 1) * work_dim1 + 1], 
00201                     &c__1, &c_b15, &work[j * work_dim1 + 1], &c__1)
00202                     ;
00203 /* L40: */
00204         }
00205         dspmv_("Lower", n, &c_b13, &a[1], &ainv[1], &c__1, &c_b15, &work[
00206                 work_dim1 + 1], &c__1);
00207 
00208     }
00209 
00210 /*     Add the identity matrix to WORK . */
00211 
00212     i__1 = *n;
00213     for (i__ = 1; i__ <= i__1; ++i__) {
00214         work[i__ + i__ * work_dim1] += 1.;
00215 /* L50: */
00216     }
00217 
00218 /*     Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) */
00219 
00220     *resid = dlange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00221 
00222     *resid = *resid * *rcond / eps / (doublereal) (*n);
00223 
00224     return 0;
00225 
00226 /*     End of DPPT03 */
00227 
00228 } /* dppt03_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:48