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 doublereal c_b6 = 0.;
00021 static integer c__0 = 0;
00022 static doublereal c_b33 = -1.;
00023
00024 doublereal dqrt12_(integer *m, integer *n, doublereal *a, integer *lda,
00025 doublereal *s, doublereal *work, integer *lwork)
00026 {
00027
00028 integer a_dim1, a_offset, i__1, i__2;
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 *), dgebd2_(integer *, integer *,
00038 doublereal *, integer *, doublereal *, doublereal *, doublereal *
00039 , doublereal *, doublereal *, integer *);
00040 doublereal dummy[1];
00041 extern int dlabad_(doublereal *, doublereal *);
00042 extern doublereal dlamch_(char *), dlange_(char *, integer *,
00043 integer *, doublereal *, integer *, doublereal *);
00044 extern int dlascl_(char *, integer *, integer *,
00045 doublereal *, doublereal *, integer *, integer *, doublereal *,
00046 integer *, integer *), dlaset_(char *, integer *, integer
00047 *, doublereal *, doublereal *, doublereal *, integer *),
00048 xerbla_(char *, integer *), dbdsqr_(char *, integer *,
00049 integer *, integer *, integer *, doublereal *, doublereal *,
00050 doublereal *, integer *, doublereal *, integer *, doublereal *,
00051 integer *, doublereal *, integer *);
00052 doublereal bignum, smlnum, nrmsvl;
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 a_dim1 = *lda;
00114 a_offset = 1 + a_dim1;
00115 a -= a_offset;
00116 --s;
00117 --work;
00118
00119
00120 ret_val = 0.;
00121
00122
00123
00124
00125 i__1 = *m * *n + (min(*m,*n) << 2) + max(*m,*n), i__2 = *m * *n + (min(*m,
00126 *n) << 1) + (*n << 2);
00127 if (*lwork < max(i__1,i__2)) {
00128 xerbla_("DQRT12", &c__7);
00129 return ret_val;
00130 }
00131
00132
00133
00134 mn = min(*m,*n);
00135 if ((doublereal) mn <= 0.) {
00136 return ret_val;
00137 }
00138
00139 nrmsvl = dnrm2_(&mn, &s[1], &c__1);
00140
00141
00142
00143 dlaset_("Full", m, n, &c_b6, &c_b6, &work[1], m);
00144 i__1 = *n;
00145 for (j = 1; j <= i__1; ++j) {
00146 i__2 = min(j,*m);
00147 for (i__ = 1; i__ <= i__2; ++i__) {
00148 work[(j - 1) * *m + i__] = a[i__ + j * a_dim1];
00149
00150 }
00151
00152 }
00153
00154
00155
00156 smlnum = dlamch_("S") / dlamch_("P");
00157 bignum = 1. / smlnum;
00158 dlabad_(&smlnum, &bignum);
00159
00160
00161
00162 anrm = dlange_("M", m, n, &work[1], m, dummy);
00163 iscl = 0;
00164 if (anrm > 0. && anrm < smlnum) {
00165
00166
00167
00168 dlascl_("G", &c__0, &c__0, &anrm, &smlnum, m, n, &work[1], m, &info);
00169 iscl = 1;
00170 } else if (anrm > bignum) {
00171
00172
00173
00174 dlascl_("G", &c__0, &c__0, &anrm, &bignum, m, n, &work[1], m, &info);
00175 iscl = 1;
00176 }
00177
00178 if (anrm != 0.) {
00179
00180
00181
00182 dgebd2_(m, n, &work[1], m, &work[*m * *n + 1], &work[*m * *n + mn + 1]
00183 , &work[*m * *n + (mn << 1) + 1], &work[*m * *n + mn * 3 + 1],
00184 &work[*m * *n + (mn << 2) + 1], &info);
00185 dbdsqr_("Upper", &mn, &c__0, &c__0, &c__0, &work[*m * *n + 1], &work[*
00186 m * *n + mn + 1], dummy, &mn, dummy, &c__1, dummy, &mn, &work[
00187 *m * *n + (mn << 1) + 1], &info);
00188
00189 if (iscl == 1) {
00190 if (anrm > bignum) {
00191 dlascl_("G", &c__0, &c__0, &bignum, &anrm, &mn, &c__1, &work[*
00192 m * *n + 1], &mn, &info);
00193 }
00194 if (anrm < smlnum) {
00195 dlascl_("G", &c__0, &c__0, &smlnum, &anrm, &mn, &c__1, &work[*
00196 m * *n + 1], &mn, &info);
00197 }
00198 }
00199
00200 } else {
00201
00202 i__1 = mn;
00203 for (i__ = 1; i__ <= i__1; ++i__) {
00204 work[*m * *n + i__] = 0.;
00205
00206 }
00207 }
00208
00209
00210
00211 daxpy_(&mn, &c_b33, &s[1], &c__1, &work[*m * *n + 1], &c__1);
00212 ret_val = dasum_(&mn, &work[*m * *n + 1], &c__1) / (dlamch_("Epsilon") * (doublereal) max(*m,*n));
00213 if (nrmsvl != 0.) {
00214 ret_val /= nrmsvl;
00215 }
00216
00217 return ret_val;
00218
00219
00220
00221 }