/src/igraph/vendor/lapack/dnrm2.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 DNRM2 |
16 | | |
17 | | =========== DOCUMENTATION =========== |
18 | | |
19 | | Online html documentation available at |
20 | | http://www.netlib.org/lapack/explore-html/ |
21 | | |
22 | | Definition: |
23 | | =========== |
24 | | |
25 | | DOUBLE PRECISION FUNCTION DNRM2(N,X,INCX) |
26 | | |
27 | | INTEGER INCX,N |
28 | | DOUBLE PRECISION X(*) |
29 | | |
30 | | |
31 | | > \par Purpose: |
32 | | ============= |
33 | | > |
34 | | > \verbatim |
35 | | > |
36 | | > DNRM2 returns the euclidean norm of a vector via the function |
37 | | > name, so that |
38 | | > |
39 | | > DNRM2 := sqrt( x'*x ) |
40 | | > \endverbatim |
41 | | |
42 | | Arguments: |
43 | | ========== |
44 | | |
45 | | > \param[in] N |
46 | | > \verbatim |
47 | | > N is INTEGER |
48 | | > number of elements in input vector(s) |
49 | | > \endverbatim |
50 | | > |
51 | | > \param[in] X |
52 | | > \verbatim |
53 | | > X is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) ) |
54 | | > \endverbatim |
55 | | > |
56 | | > \param[in] INCX |
57 | | > \verbatim |
58 | | > INCX is INTEGER |
59 | | > storage spacing between elements of DX |
60 | | > \endverbatim |
61 | | |
62 | | Authors: |
63 | | ======== |
64 | | |
65 | | > \author Univ. of Tennessee |
66 | | > \author Univ. of California Berkeley |
67 | | > \author Univ. of Colorado Denver |
68 | | > \author NAG Ltd. |
69 | | |
70 | | > \date November 2017 |
71 | | |
72 | | > \ingroup double_blas_level1 |
73 | | |
74 | | > \par Further Details: |
75 | | ===================== |
76 | | > |
77 | | > \verbatim |
78 | | > |
79 | | > -- This version written on 25-October-1982. |
80 | | > Modified on 14-October-1993 to inline the call to DLASSQ. |
81 | | > Sven Hammarling, Nag Ltd. |
82 | | > \endverbatim |
83 | | > |
84 | | ===================================================================== */ |
85 | | doublereal igraphdnrm2_(integer *n, doublereal *x, integer *incx) |
86 | 0 | { |
87 | | /* System generated locals */ |
88 | 0 | integer i__1, i__2; |
89 | 0 | doublereal ret_val, d__1; |
90 | | |
91 | | /* Builtin functions */ |
92 | 0 | double sqrt(doublereal); |
93 | | |
94 | | /* Local variables */ |
95 | 0 | integer ix; |
96 | 0 | doublereal ssq, norm, scale, absxi; |
97 | | |
98 | | |
99 | | /* -- Reference BLAS level1 routine (version 3.8.0) -- |
100 | | -- Reference BLAS is a software package provided by Univ. of Tennessee, -- |
101 | | -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
102 | | November 2017 |
103 | | |
104 | | |
105 | | ===================================================================== |
106 | | |
107 | | Parameter adjustments */ |
108 | 0 | --x; |
109 | | |
110 | | /* Function Body */ |
111 | 0 | if (*n < 1 || *incx < 1) { |
112 | 0 | norm = 0.; |
113 | 0 | } else if (*n == 1) { |
114 | 0 | norm = abs(x[1]); |
115 | 0 | } else { |
116 | 0 | scale = 0.; |
117 | 0 | ssq = 1.; |
118 | | /* The following loop is equivalent to this call to the LAPACK |
119 | | auxiliary routine: |
120 | | CALL DLASSQ( N, X, INCX, SCALE, SSQ ) */ |
121 | |
|
122 | 0 | i__1 = (*n - 1) * *incx + 1; |
123 | 0 | i__2 = *incx; |
124 | 0 | for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) { |
125 | 0 | if (x[ix] != 0.) { |
126 | 0 | absxi = (d__1 = x[ix], abs(d__1)); |
127 | 0 | if (scale < absxi) { |
128 | | /* Computing 2nd power */ |
129 | 0 | d__1 = scale / absxi; |
130 | 0 | ssq = ssq * (d__1 * d__1) + 1.; |
131 | 0 | scale = absxi; |
132 | 0 | } else { |
133 | | /* Computing 2nd power */ |
134 | 0 | d__1 = absxi / scale; |
135 | 0 | ssq += d__1 * d__1; |
136 | 0 | } |
137 | 0 | } |
138 | | /* L10: */ |
139 | 0 | } |
140 | 0 | norm = scale * sqrt(ssq); |
141 | 0 | } |
142 | |
|
143 | 0 | ret_val = norm; |
144 | 0 | return ret_val; |
145 | | |
146 | | /* End of DNRM2. */ |
147 | |
|
148 | 0 | } /* igraphdnrm2_ */ |
149 | | |