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