00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dget53_(doublereal *a, integer *lda, doublereal *b,
00017 integer *ldb, doublereal *scale, doublereal *wr, doublereal *wi,
00018 doublereal *result, integer *info)
00019 {
00020
00021 integer a_dim1, a_offset, b_dim1, b_offset;
00022 doublereal d__1, d__2, d__3, d__4, d__5, d__6;
00023
00024
00025 double sqrt(doublereal);
00026
00027
00028 doublereal s1, ci11, ci12, ci22, cr11, cr12, cr21, cr22, ulp, wis, wrs,
00029 deti, absw, detr, temp, anorm, bnorm, cnorm;
00030 extern doublereal dlamch_(char *);
00031 doublereal cscale, scales, safmin, sigmin;
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
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
00115
00116
00117
00118
00119
00120 a_dim1 = *lda;
00121 a_offset = 1 + a_dim1;
00122 a -= a_offset;
00123 b_dim1 = *ldb;
00124 b_offset = 1 + b_dim1;
00125 b -= b_offset;
00126
00127
00128 *info = 0;
00129 *result = 0.;
00130 scales = *scale;
00131 wrs = *wr;
00132 wis = *wi;
00133
00134
00135
00136 safmin = dlamch_("Safe minimum");
00137 ulp = dlamch_("Epsilon") * dlamch_("Base");
00138 absw = abs(wrs) + abs(wis);
00139
00140 d__5 = (d__1 = a[a_dim1 + 1], abs(d__1)) + (d__2 = a[a_dim1 + 2], abs(
00141 d__2)), d__6 = (d__3 = a[(a_dim1 << 1) + 1], abs(d__3)) + (d__4 =
00142 a[(a_dim1 << 1) + 2], abs(d__4)), d__5 = max(d__5,d__6);
00143 anorm = max(d__5,safmin);
00144
00145 d__4 = (d__3 = b[b_dim1 + 1], abs(d__3)), d__5 = (d__1 = b[(b_dim1 << 1)
00146 + 1], abs(d__1)) + (d__2 = b[(b_dim1 << 1) + 2], abs(d__2)), d__4
00147 = max(d__4,d__5);
00148 bnorm = max(d__4,safmin);
00149
00150
00151
00152 temp = safmin * bnorm * absw + safmin * anorm * scales;
00153 if (temp >= 1.) {
00154
00155
00156
00157 *info = 1;
00158 temp = 1. / temp;
00159 scales *= temp;
00160 wrs *= temp;
00161 wis *= temp;
00162 absw = abs(wrs) + abs(wis);
00163 }
00164
00165
00166 d__3 = scales * anorm, d__4 = absw * bnorm;
00167 d__1 = ulp * max(d__3,d__4), d__2 = safmin * max(scales,absw);
00168 s1 = max(d__1,d__2);
00169
00170
00171
00172 if (s1 < safmin) {
00173 *info = 2;
00174 if (scales < safmin && absw < safmin) {
00175 *info = 3;
00176 *result = 1. / ulp;
00177 return 0;
00178 }
00179
00180
00181
00182
00183 d__1 = scales * anorm + absw * bnorm;
00184 temp = 1. / max(d__1,safmin);
00185 scales *= temp;
00186 wrs *= temp;
00187 wis *= temp;
00188 absw = abs(wrs) + abs(wis);
00189
00190
00191 d__3 = scales * anorm, d__4 = absw * bnorm;
00192 d__1 = ulp * max(d__3,d__4), d__2 = safmin * max(scales,absw);
00193 s1 = max(d__1,d__2);
00194 if (s1 < safmin) {
00195 *info = 3;
00196 *result = 1. / ulp;
00197 return 0;
00198 }
00199 }
00200
00201
00202
00203 cr11 = scales * a[a_dim1 + 1] - wrs * b[b_dim1 + 1];
00204 ci11 = -wis * b[b_dim1 + 1];
00205 cr21 = scales * a[a_dim1 + 2];
00206 cr12 = scales * a[(a_dim1 << 1) + 1] - wrs * b[(b_dim1 << 1) + 1];
00207 ci12 = -wis * b[(b_dim1 << 1) + 1];
00208 cr22 = scales * a[(a_dim1 << 1) + 2] - wrs * b[(b_dim1 << 1) + 2];
00209 ci22 = -wis * b[(b_dim1 << 1) + 2];
00210
00211
00212
00213
00214
00215
00216
00217
00218 d__1 = abs(cr11) + abs(ci11) + abs(cr21), d__2 = abs(cr12) + abs(ci12) +
00219 abs(cr22) + abs(ci22), d__1 = max(d__1,d__2);
00220 cnorm = max(d__1,safmin);
00221 cscale = 1. / sqrt(cnorm);
00222 detr = cscale * cr11 * (cscale * cr22) - cscale * ci11 * (cscale * ci22)
00223 - cscale * cr12 * (cscale * cr21);
00224 deti = cscale * cr11 * (cscale * ci22) + cscale * ci11 * (cscale * cr22)
00225 - cscale * ci12 * (cscale * cr21);
00226 sigmin = abs(detr) + abs(deti);
00227 *result = sigmin / s1;
00228 return 0;
00229
00230
00231
00232 }