kusano 7d535a
#include "f2c.h"
kusano 7d535a
kusano 7d535a
/* Subroutine */ int clartg_(complex *f, complex *g, real *cs, complex *sn, 
kusano 7d535a
	complex *r)
kusano 7d535a
{
kusano 7d535a
/*  -- LAPACK auxiliary routine (version 2.0) --   
kusano 7d535a
       Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,   
kusano 7d535a
       Courant Institute, Argonne National Lab, and Rice University   
kusano 7d535a
       September 30, 1994   
kusano 7d535a
kusano 7d535a
kusano 7d535a
    Purpose   
kusano 7d535a
    =======   
kusano 7d535a
kusano 7d535a
    CLARTG generates a plane rotation so that   
kusano 7d535a
kusano 7d535a
       [  CS  SN  ]     [ F ]     [ R ]   
kusano 7d535a
       [  __      ]  .  [   ]  =  [   ]   where CS**2 + |SN|**2 = 1.   
kusano 7d535a
       [ -SN  CS  ]     [ G ]     [ 0 ]   
kusano 7d535a
kusano 7d535a
    This is a faster version of the BLAS1 routine CROTG, except for   
kusano 7d535a
    the following differences:   
kusano 7d535a
       F and G are unchanged on return.   
kusano 7d535a
       If G=0, then CS=1 and SN=0.   
kusano 7d535a
       If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any   
kusano 7d535a
          floating point operations.   
kusano 7d535a
kusano 7d535a
    Arguments   
kusano 7d535a
    =========   
kusano 7d535a
kusano 7d535a
    F       (input) COMPLEX   
kusano 7d535a
            The first component of vector to be rotated.   
kusano 7d535a
kusano 7d535a
    G       (input) COMPLEX   
kusano 7d535a
            The second component of vector to be rotated.   
kusano 7d535a
kusano 7d535a
    CS      (output) REAL   
kusano 7d535a
            The cosine of the rotation.   
kusano 7d535a
kusano 7d535a
    SN      (output) COMPLEX   
kusano 7d535a
            The sine of the rotation.   
kusano 7d535a
kusano 7d535a
    R       (output) COMPLEX   
kusano 7d535a
            The nonzero component of the rotated vector.   
kusano 7d535a
kusano 7d535a
    ===================================================================== 
kusano 7d535a
  
kusano 7d535a
kusano 7d535a
kusano 7d535a
       [ 25 or 38 ops for main paths ] */
kusano 7d535a
    /* System generated locals */
kusano 7d535a
    real r__1, r__2;
kusano 7d535a
    doublereal d__1;
kusano 7d535a
    complex q__1, q__2, q__3;
kusano 7d535a
    /* Builtin functions */
kusano 7d535a
    void r_cnjg(complex *, complex *);
kusano 7d535a
    double c_abs(complex *), r_imag(complex *), sqrt(doublereal);
kusano 7d535a
    /* Local variables */
kusano 7d535a
    static real d, f1, f2, g1, g2, fa, ga, di;
kusano 7d535a
    static complex fs, gs, ss;
kusano 7d535a
kusano 7d535a
kusano 7d535a
    if (g->r == 0.f && g->i == 0.f) {
kusano 7d535a
	*cs = 1.f;
kusano 7d535a
	sn->r = 0.f, sn->i = 0.f;
kusano 7d535a
	r->r = f->r, r->i = f->i;
kusano 7d535a
    } else if (f->r == 0.f && f->i == 0.f) {
kusano 7d535a
	*cs = 0.f;
kusano 7d535a
kusano 7d535a
	r_cnjg(&q__2, g);
kusano 7d535a
	d__1 = c_abs(g);
kusano 7d535a
	q__1.r = q__2.r / d__1, q__1.i = q__2.i / d__1;
kusano 7d535a
	sn->r = q__1.r, sn->i = q__1.i;
kusano 7d535a
	d__1 = c_abs(g);
kusano 7d535a
	r->r = d__1, r->i = 0.f;
kusano 7d535a
kusano 7d535a
/*         SN = ONE   
kusano 7d535a
           R = G */
kusano 7d535a
kusano 7d535a
    } else {
kusano 7d535a
	f1 = (r__1 = f->r, dabs(r__1)) + (r__2 = r_imag(f), dabs(r__2));
kusano 7d535a
	g1 = (r__1 = g->r, dabs(r__1)) + (r__2 = r_imag(g), dabs(r__2));
kusano 7d535a
	if (f1 >= g1) {
kusano 7d535a
	    q__1.r = g->r / f1, q__1.i = g->i / f1;
kusano 7d535a
	    gs.r = q__1.r, gs.i = q__1.i;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__1 = gs.r;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__2 = r_imag(&gs);
kusano 7d535a
	    g2 = r__1 * r__1 + r__2 * r__2;
kusano 7d535a
	    q__1.r = f->r / f1, q__1.i = f->i / f1;
kusano 7d535a
	    fs.r = q__1.r, fs.i = q__1.i;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__1 = fs.r;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__2 = r_imag(&fs);
kusano 7d535a
	    f2 = r__1 * r__1 + r__2 * r__2;
kusano 7d535a
	    d = sqrt(g2 / f2 + 1.f);
kusano 7d535a
	    *cs = 1.f / d;
kusano 7d535a
	    r_cnjg(&q__3, &gs);
kusano 7d535a
	    q__2.r = q__3.r * fs.r - q__3.i * fs.i, q__2.i = q__3.r * fs.i + 
kusano 7d535a
		    q__3.i * fs.r;
kusano 7d535a
	    d__1 = *cs / f2;
kusano 7d535a
	    q__1.r = d__1 * q__2.r, q__1.i = d__1 * q__2.i;
kusano 7d535a
	    sn->r = q__1.r, sn->i = q__1.i;
kusano 7d535a
	    q__1.r = d * f->r, q__1.i = d * f->i;
kusano 7d535a
	    r->r = q__1.r, r->i = q__1.i;
kusano 7d535a
	} else {
kusano 7d535a
	    q__1.r = f->r / g1, q__1.i = f->i / g1;
kusano 7d535a
	    fs.r = q__1.r, fs.i = q__1.i;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__1 = fs.r;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__2 = r_imag(&fs);
kusano 7d535a
	    f2 = r__1 * r__1 + r__2 * r__2;
kusano 7d535a
	    fa = sqrt(f2);
kusano 7d535a
	    q__1.r = g->r / g1, q__1.i = g->i / g1;
kusano 7d535a
	    gs.r = q__1.r, gs.i = q__1.i;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__1 = gs.r;
kusano 7d535a
/* Computing 2nd power */
kusano 7d535a
	    r__2 = r_imag(&gs);
kusano 7d535a
	    g2 = r__1 * r__1 + r__2 * r__2;
kusano 7d535a
	    ga = sqrt(g2);
kusano 7d535a
	    d = sqrt(f2 / g2 + 1.f);
kusano 7d535a
	    di = 1.f / d;
kusano 7d535a
	    *cs = fa / ga * di;
kusano 7d535a
	    r_cnjg(&q__3, &gs);
kusano 7d535a
	    q__2.r = q__3.r * fs.r - q__3.i * fs.i, q__2.i = q__3.r * fs.i + 
kusano 7d535a
		    q__3.i * fs.r;
kusano 7d535a
	    d__1 = fa * ga;
kusano 7d535a
	    q__1.r = q__2.r / d__1, q__1.i = q__2.i / d__1;
kusano 7d535a
	    ss.r = q__1.r, ss.i = q__1.i;
kusano 7d535a
	    q__1.r = di * ss.r, q__1.i = di * ss.i;
kusano 7d535a
	    sn->r = q__1.r, sn->i = q__1.i;
kusano 7d535a
	    q__2.r = g->r * ss.r - g->i * ss.i, q__2.i = g->r * ss.i + g->i * 
kusano 7d535a
		    ss.r;
kusano 7d535a
	    q__1.r = d * q__2.r, q__1.i = d * q__2.i;
kusano 7d535a
	    r->r = q__1.r, r->i = q__1.i;
kusano 7d535a
	}
kusano 7d535a
    }
kusano 7d535a
    return 0;
kusano 7d535a
kusano 7d535a
/*     End of CLARTG */
kusano 7d535a
kusano 7d535a
} /* clartg_ */
kusano 7d535a