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__7 = 7;
00019 static integer c__1 = 1;
00020 static complex c_b6 = {0.f,0.f};
00021 static integer c__0 = 0;
00022 static real c_b33 = -1.f;
00023
00024 doublereal cqrt12_(integer *m, integer *n, complex *a, integer *lda, real *s,
00025 complex *work, integer *lwork, real *rwork)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
00029 real ret_val;
00030
00031
00032 integer i__, j, mn, iscl, info;
00033 real anrm;
00034 extern doublereal snrm2_(integer *, real *, integer *);
00035 extern int cgebd2_(integer *, integer *, complex *,
00036 integer *, real *, real *, complex *, complex *, complex *,
00037 integer *);
00038 extern doublereal sasum_(integer *, real *, integer *);
00039 real dummy[1];
00040 extern int saxpy_(integer *, real *, real *, integer *,
00041 real *, integer *), slabad_(real *, real *);
00042 extern doublereal clange_(char *, integer *, integer *, complex *,
00043 integer *, real *);
00044 extern int clascl_(char *, integer *, integer *, real *,
00045 real *, integer *, integer *, complex *, integer *, integer *);
00046 extern doublereal slamch_(char *);
00047 extern int claset_(char *, integer *, integer *, complex
00048 *, complex *, complex *, integer *), xerbla_(char *,
00049 integer *);
00050 real bignum;
00051 extern int slascl_(char *, integer *, integer *, real *,
00052 real *, integer *, integer *, real *, integer *, integer *), sbdsqr_(char *, integer *, integer *, integer *, integer
00053 *, real *, real *, real *, integer *, real *, integer *, real *,
00054 integer *, real *, integer *);
00055 real smlnum, nrmsvl;
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 a_dim1 = *lda;
00119 a_offset = 1 + a_dim1;
00120 a -= a_offset;
00121 --s;
00122 --work;
00123 --rwork;
00124
00125
00126 ret_val = 0.f;
00127
00128
00129
00130 if (*lwork < *m * *n + (min(*m,*n) << 1) + max(*m,*n)) {
00131 xerbla_("CQRT12", &c__7);
00132 return ret_val;
00133 }
00134
00135
00136
00137 mn = min(*m,*n);
00138 if ((real) mn <= 0.f) {
00139 return ret_val;
00140 }
00141
00142 nrmsvl = snrm2_(&mn, &s[1], &c__1);
00143
00144
00145
00146 claset_("Full", m, n, &c_b6, &c_b6, &work[1], m);
00147 i__1 = *n;
00148 for (j = 1; j <= i__1; ++j) {
00149 i__2 = min(j,*m);
00150 for (i__ = 1; i__ <= i__2; ++i__) {
00151 i__3 = (j - 1) * *m + i__;
00152 i__4 = i__ + j * a_dim1;
00153 work[i__3].r = a[i__4].r, work[i__3].i = a[i__4].i;
00154
00155 }
00156
00157 }
00158
00159
00160
00161 smlnum = slamch_("S") / slamch_("P");
00162 bignum = 1.f / smlnum;
00163 slabad_(&smlnum, &bignum);
00164
00165
00166
00167 anrm = clange_("M", m, n, &work[1], m, dummy);
00168 iscl = 0;
00169 if (anrm > 0.f && anrm < smlnum) {
00170
00171
00172
00173 clascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &work[1], m, &info);
00174 iscl = 1;
00175 } else if (anrm > bignum) {
00176
00177
00178
00179 clascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &work[1], m, &info);
00180 iscl = 1;
00181 }
00182
00183 if (anrm != 0.f) {
00184
00185
00186
00187 cgebd2_(m, n, &work[1], m, &rwork[1], &rwork[mn + 1], &work[*m * *n +
00188 1], &work[*m * *n + mn + 1], &work[*m * *n + (mn << 1) + 1], &
00189 info);
00190 sbdsqr_("Upper", &mn, &c__0, &c__0, &c__0, &rwork[1], &rwork[mn + 1],
00191 dummy, &mn, dummy, &c__1, dummy, &mn, &rwork[(mn << 1) + 1], &
00192 info);
00193
00194 if (iscl == 1) {
00195 if (anrm > bignum) {
00196 slascl_("G", &c__0, &c__0, &bignum, &anrm, &mn, &c__1, &rwork[
00197 1], &mn, &info);
00198 }
00199 if (anrm < smlnum) {
00200 slascl_("G", &c__0, &c__0, &smlnum, &anrm, &mn, &c__1, &rwork[
00201 1], &mn, &info);
00202 }
00203 }
00204
00205 } else {
00206
00207 i__1 = mn;
00208 for (i__ = 1; i__ <= i__1; ++i__) {
00209 rwork[i__] = 0.f;
00210
00211 }
00212 }
00213
00214
00215
00216 saxpy_(&mn, &c_b33, &s[1], &c__1, &rwork[1], &c__1);
00217 ret_val = sasum_(&mn, &rwork[1], &c__1) / (slamch_("Epsilon") *
00218 (real) max(*m,*n));
00219 if (nrmsvl != 0.f) {
00220 ret_val /= nrmsvl;
00221 }
00222
00223 return ret_val;
00224
00225
00226
00227 }