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