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 doublecomplex c_b7 = {-1.,-0.};
00020 static doublecomplex c_b10 = {1.,0.};
00021
00022 int zbdt02_(integer *m, integer *n, doublecomplex *b,
00023 integer *ldb, doublecomplex *c__, integer *ldc, doublecomplex *u,
00024 integer *ldu, doublecomplex *work, doublereal *rwork, doublereal *
00025 resid)
00026 {
00027
00028 integer b_dim1, b_offset, c_dim1, c_offset, u_dim1, u_offset, i__1;
00029 doublereal d__1, d__2;
00030
00031
00032 integer j;
00033 doublereal eps, bnorm;
00034 extern int zgemv_(char *, integer *, integer *,
00035 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00036 integer *, doublecomplex *, doublecomplex *, integer *),
00037 zcopy_(integer *, doublecomplex *, integer *, doublecomplex *,
00038 integer *);
00039 extern doublereal dlamch_(char *);
00040 doublereal realmn;
00041 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00042 integer *, doublereal *), dzasum_(integer *,
00043 doublecomplex *, integer *);
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
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 b_dim1 = *ldb;
00118 b_offset = 1 + b_dim1;
00119 b -= b_offset;
00120 c_dim1 = *ldc;
00121 c_offset = 1 + c_dim1;
00122 c__ -= c_offset;
00123 u_dim1 = *ldu;
00124 u_offset = 1 + u_dim1;
00125 u -= u_offset;
00126 --work;
00127 --rwork;
00128
00129
00130 *resid = 0.;
00131 if (*m <= 0 || *n <= 0) {
00132 return 0;
00133 }
00134 realmn = (doublereal) max(*m,*n);
00135 eps = dlamch_("Precision");
00136
00137
00138
00139 i__1 = *n;
00140 for (j = 1; j <= i__1; ++j) {
00141 zcopy_(m, &b[j * b_dim1 + 1], &c__1, &work[1], &c__1);
00142 zgemv_("No transpose", m, m, &c_b7, &u[u_offset], ldu, &c__[j *
00143 c_dim1 + 1], &c__1, &c_b10, &work[1], &c__1);
00144
00145 d__1 = *resid, d__2 = dzasum_(m, &work[1], &c__1);
00146 *resid = max(d__1,d__2);
00147
00148 }
00149
00150
00151
00152 bnorm = zlange_("1", m, n, &b[b_offset], ldb, &rwork[1]);
00153
00154 if (bnorm <= 0.) {
00155 if (*resid != 0.) {
00156 *resid = 1. / eps;
00157 }
00158 } else {
00159 if (bnorm >= *resid) {
00160 *resid = *resid / bnorm / (realmn * eps);
00161 } else {
00162 if (bnorm < 1.) {
00163
00164 d__1 = *resid, d__2 = realmn * bnorm;
00165 *resid = min(d__1,d__2) / bnorm / (realmn * eps);
00166 } else {
00167
00168 d__1 = *resid / bnorm;
00169 *resid = min(d__1,realmn) / (realmn * eps);
00170 }
00171 }
00172 }
00173 return 0;
00174
00175
00176
00177 }