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 doublereal c_b7 = 0.;
00019 static doublereal c_b8 = 1.;
00020 static doublereal c_b10 = -1.;
00021 static integer c__1 = 1;
00022
00023 int dort01_(char *rowcol, integer *m, integer *n, doublereal
00024 *u, integer *ldu, doublereal *work, integer *lwork, doublereal *resid)
00025 {
00026
00027 integer u_dim1, u_offset, i__1, i__2;
00028 doublereal d__1, d__2;
00029
00030
00031 integer i__, j, k;
00032 doublereal eps, tmp;
00033 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00034 integer *);
00035 extern logical lsame_(char *, char *);
00036 integer mnmin;
00037 extern int dsyrk_(char *, char *, integer *, integer *,
00038 doublereal *, doublereal *, integer *, doublereal *, doublereal *,
00039 integer *);
00040 extern doublereal dlamch_(char *);
00041 extern int dlaset_(char *, integer *, integer *,
00042 doublereal *, doublereal *, doublereal *, integer *);
00043 extern doublereal dlansy_(char *, char *, integer *, doublereal *,
00044 integer *, doublereal *);
00045 integer ldwork;
00046 char transu[1];
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
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 u_dim1 = *ldu;
00128 u_offset = 1 + u_dim1;
00129 u -= u_offset;
00130 --work;
00131
00132
00133 *resid = 0.;
00134
00135
00136
00137 if (*m <= 0 || *n <= 0) {
00138 return 0;
00139 }
00140
00141 eps = dlamch_("Precision");
00142 if (*m < *n || *m == *n && lsame_(rowcol, "R")) {
00143 *(unsigned char *)transu = 'N';
00144 k = *n;
00145 } else {
00146 *(unsigned char *)transu = 'T';
00147 k = *m;
00148 }
00149 mnmin = min(*m,*n);
00150
00151 if ((mnmin + 1) * mnmin <= *lwork) {
00152 ldwork = mnmin;
00153 } else {
00154 ldwork = 0;
00155 }
00156 if (ldwork > 0) {
00157
00158
00159
00160 dlaset_("Upper", &mnmin, &mnmin, &c_b7, &c_b8, &work[1], &ldwork);
00161 dsyrk_("Upper", transu, &mnmin, &k, &c_b10, &u[u_offset], ldu, &c_b8,
00162 &work[1], &ldwork);
00163
00164
00165
00166 *resid = dlansy_("1", "Upper", &mnmin, &work[1], &ldwork, &work[
00167 ldwork * mnmin + 1]);
00168 *resid = *resid / (doublereal) k / eps;
00169 } else if (*(unsigned char *)transu == 'T') {
00170
00171
00172
00173 i__1 = *n;
00174 for (j = 1; j <= i__1; ++j) {
00175 i__2 = j;
00176 for (i__ = 1; i__ <= i__2; ++i__) {
00177 if (i__ != j) {
00178 tmp = 0.;
00179 } else {
00180 tmp = 1.;
00181 }
00182 tmp -= ddot_(m, &u[i__ * u_dim1 + 1], &c__1, &u[j * u_dim1 +
00183 1], &c__1);
00184
00185 d__1 = *resid, d__2 = abs(tmp);
00186 *resid = max(d__1,d__2);
00187
00188 }
00189
00190 }
00191 *resid = *resid / (doublereal) (*m) / eps;
00192 } else {
00193
00194
00195
00196 i__1 = *m;
00197 for (j = 1; j <= i__1; ++j) {
00198 i__2 = j;
00199 for (i__ = 1; i__ <= i__2; ++i__) {
00200 if (i__ != j) {
00201 tmp = 0.;
00202 } else {
00203 tmp = 1.;
00204 }
00205 tmp -= ddot_(n, &u[j + u_dim1], ldu, &u[i__ + u_dim1], ldu);
00206
00207 d__1 = *resid, d__2 = abs(tmp);
00208 *resid = max(d__1,d__2);
00209
00210 }
00211
00212 }
00213 *resid = *resid / (doublereal) (*n) / eps;
00214 }
00215 return 0;
00216
00217
00218
00219 }