00001 /* spot03.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 real c_b11 = -1.f; 00019 static real c_b12 = 0.f; 00020 00021 /* Subroutine */ int spot03_(char *uplo, integer *n, real *a, integer *lda, 00022 real *ainv, integer *ldainv, real *work, integer *ldwork, real *rwork, 00023 real *rcond, real *resid) 00024 { 00025 /* System generated locals */ 00026 integer a_dim1, a_offset, ainv_dim1, ainv_offset, work_dim1, work_offset, 00027 i__1, i__2; 00028 00029 /* Local variables */ 00030 integer i__, j; 00031 real eps; 00032 extern logical lsame_(char *, char *); 00033 real anorm; 00034 extern /* Subroutine */ int ssymm_(char *, char *, integer *, integer *, 00035 real *, real *, integer *, real *, integer *, real *, real *, 00036 integer *); 00037 extern doublereal slamch_(char *), slange_(char *, integer *, 00038 integer *, real *, integer *, real *); 00039 real ainvnm; 00040 extern doublereal slansy_(char *, char *, integer *, real *, integer *, 00041 real *); 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 /* SPOT03 computes the residual for a symmetric 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) REAL array, dimension (LDA,N) */ 00074 /* The original symmetric matrix A. */ 00075 00076 /* LDA (input) INTEGER */ 00077 /* The leading dimension of the array A. LDA >= max(1,N) */ 00078 00079 /* AINV (input/output) REAL array, dimension (LDAINV,N) */ 00080 /* On entry, the inverse of the matrix A, stored as a symmetric */ 00081 /* matrix in the same format as A. */ 00082 /* In this version, AINV is expanded into a full matrix and */ 00083 /* multiplied by A, so the opposing triangle of AINV will be */ 00084 /* changed; i.e., if the upper triangular part of AINV is */ 00085 /* stored, the lower triangular part will be used as work space. */ 00086 00087 /* LDAINV (input) INTEGER */ 00088 /* The leading dimension of the array AINV. LDAINV >= max(1,N). */ 00089 00090 /* WORK (workspace) REAL array, dimension (LDWORK,N) */ 00091 00092 /* LDWORK (input) INTEGER */ 00093 /* The leading dimension of the array WORK. LDWORK >= max(1,N). */ 00094 00095 /* RWORK (workspace) REAL array, dimension (N) */ 00096 00097 /* RCOND (output) REAL */ 00098 /* The reciprocal of the condition number of A, computed as */ 00099 /* ( 1/norm(A) ) / norm(AINV). */ 00100 00101 /* RESID (output) REAL */ 00102 /* norm(I - A*AINV) / ( N * norm(A) * norm(AINV) * EPS ) */ 00103 00104 /* ===================================================================== */ 00105 00106 /* .. Parameters .. */ 00107 /* .. */ 00108 /* .. Local Scalars .. */ 00109 /* .. */ 00110 /* .. External Functions .. */ 00111 /* .. */ 00112 /* .. External Subroutines .. */ 00113 /* .. */ 00114 /* .. Intrinsic Functions .. */ 00115 /* .. */ 00116 /* .. Executable Statements .. */ 00117 00118 /* Quick exit if N = 0. */ 00119 00120 /* Parameter adjustments */ 00121 a_dim1 = *lda; 00122 a_offset = 1 + a_dim1; 00123 a -= a_offset; 00124 ainv_dim1 = *ldainv; 00125 ainv_offset = 1 + ainv_dim1; 00126 ainv -= ainv_offset; 00127 work_dim1 = *ldwork; 00128 work_offset = 1 + work_dim1; 00129 work -= work_offset; 00130 --rwork; 00131 00132 /* Function Body */ 00133 if (*n <= 0) { 00134 *rcond = 1.f; 00135 *resid = 0.f; 00136 return 0; 00137 } 00138 00139 /* Exit with RESID = 1/EPS if ANORM = 0 or AINVNM = 0. */ 00140 00141 eps = slamch_("Epsilon"); 00142 anorm = slansy_("1", uplo, n, &a[a_offset], lda, &rwork[1]); 00143 ainvnm = slansy_("1", uplo, n, &ainv[ainv_offset], ldainv, &rwork[1]); 00144 if (anorm <= 0.f || ainvnm <= 0.f) { 00145 *rcond = 0.f; 00146 *resid = 1.f / eps; 00147 return 0; 00148 } 00149 *rcond = 1.f / anorm / ainvnm; 00150 00151 /* Expand AINV into a full matrix and call SSYMM to multiply */ 00152 /* AINV on the left by A. */ 00153 00154 if (lsame_(uplo, "U")) { 00155 i__1 = *n; 00156 for (j = 1; j <= i__1; ++j) { 00157 i__2 = j - 1; 00158 for (i__ = 1; i__ <= i__2; ++i__) { 00159 ainv[j + i__ * ainv_dim1] = ainv[i__ + j * ainv_dim1]; 00160 /* L10: */ 00161 } 00162 /* L20: */ 00163 } 00164 } else { 00165 i__1 = *n; 00166 for (j = 1; j <= i__1; ++j) { 00167 i__2 = *n; 00168 for (i__ = j + 1; i__ <= i__2; ++i__) { 00169 ainv[j + i__ * ainv_dim1] = ainv[i__ + j * ainv_dim1]; 00170 /* L30: */ 00171 } 00172 /* L40: */ 00173 } 00174 } 00175 ssymm_("Left", uplo, n, n, &c_b11, &a[a_offset], lda, &ainv[ainv_offset], 00176 ldainv, &c_b12, &work[work_offset], ldwork); 00177 00178 /* Add the identity matrix to WORK . */ 00179 00180 i__1 = *n; 00181 for (i__ = 1; i__ <= i__1; ++i__) { 00182 work[i__ + i__ * work_dim1] += 1.f; 00183 /* L50: */ 00184 } 00185 00186 /* Compute norm(I - A*AINV) / (N * norm(A) * norm(AINV) * EPS) */ 00187 00188 *resid = slange_("1", n, n, &work[work_offset], ldwork, &rwork[1]); 00189 00190 *resid = *resid * *rcond / eps / (real) (*n); 00191 00192 return 0; 00193 00194 /* End of SPOT03 */ 00195 00196 } /* spot03_ */