Coverage Report

Created: 2023-09-25 06:05

/src/igraph/vendor/lapack/dlartg.c
Line
Count
Source (jump to first uncovered line)
1
/*  -- translated by f2c (version 20191129).
2
   You must link the resulting object file with libf2c:
3
  on Microsoft Windows system, link with libf2c.lib;
4
  on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5
  or, if you install libf2c.a in a standard place, with -lf2c -lm
6
  -- in that order, at the end of the command line, as in
7
    cc *.o -lf2c -lm
8
  Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
9
10
    http://www.netlib.org/f2c/libf2c.zip
11
*/
12
13
#include "f2c.h"
14
15
/* > \brief \b DLARTG generates a plane rotation with real cosine and real sine.   
16
17
    =========== DOCUMENTATION ===========   
18
19
   Online html documentation available at   
20
              http://www.netlib.org/lapack/explore-html/   
21
22
   > \htmlonly   
23
   > Download DLARTG + dependencies   
24
   > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlartg.
25
f">   
26
   > [TGZ]</a>   
27
   > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlartg.
28
f">   
29
   > [ZIP]</a>   
30
   > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlartg.
31
f">   
32
   > [TXT]</a>   
33
   > \endhtmlonly   
34
35
    Definition:   
36
    ===========   
37
38
         SUBROUTINE DLARTG( F, G, CS, SN, R )   
39
40
         DOUBLE PRECISION   CS, F, G, R, SN   
41
42
43
   > \par Purpose:   
44
    =============   
45
   >   
46
   > \verbatim   
47
   >   
48
   > DLARTG generate a plane rotation so that   
49
   >   
50
   >    [  CS  SN  ]  .  [ F ]  =  [ R ]   where CS**2 + SN**2 = 1.   
51
   >    [ -SN  CS  ]     [ G ]     [ 0 ]   
52
   >   
53
   > This is a slower, more accurate version of the BLAS1 routine DROTG,   
54
   > with the following other differences:   
55
   >    F and G are unchanged on return.   
56
   >    If G=0, then CS=1 and SN=0.   
57
   >    If F=0 and (G .ne. 0), then CS=0 and SN=1 without doing any   
58
   >       floating point operations (saves work in DBDSQR when   
59
   >       there are zeros on the diagonal).   
60
   >   
61
   > If F exceeds G in magnitude, CS will be positive.   
62
   > \endverbatim   
63
64
    Arguments:   
65
    ==========   
66
67
   > \param[in] F   
68
   > \verbatim   
69
   >          F is DOUBLE PRECISION   
70
   >          The first component of vector to be rotated.   
71
   > \endverbatim   
72
   >   
73
   > \param[in] G   
74
   > \verbatim   
75
   >          G is DOUBLE PRECISION   
76
   >          The second component of vector to be rotated.   
77
   > \endverbatim   
78
   >   
79
   > \param[out] CS   
80
   > \verbatim   
81
   >          CS is DOUBLE PRECISION   
82
   >          The cosine of the rotation.   
83
   > \endverbatim   
84
   >   
85
   > \param[out] SN   
86
   > \verbatim   
87
   >          SN is DOUBLE PRECISION   
88
   >          The sine of the rotation.   
89
   > \endverbatim   
90
   >   
91
   > \param[out] R   
92
   > \verbatim   
93
   >          R is DOUBLE PRECISION   
94
   >          The nonzero component of the rotated vector.   
95
   >   
96
   >  This version has a few statements commented out for thread safety   
97
   >  (machine parameters are computed on each entry). 10 feb 03, SJH.   
98
   > \endverbatim   
99
100
    Authors:   
101
    ========   
102
103
   > \author Univ. of Tennessee   
104
   > \author Univ. of California Berkeley   
105
   > \author Univ. of Colorado Denver   
106
   > \author NAG Ltd.   
107
108
   > \date September 2012   
109
110
   > \ingroup auxOTHERauxiliary   
111
112
    =====================================================================   
113
   Subroutine */ int igraphdlartg_(doublereal *f, doublereal *g, doublereal *cs, 
114
  doublereal *sn, doublereal *r__)
115
0
{
116
    /* System generated locals */
117
0
    integer i__1;
118
0
    doublereal d__1, d__2;
119
120
    /* Builtin functions */
121
0
    double log(doublereal), pow_di(doublereal *, integer *), sqrt(doublereal);
122
123
    /* Local variables */
124
0
    integer i__;
125
0
    doublereal f1, g1, eps, scale;
126
0
    integer count;
127
0
    doublereal safmn2, safmx2;
128
0
    extern doublereal igraphdlamch_(char *);
129
0
    doublereal safmin;
130
131
132
/*  -- LAPACK auxiliary routine (version 3.4.2) --   
133
    -- LAPACK is a software package provided by Univ. of Tennessee,    --   
134
    -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--   
135
       September 2012   
136
137
138
    =====================================================================   
139
140
       LOGICAL            FIRST   
141
       SAVE               FIRST, SAFMX2, SAFMIN, SAFMN2   
142
       DATA               FIRST / .TRUE. /   
143
144
       IF( FIRST ) THEN */
145
0
    safmin = igraphdlamch_("S");
146
0
    eps = igraphdlamch_("E");
147
0
    d__1 = igraphdlamch_("B");
148
0
    i__1 = (integer) (log(safmin / eps) / log(igraphdlamch_("B")) / 2.);
149
0
    safmn2 = pow_di(&d__1, &i__1);
150
0
    safmx2 = 1. / safmn2;
151
/*        FIRST = .FALSE.   
152
       END IF */
153
0
    if (*g == 0.) {
154
0
  *cs = 1.;
155
0
  *sn = 0.;
156
0
  *r__ = *f;
157
0
    } else if (*f == 0.) {
158
0
  *cs = 0.;
159
0
  *sn = 1.;
160
0
  *r__ = *g;
161
0
    } else {
162
0
  f1 = *f;
163
0
  g1 = *g;
164
/* Computing MAX */
165
0
  d__1 = abs(f1), d__2 = abs(g1);
166
0
  scale = max(d__1,d__2);
167
0
  if (scale >= safmx2) {
168
0
      count = 0;
169
0
L10:
170
0
      ++count;
171
0
      f1 *= safmn2;
172
0
      g1 *= safmn2;
173
/* Computing MAX */
174
0
      d__1 = abs(f1), d__2 = abs(g1);
175
0
      scale = max(d__1,d__2);
176
0
      if (scale >= safmx2) {
177
0
    goto L10;
178
0
      }
179
/* Computing 2nd power */
180
0
      d__1 = f1;
181
/* Computing 2nd power */
182
0
      d__2 = g1;
183
0
      *r__ = sqrt(d__1 * d__1 + d__2 * d__2);
184
0
      *cs = f1 / *r__;
185
0
      *sn = g1 / *r__;
186
0
      i__1 = count;
187
0
      for (i__ = 1; i__ <= i__1; ++i__) {
188
0
    *r__ *= safmx2;
189
/* L20: */
190
0
      }
191
0
  } else if (scale <= safmn2) {
192
0
      count = 0;
193
0
L30:
194
0
      ++count;
195
0
      f1 *= safmx2;
196
0
      g1 *= safmx2;
197
/* Computing MAX */
198
0
      d__1 = abs(f1), d__2 = abs(g1);
199
0
      scale = max(d__1,d__2);
200
0
      if (scale <= safmn2) {
201
0
    goto L30;
202
0
      }
203
/* Computing 2nd power */
204
0
      d__1 = f1;
205
/* Computing 2nd power */
206
0
      d__2 = g1;
207
0
      *r__ = sqrt(d__1 * d__1 + d__2 * d__2);
208
0
      *cs = f1 / *r__;
209
0
      *sn = g1 / *r__;
210
0
      i__1 = count;
211
0
      for (i__ = 1; i__ <= i__1; ++i__) {
212
0
    *r__ *= safmn2;
213
/* L40: */
214
0
      }
215
0
  } else {
216
/* Computing 2nd power */
217
0
      d__1 = f1;
218
/* Computing 2nd power */
219
0
      d__2 = g1;
220
0
      *r__ = sqrt(d__1 * d__1 + d__2 * d__2);
221
0
      *cs = f1 / *r__;
222
0
      *sn = g1 / *r__;
223
0
  }
224
0
  if (abs(*f) > abs(*g) && *cs < 0.) {
225
0
      *cs = -(*cs);
226
0
      *sn = -(*sn);
227
0
      *r__ = -(*r__);
228
0
  }
229
0
    }
230
0
    return 0;
231
232
/*     End of DLARTG */
233
234
0
} /* igraphdlartg_ */
235