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