File: drotg.c

package info (click to toggle)
insighttoolkit 3.18.0-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 110,432 kB
  • ctags: 74,559
  • sloc: cpp: 412,627; ansic: 196,210; fortran: 28,000; python: 3,852; tcl: 2,005; sh: 1,186; java: 583; makefile: 458; csh: 220; perl: 193; xml: 20
file content (98 lines) | stat: -rw-r--r-- 2,537 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* blas/drotg.f -- translated by f2c (version 20050501).
   You must link the resulting object file with libf2c:
        on Microsoft Windows system, link with libf2c.lib;
        on Linux or Unix systems, link with .../path/to/libf2c.a -lm
        or, if you install libf2c.a in a standard place, with -lf2c -lm
        -- in that order, at the end of the command line, as in
                cc *.o -lf2c -lm
        Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,

                http://www.netlib.org/f2c/libf2c.zip
*/

#ifdef __cplusplus
extern "C" {
#endif
#include "v3p_netlib.h"

/* Table of constant values */

static doublereal c_b4 = 1.;

/*<       subroutine drotg(da,db,c,s) >*/
/* Subroutine */ int drotg_(doublereal *da, doublereal *db, doublereal *c__, 
        doublereal *s)
{
    /* System generated locals */
    doublereal d__1, d__2;

    /* Builtin functions */
    double sqrt(doublereal), d_sign(doublereal *, doublereal *);

    /* Local variables */
    doublereal r__, z__, roe, scale;


/*     construct givens plane rotation. */
/*     jack dongarra, linpack, 3/11/78. */

/*<       double precision da,db,c,s,roe,scale,r,z >*/

/*<       roe = db >*/
    roe = *db;
/*<       if( dabs(da) .gt. dabs(db) ) roe = da >*/
    if (abs(*da) > abs(*db)) {
        roe = *da;
    }
/*<       scale = dabs(da) + dabs(db) >*/
    scale = abs(*da) + abs(*db);
/*<       if( scale .ne. 0.0d0 ) go to 10 >*/
    if (scale != 0.) {
        goto L10;
    }
/*<          c = 1.0d0 >*/
    *c__ = 1.;
/*<          s = 0.0d0 >*/
    *s = 0.;
/*<          r = 0.0d0 >*/
    r__ = 0.;
/*<          z = 0.0d0 >*/
    z__ = 0.;
/*<          go to 20 >*/
    goto L20;
/*<    10 r = scale*dsqrt((da/scale)**2 + (db/scale)**2) >*/
L10:
/* Computing 2nd power */
    d__1 = *da / scale;
/* Computing 2nd power */
    d__2 = *db / scale;
    r__ = scale * sqrt(d__1 * d__1 + d__2 * d__2);
/*<       r = dsign(1.0d0,roe)*r >*/
    r__ = d_sign(&c_b4, &roe) * r__;
/*<       c = da/r >*/
    *c__ = *da / r__;
/*<       s = db/r >*/
    *s = *db / r__;
/*<       z = 1.0d0 >*/
    z__ = 1.;
/*<       if( dabs(da) .gt. dabs(db) ) z = s >*/
    if (abs(*da) > abs(*db)) {
        z__ = *s;
    }
/*<       if( dabs(db) .ge. dabs(da) .and. c .ne. 0.0d0 ) z = 1.0d0/c >*/
    if (abs(*db) >= abs(*da) && *c__ != 0.) {
        z__ = 1. / *c__;
    }
/*<    20 da = r >*/
L20:
    *da = r__;
/*<       db = z >*/
    *db = z__;
/*<       return >*/
    return 0;
/*<       end >*/
} /* drotg_ */

#ifdef __cplusplus
        }
#endif