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 doublereal c_b7 = -1.;
00019 static doublereal c_b8 = 0.;
00020
00021 int dget03_(integer *n, doublereal *a, integer *lda,
00022 doublereal *ainv, integer *ldainv, doublereal *work, integer *ldwork,
00023 doublereal *rwork, doublereal *rcond, doublereal *resid)
00024 {
00025
00026 integer a_dim1, a_offset, ainv_dim1, ainv_offset, work_dim1, work_offset,
00027 i__1;
00028
00029
00030 integer i__;
00031 doublereal eps;
00032 extern int dgemm_(char *, char *, integer *, integer *,
00033 integer *, doublereal *, doublereal *, integer *, doublereal *,
00034 integer *, doublereal *, doublereal *, integer *);
00035 doublereal anorm;
00036 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00037 integer *, doublereal *, integer *, doublereal *);
00038 doublereal ainvnm;
00039
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 a_dim1 = *lda;
00107 a_offset = 1 + a_dim1;
00108 a -= a_offset;
00109 ainv_dim1 = *ldainv;
00110 ainv_offset = 1 + ainv_dim1;
00111 ainv -= ainv_offset;
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.;
00120 *resid = 0.;
00121 return 0;
00122 }
00123
00124
00125
00126 eps = dlamch_("Epsilon");
00127 anorm = dlange_("1", n, n, &a[a_offset], lda, &rwork[1]);
00128 ainvnm = dlange_("1", n, n, &ainv[ainv_offset], ldainv, &rwork[1]);
00129 if (anorm <= 0. || ainvnm <= 0.) {
00130 *rcond = 0.;
00131 *resid = 1. / eps;
00132 return 0;
00133 }
00134 *rcond = 1. / anorm / ainvnm;
00135
00136
00137
00138 dgemm_("No transpose", "No transpose", n, n, n, &c_b7, &ainv[ainv_offset],
00139 ldainv, &a[a_offset], lda, &c_b8, &work[work_offset], ldwork);
00140 i__1 = *n;
00141 for (i__ = 1; i__ <= i__1; ++i__) {
00142 work[i__ + i__ * work_dim1] += 1.;
00143
00144 }
00145
00146
00147
00148 *resid = dlange_("1", n, n, &work[work_offset], ldwork, &rwork[1]);
00149
00150 *resid = *resid * *rcond / eps / (doublereal) (*n);
00151
00152 return 0;
00153
00154
00155
00156 }