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