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