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 integer c__13 = 13;
00020 static doublereal c_b13 = -1.;
00021 static doublereal c_b14 = 1.;
00022 static integer c__0 = 0;
00023 static doublereal c_b22 = 0.;
00024
00025 doublereal dqrt17_(char *trans, integer *iresid, integer *m, integer *n,
00026 integer *nrhs, doublereal *a, integer *lda, doublereal *x, integer *
00027 ldx, doublereal *b, integer *ldb, doublereal *c__, doublereal *work,
00028 integer *lwork)
00029 {
00030
00031 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, x_dim1,
00032 x_offset, i__1;
00033 doublereal ret_val;
00034
00035
00036 doublereal err;
00037 integer iscl, info;
00038 extern int dgemm_(char *, char *, integer *, integer *,
00039 integer *, doublereal *, doublereal *, integer *, doublereal *,
00040 integer *, doublereal *, doublereal *, integer *);
00041 extern logical lsame_(char *, char *);
00042 doublereal norma, normb;
00043 integer ncols;
00044 doublereal normx, rwork[1];
00045 integer nrows;
00046 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00047 integer *, doublereal *, integer *, doublereal *);
00048 extern int dlascl_(char *, integer *, integer *,
00049 doublereal *, doublereal *, integer *, integer *, doublereal *,
00050 integer *, integer *), dlacpy_(char *, integer *, integer
00051 *, doublereal *, integer *, doublereal *, integer *),
00052 xerbla_(char *, integer *);
00053 doublereal bignum, smlnum, normrs;
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
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 a_dim1 = *lda;
00151 a_offset = 1 + a_dim1;
00152 a -= a_offset;
00153 x_dim1 = *ldx;
00154 x_offset = 1 + x_dim1;
00155 x -= x_offset;
00156 c_dim1 = *ldb;
00157 c_offset = 1 + c_dim1;
00158 c__ -= c_offset;
00159 b_dim1 = *ldb;
00160 b_offset = 1 + b_dim1;
00161 b -= b_offset;
00162 --work;
00163
00164
00165 ret_val = 0.;
00166
00167 if (lsame_(trans, "N")) {
00168 nrows = *m;
00169 ncols = *n;
00170 } else if (lsame_(trans, "T")) {
00171 nrows = *n;
00172 ncols = *m;
00173 } else {
00174 xerbla_("DQRT17", &c__1);
00175 return ret_val;
00176 }
00177
00178 if (*lwork < ncols * *nrhs) {
00179 xerbla_("DQRT17", &c__13);
00180 return ret_val;
00181 }
00182
00183 if (*m <= 0 || *n <= 0 || *nrhs <= 0) {
00184 return ret_val;
00185 }
00186
00187 norma = dlange_("One-norm", m, n, &a[a_offset], lda, rwork);
00188 smlnum = dlamch_("Safe minimum") / dlamch_("Precision");
00189 bignum = 1. / smlnum;
00190 iscl = 0;
00191
00192
00193
00194 dlacpy_("All", &nrows, nrhs, &b[b_offset], ldb, &c__[c_offset], ldb);
00195 dgemm_(trans, "No transpose", &nrows, nrhs, &ncols, &c_b13, &a[a_offset],
00196 lda, &x[x_offset], ldx, &c_b14, &c__[c_offset], ldb);
00197 normrs = dlange_("Max", &nrows, nrhs, &c__[c_offset], ldb, rwork);
00198 if (normrs > smlnum) {
00199 iscl = 1;
00200 dlascl_("General", &c__0, &c__0, &normrs, &c_b14, &nrows, nrhs, &c__[
00201 c_offset], ldb, &info);
00202 }
00203
00204
00205
00206 dgemm_("Transpose", trans, nrhs, &ncols, &nrows, &c_b14, &c__[c_offset],
00207 ldb, &a[a_offset], lda, &c_b22, &work[1], nrhs);
00208
00209
00210
00211 err = dlange_("One-norm", nrhs, &ncols, &work[1], nrhs, rwork);
00212 if (norma != 0.) {
00213 err /= norma;
00214 }
00215
00216 if (iscl == 1) {
00217 err *= normrs;
00218 }
00219
00220 if (*iresid == 1) {
00221 normb = dlange_("One-norm", &nrows, nrhs, &b[b_offset], ldb, rwork);
00222 if (normb != 0.) {
00223 err /= normb;
00224 }
00225 } else {
00226 normx = dlange_("One-norm", &ncols, nrhs, &x[x_offset], ldx, rwork);
00227 if (normx != 0.) {
00228 err /= normx;
00229 }
00230 }
00231
00232
00233 i__1 = max(*m,*n);
00234 ret_val = err / (dlamch_("Epsilon") * (doublereal) max(i__1,*
00235 nrhs));
00236 return ret_val;
00237
00238
00239
00240 }