00001 /* sspt01.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_b5 = 0.f; 00019 static real c_b6 = 1.f; 00020 00021 /* Subroutine */ int sspt01_(char *uplo, integer *n, real *a, real *afac, 00022 integer *ipiv, real *c__, integer *ldc, real *rwork, real *resid) 00023 { 00024 /* System generated locals */ 00025 integer c_dim1, c_offset, i__1, i__2; 00026 00027 /* Local variables */ 00028 integer i__, j, jc; 00029 real eps; 00030 integer info; 00031 extern logical lsame_(char *, char *); 00032 real anorm; 00033 extern doublereal slamch_(char *); 00034 extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, 00035 real *, real *, integer *); 00036 extern doublereal slansp_(char *, char *, integer *, real *, real *); 00037 extern /* Subroutine */ int slavsp_(char *, char *, char *, integer *, 00038 integer *, real *, integer *, real *, integer *, integer *); 00039 extern doublereal slansy_(char *, char *, integer *, real *, integer *, 00040 real *); 00041 00042 00043 /* -- LAPACK test routine (version 3.1) -- */ 00044 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00045 /* November 2006 */ 00046 00047 /* .. Scalar Arguments .. */ 00048 /* .. */ 00049 /* .. Array Arguments .. */ 00050 /* .. */ 00051 00052 /* Purpose */ 00053 /* ======= */ 00054 00055 /* SSPT01 reconstructs a symmetric indefinite packed matrix A from its */ 00056 /* block L*D*L' or U*D*U' factorization and computes the residual */ 00057 /* norm( C - A ) / ( N * norm(A) * EPS ), */ 00058 /* where C is the reconstructed matrix and EPS is the machine epsilon. */ 00059 00060 /* Arguments */ 00061 /* ========== */ 00062 00063 /* UPLO (input) CHARACTER*1 */ 00064 /* Specifies whether the upper or lower triangular part of the */ 00065 /* symmetric matrix A is stored: */ 00066 /* = 'U': Upper triangular */ 00067 /* = 'L': Lower triangular */ 00068 00069 /* N (input) INTEGER */ 00070 /* The number of rows and columns of the matrix A. N >= 0. */ 00071 00072 /* A (input) REAL array, dimension (N*(N+1)/2) */ 00073 /* The original symmetric matrix A, stored as a packed */ 00074 /* triangular matrix. */ 00075 00076 /* AFAC (input) REAL array, dimension (N*(N+1)/2) */ 00077 /* The factored form of the matrix A, stored as a packed */ 00078 /* triangular matrix. AFAC contains the block diagonal matrix D */ 00079 /* and the multipliers used to obtain the factor L or U from the */ 00080 /* block L*D*L' or U*D*U' factorization as computed by SSPTRF. */ 00081 00082 /* IPIV (input) INTEGER array, dimension (N) */ 00083 /* The pivot indices from SSPTRF. */ 00084 00085 /* C (workspace) REAL array, dimension (LDC,N) */ 00086 00087 /* LDC (integer) INTEGER */ 00088 /* The leading dimension of the array C. LDC >= max(1,N). */ 00089 00090 /* RWORK (workspace) REAL array, dimension (N) */ 00091 00092 /* RESID (output) REAL */ 00093 /* If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS ) */ 00094 /* If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS ) */ 00095 00096 /* ===================================================================== */ 00097 00098 /* .. Parameters .. */ 00099 /* .. */ 00100 /* .. Local Scalars .. */ 00101 /* .. */ 00102 /* .. External Functions .. */ 00103 /* .. */ 00104 /* .. External Subroutines .. */ 00105 /* .. */ 00106 /* .. Intrinsic Functions .. */ 00107 /* .. */ 00108 /* .. Executable Statements .. */ 00109 00110 /* Quick exit if N = 0. */ 00111 00112 /* Parameter adjustments */ 00113 --a; 00114 --afac; 00115 --ipiv; 00116 c_dim1 = *ldc; 00117 c_offset = 1 + c_dim1; 00118 c__ -= c_offset; 00119 --rwork; 00120 00121 /* Function Body */ 00122 if (*n <= 0) { 00123 *resid = 0.f; 00124 return 0; 00125 } 00126 00127 /* Determine EPS and the norm of A. */ 00128 00129 eps = slamch_("Epsilon"); 00130 anorm = slansp_("1", uplo, n, &a[1], &rwork[1]); 00131 00132 /* Initialize C to the identity matrix. */ 00133 00134 slaset_("Full", n, n, &c_b5, &c_b6, &c__[c_offset], ldc); 00135 00136 /* Call SLAVSP to form the product D * U' (or D * L' ). */ 00137 00138 slavsp_(uplo, "Transpose", "Non-unit", n, n, &afac[1], &ipiv[1], &c__[ 00139 c_offset], ldc, &info); 00140 00141 /* Call SLAVSP again to multiply by U ( or L ). */ 00142 00143 slavsp_(uplo, "No transpose", "Unit", n, n, &afac[1], &ipiv[1], &c__[ 00144 c_offset], ldc, &info); 00145 00146 /* Compute the difference C - A . */ 00147 00148 if (lsame_(uplo, "U")) { 00149 jc = 0; 00150 i__1 = *n; 00151 for (j = 1; j <= i__1; ++j) { 00152 i__2 = j; 00153 for (i__ = 1; i__ <= i__2; ++i__) { 00154 c__[i__ + j * c_dim1] -= a[jc + i__]; 00155 /* L10: */ 00156 } 00157 jc += j; 00158 /* L20: */ 00159 } 00160 } else { 00161 jc = 1; 00162 i__1 = *n; 00163 for (j = 1; j <= i__1; ++j) { 00164 i__2 = *n; 00165 for (i__ = j; i__ <= i__2; ++i__) { 00166 c__[i__ + j * c_dim1] -= a[jc + i__ - j]; 00167 /* L30: */ 00168 } 00169 jc = jc + *n - j + 1; 00170 /* L40: */ 00171 } 00172 } 00173 00174 /* Compute norm( C - A ) / ( N * norm(A) * EPS ) */ 00175 00176 *resid = slansy_("1", uplo, n, &c__[c_offset], ldc, &rwork[1]); 00177 00178 if (anorm <= 0.f) { 00179 if (*resid != 0.f) { 00180 *resid = 1.f / eps; 00181 } 00182 } else { 00183 *resid = *resid / (real) (*n) / anorm / eps; 00184 } 00185 00186 return 0; 00187 00188 /* End of SSPT01 */ 00189 00190 } /* sspt01_ */