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 complex c_b5 = {1.f,0.f};
00019
00020 int clarfp_(integer *n, complex *alpha, complex *x, integer *
00021 incx, complex *tau)
00022 {
00023
00024 integer i__1, i__2;
00025 real r__1, r__2;
00026 complex q__1, q__2;
00027
00028
00029 double r_imag(complex *), r_sign(real *, real *);
00030
00031
00032 integer j, knt;
00033 real beta;
00034 extern int cscal_(integer *, complex *, complex *,
00035 integer *);
00036 real alphi, alphr, xnorm;
00037 extern doublereal scnrm2_(integer *, complex *, integer *), slapy2_(real *
00038 , real *), slapy3_(real *, real *, real *);
00039 extern VOID cladiv_(complex *, complex *, complex *);
00040 extern doublereal slamch_(char *);
00041 extern int csscal_(integer *, real *, complex *, integer
00042 *);
00043 real safmin, rsafmn;
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 --x;
00115
00116
00117 if (*n <= 0) {
00118 tau->r = 0.f, tau->i = 0.f;
00119 return 0;
00120 }
00121
00122 i__1 = *n - 1;
00123 xnorm = scnrm2_(&i__1, &x[1], incx);
00124 alphr = alpha->r;
00125 alphi = r_imag(alpha);
00126
00127 if (xnorm == 0.f && alphi == 0.f) {
00128
00129
00130
00131 if (alphi == 0.f) {
00132 if (alphr >= 0.f) {
00133
00134
00135
00136 tau->r = 0.f, tau->i = 0.f;
00137 } else {
00138
00139
00140 tau->r = 2.f, tau->i = 0.f;
00141 i__1 = *n - 1;
00142 for (j = 1; j <= i__1; ++j) {
00143 i__2 = (j - 1) * *incx + 1;
00144 x[i__2].r = 0.f, x[i__2].i = 0.f;
00145 }
00146 q__1.r = -alpha->r, q__1.i = -alpha->i;
00147 alpha->r = q__1.r, alpha->i = q__1.i;
00148 }
00149 } else {
00150
00151 xnorm = slapy2_(&alphr, &alphi);
00152 r__1 = 1.f - alphr / xnorm;
00153 r__2 = -alphi / xnorm;
00154 q__1.r = r__1, q__1.i = r__2;
00155 tau->r = q__1.r, tau->i = q__1.i;
00156 i__1 = *n - 1;
00157 for (j = 1; j <= i__1; ++j) {
00158 i__2 = (j - 1) * *incx + 1;
00159 x[i__2].r = 0.f, x[i__2].i = 0.f;
00160 }
00161 alpha->r = xnorm, alpha->i = 0.f;
00162 }
00163 } else {
00164
00165
00166
00167 r__1 = slapy3_(&alphr, &alphi, &xnorm);
00168 beta = r_sign(&r__1, &alphr);
00169 safmin = slamch_("S") / slamch_("E");
00170 rsafmn = 1.f / safmin;
00171
00172 knt = 0;
00173 if (dabs(beta) < safmin) {
00174
00175
00176
00177 L10:
00178 ++knt;
00179 i__1 = *n - 1;
00180 csscal_(&i__1, &rsafmn, &x[1], incx);
00181 beta *= rsafmn;
00182 alphi *= rsafmn;
00183 alphr *= rsafmn;
00184 if (dabs(beta) < safmin) {
00185 goto L10;
00186 }
00187
00188
00189
00190 i__1 = *n - 1;
00191 xnorm = scnrm2_(&i__1, &x[1], incx);
00192 q__1.r = alphr, q__1.i = alphi;
00193 alpha->r = q__1.r, alpha->i = q__1.i;
00194 r__1 = slapy3_(&alphr, &alphi, &xnorm);
00195 beta = r_sign(&r__1, &alphr);
00196 }
00197 q__1.r = alpha->r + beta, q__1.i = alpha->i;
00198 alpha->r = q__1.r, alpha->i = q__1.i;
00199 if (beta < 0.f) {
00200 beta = -beta;
00201 q__2.r = -alpha->r, q__2.i = -alpha->i;
00202 q__1.r = q__2.r / beta, q__1.i = q__2.i / beta;
00203 tau->r = q__1.r, tau->i = q__1.i;
00204 } else {
00205 alphr = alphi * (alphi / alpha->r);
00206 alphr += xnorm * (xnorm / alpha->r);
00207 r__1 = alphr / beta;
00208 r__2 = -alphi / beta;
00209 q__1.r = r__1, q__1.i = r__2;
00210 tau->r = q__1.r, tau->i = q__1.i;
00211 r__1 = -alphr;
00212 q__1.r = r__1, q__1.i = alphi;
00213 alpha->r = q__1.r, alpha->i = q__1.i;
00214 }
00215 cladiv_(&q__1, &c_b5, alpha);
00216 alpha->r = q__1.r, alpha->i = q__1.i;
00217 i__1 = *n - 1;
00218 cscal_(&i__1, alpha, &x[1], incx);
00219
00220
00221
00222 i__1 = knt;
00223 for (j = 1; j <= i__1; ++j) {
00224 beta *= safmin;
00225
00226 }
00227 alpha->r = beta, alpha->i = 0.f;
00228 }
00229
00230 return 0;
00231
00232
00233
00234 }