00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__1 = 1;
00019 static real c_b13 = -1.f;
00020 static real c_b15 = 0.f;
00021
00022 int sppt03_(char *uplo, integer *n, real *a, real *ainv,
00023 real *work, integer *ldwork, real *rwork, real *rcond, real *resid)
00024 {
00025
00026 integer work_dim1, work_offset, i__1, i__2;
00027
00028
00029 integer i__, j, jj;
00030 real eps;
00031 extern logical lsame_(char *, char *);
00032 real anorm;
00033 extern 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
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 --a;
00111 --ainv;
00112 work_dim1 = *ldwork;
00113 work_offset = 1 + work_dim1;
00114 work -= work_offset;
00115 --rwork;
00116
00117
00118 if (*n <= 0) {
00119 *rcond = 1.f;
00120 *resid = 0.f;
00121 return 0;
00122 }
00123
00124
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
00137
00138
00139
00140
00141 if (lsame_(uplo, "U")) {
00142
00143
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
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
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
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
00173
00174
00175
00176 } else {
00177
00178
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
00193 }
00194
00195
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
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
00209
00210 i__1 = *n;
00211 for (i__ = 1; i__ <= i__1; ++i__) {
00212 work[i__ + i__ * work_dim1] += 1.f;
00213
00214 }
00215
00216
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
00225
00226 }