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