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 doublecomplex c_b7 = {0.,0.};
00019 static doublecomplex c_b8 = {1.,0.};
00020 static doublereal c_b10 = -1.;
00021 static doublereal c_b11 = 1.;
00022 static integer c__1 = 1;
00023
00024 int zunt01_(char *rowcol, integer *m, integer *n,
00025 doublecomplex *u, integer *ldu, doublecomplex *work, integer *lwork,
00026 doublereal *rwork, doublereal *resid)
00027 {
00028
00029 integer u_dim1, u_offset, i__1, i__2;
00030 doublereal d__1, d__2, d__3, d__4;
00031 doublecomplex z__1, z__2;
00032
00033
00034 double d_imag(doublecomplex *);
00035
00036
00037 integer i__, j, k;
00038 doublereal eps;
00039 doublecomplex tmp;
00040 extern logical lsame_(char *, char *);
00041 integer mnmin;
00042 extern VOID zdotc_(doublecomplex *, integer *,
00043 doublecomplex *, integer *, doublecomplex *, integer *);
00044 extern int zherk_(char *, char *, integer *, integer *,
00045 doublereal *, doublecomplex *, integer *, doublereal *,
00046 doublecomplex *, integer *);
00047 extern doublereal dlamch_(char *);
00048 integer ldwork;
00049 extern int zlaset_(char *, integer *, integer *,
00050 doublecomplex *, doublecomplex *, doublecomplex *, integer *);
00051 char transu[1];
00052 extern doublereal zlansy_(char *, char *, integer *, doublecomplex *,
00053 integer *, doublereal *);
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 u_dim1 = *ldu;
00143 u_offset = 1 + u_dim1;
00144 u -= u_offset;
00145 --work;
00146 --rwork;
00147
00148
00149 *resid = 0.;
00150
00151
00152
00153 if (*m <= 0 || *n <= 0) {
00154 return 0;
00155 }
00156
00157 eps = dlamch_("Precision");
00158 if (*m < *n || *m == *n && lsame_(rowcol, "R")) {
00159 *(unsigned char *)transu = 'N';
00160 k = *n;
00161 } else {
00162 *(unsigned char *)transu = 'C';
00163 k = *m;
00164 }
00165 mnmin = min(*m,*n);
00166
00167 if ((mnmin + 1) * mnmin <= *lwork) {
00168 ldwork = mnmin;
00169 } else {
00170 ldwork = 0;
00171 }
00172 if (ldwork > 0) {
00173
00174
00175
00176 zlaset_("Upper", &mnmin, &mnmin, &c_b7, &c_b8, &work[1], &ldwork);
00177 zherk_("Upper", transu, &mnmin, &k, &c_b10, &u[u_offset], ldu, &c_b11,
00178 &work[1], &ldwork);
00179
00180
00181
00182 *resid = zlansy_("1", "Upper", &mnmin, &work[1], &ldwork, &rwork[1]);
00183 *resid = *resid / (doublereal) k / eps;
00184 } else if (*(unsigned char *)transu == 'C') {
00185
00186
00187
00188 i__1 = *n;
00189 for (j = 1; j <= i__1; ++j) {
00190 i__2 = j;
00191 for (i__ = 1; i__ <= i__2; ++i__) {
00192 if (i__ != j) {
00193 tmp.r = 0., tmp.i = 0.;
00194 } else {
00195 tmp.r = 1., tmp.i = 0.;
00196 }
00197 zdotc_(&z__2, m, &u[i__ * u_dim1 + 1], &c__1, &u[j * u_dim1 +
00198 1], &c__1);
00199 z__1.r = tmp.r - z__2.r, z__1.i = tmp.i - z__2.i;
00200 tmp.r = z__1.r, tmp.i = z__1.i;
00201
00202 d__3 = *resid, d__4 = (d__1 = tmp.r, abs(d__1)) + (d__2 =
00203 d_imag(&tmp), abs(d__2));
00204 *resid = max(d__3,d__4);
00205
00206 }
00207
00208 }
00209 *resid = *resid / (doublereal) (*m) / eps;
00210 } else {
00211
00212
00213
00214 i__1 = *m;
00215 for (j = 1; j <= i__1; ++j) {
00216 i__2 = j;
00217 for (i__ = 1; i__ <= i__2; ++i__) {
00218 if (i__ != j) {
00219 tmp.r = 0., tmp.i = 0.;
00220 } else {
00221 tmp.r = 1., tmp.i = 0.;
00222 }
00223 zdotc_(&z__2, n, &u[j + u_dim1], ldu, &u[i__ + u_dim1], ldu);
00224 z__1.r = tmp.r - z__2.r, z__1.i = tmp.i - z__2.i;
00225 tmp.r = z__1.r, tmp.i = z__1.i;
00226
00227 d__3 = *resid, d__4 = (d__1 = tmp.r, abs(d__1)) + (d__2 =
00228 d_imag(&tmp), abs(d__2));
00229 *resid = max(d__3,d__4);
00230
00231 }
00232
00233 }
00234 *resid = *resid / (doublereal) (*n) / eps;
00235 }
00236 return 0;
00237
00238
00239
00240 }