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 doublereal c_b13 = -1.;
00020 static doublereal c_b15 = 0.;
00021
00022 int dppt03_(char *uplo, integer *n, doublereal *a,
00023 doublereal *ainv, doublereal *work, integer *ldwork, doublereal *
00024 rwork, doublereal *rcond, doublereal *resid)
00025 {
00026
00027 integer work_dim1, work_offset, i__1, i__2;
00028
00029
00030 integer i__, j, jj;
00031 doublereal eps;
00032 extern logical lsame_(char *, char *);
00033 doublereal anorm;
00034 extern 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
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
00111
00112 --a;
00113 --ainv;
00114 work_dim1 = *ldwork;
00115 work_offset = 1 + work_dim1;
00116 work -= work_offset;
00117 --rwork;
00118
00119
00120 if (*n <= 0) {
00121 *rcond = 1.;
00122 *resid = 0.;
00123 return 0;
00124 }
00125
00126
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
00139
00140
00141
00142
00143 if (lsame_(uplo, "U")) {
00144
00145
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
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
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
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
00175
00176
00177
00178 } else {
00179
00180
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
00195 }
00196
00197
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
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
00211
00212 i__1 = *n;
00213 for (i__ = 1; i__ <= i__1; ++i__) {
00214 work[i__ + i__ * work_dim1] += 1.;
00215
00216 }
00217
00218
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
00227
00228 }