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 real c_b13 = -1.f;
00021 static real c_b14 = 1.f;
00022 static integer c__0 = 0;
00023 static real c_b22 = 0.f;
00024
00025 doublereal sqrt17_(char *trans, integer *iresid, integer *m, integer *n,
00026 integer *nrhs, real *a, integer *lda, real *x, integer *ldx, real *b,
00027 integer *ldb, real *c__, real *work, integer *lwork)
00028 {
00029
00030 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, x_dim1,
00031 x_offset, i__1;
00032 real ret_val;
00033
00034
00035 real err;
00036 integer iscl, info;
00037 extern logical lsame_(char *, char *);
00038 extern int sgemm_(char *, char *, integer *, integer *,
00039 integer *, real *, real *, integer *, real *, integer *, real *,
00040 real *, integer *);
00041 real norma, normb;
00042 integer ncols;
00043 real normx, rwork[1];
00044 integer nrows;
00045 extern doublereal slamch_(char *), slange_(char *, integer *,
00046 integer *, real *, integer *, real *);
00047 extern int xerbla_(char *, integer *);
00048 real bignum;
00049 extern int slascl_(char *, integer *, integer *, real *,
00050 real *, integer *, integer *, real *, integer *, integer *), slacpy_(char *, integer *, integer *, real *, integer *,
00051 real *, integer *);
00052 real smlnum, normrs;
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
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 a_dim1 = *lda;
00150 a_offset = 1 + a_dim1;
00151 a -= a_offset;
00152 x_dim1 = *ldx;
00153 x_offset = 1 + x_dim1;
00154 x -= x_offset;
00155 c_dim1 = *ldb;
00156 c_offset = 1 + c_dim1;
00157 c__ -= c_offset;
00158 b_dim1 = *ldb;
00159 b_offset = 1 + b_dim1;
00160 b -= b_offset;
00161 --work;
00162
00163
00164 ret_val = 0.f;
00165
00166 if (lsame_(trans, "N")) {
00167 nrows = *m;
00168 ncols = *n;
00169 } else if (lsame_(trans, "T")) {
00170 nrows = *n;
00171 ncols = *m;
00172 } else {
00173 xerbla_("SQRT17", &c__1);
00174 return ret_val;
00175 }
00176
00177 if (*lwork < ncols * *nrhs) {
00178 xerbla_("SQRT17", &c__13);
00179 return ret_val;
00180 }
00181
00182 if (*m <= 0 || *n <= 0 || *nrhs <= 0) {
00183 return ret_val;
00184 }
00185
00186 norma = slange_("One-norm", m, n, &a[a_offset], lda, rwork);
00187 smlnum = slamch_("Safe minimum") / slamch_("Precision");
00188 bignum = 1.f / smlnum;
00189 iscl = 0;
00190
00191
00192
00193 slacpy_("All", &nrows, nrhs, &b[b_offset], ldb, &c__[c_offset], ldb);
00194 sgemm_(trans, "No transpose", &nrows, nrhs, &ncols, &c_b13, &a[a_offset],
00195 lda, &x[x_offset], ldx, &c_b14, &c__[c_offset], ldb);
00196 normrs = slange_("Max", &nrows, nrhs, &c__[c_offset], ldb, rwork);
00197 if (normrs > smlnum) {
00198 iscl = 1;
00199 slascl_("General", &c__0, &c__0, &normrs, &c_b14, &nrows, nrhs, &c__[
00200 c_offset], ldb, &info);
00201 }
00202
00203
00204
00205 sgemm_("Transpose", trans, nrhs, &ncols, &nrows, &c_b14, &c__[c_offset],
00206 ldb, &a[a_offset], lda, &c_b22, &work[1], nrhs);
00207
00208
00209
00210 err = slange_("One-norm", nrhs, &ncols, &work[1], nrhs, rwork);
00211 if (norma != 0.f) {
00212 err /= norma;
00213 }
00214
00215 if (iscl == 1) {
00216 err *= normrs;
00217 }
00218
00219 if (*iresid == 1) {
00220 normb = slange_("One-norm", &nrows, nrhs, &b[b_offset], ldb, rwork);
00221 if (normb != 0.f) {
00222 err /= normb;
00223 }
00224 } else {
00225 normx = slange_("One-norm", &ncols, nrhs, &x[x_offset], ldx, rwork);
00226 if (normx != 0.f) {
00227 err /= normx;
00228 }
00229 }
00230
00231
00232 i__1 = max(*m,*n);
00233 ret_val = err / (slamch_("Epsilon") * (real) max(i__1,*nrhs));
00234 return ret_val;
00235
00236
00237
00238 }