src/liblinear/blas/dnrm2.c

filter: Statementstmt 90.0% 18 / 20 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 81.2% 26 / 32 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« src/liblinear/blas/dscal.c ↑ Summary blib/lib/Algorithm/LibLinear/Types.pm »
1 #include <math.h> /* Needed for fabs() and sqrt() */
2 #include "blas.h"
3  
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7  
8 215 double dnrm2_(int *n, double *x, int *incx)
9 {
10 long int ix, nn, iincx;
11 double norm, scale, absxi, ssq, temp;
12  
13 /* DNRM2 returns the euclidean norm of a vector via the function
14 name, so that
15  
16 DNRM2 := sqrt( x'*x )
17  
18 -- This version written on 25-October-1982.
19 Modified on 14-October-1993 to inline the call to SLASSQ.
20 Sven Hammarling, Nag Ltd. */
21  
22 /* Dereference inputs */
23 215 nn = *n;
24 215 iincx = *incx;
25  
26 215 ▶ if( nn > 0 && iincx > 0 )
Branch: 2 branches
BranchTrueFalseTotal
if( nn > 0 && iincx > 0 ) 215 0 215
if( nn > 0 && iincx > 0 ) 215 0 215
27 {
28 215 ▶ if (nn == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (nn == 1) 0 215 215
29 {
30 0 norm = fabs(x[0]);
31 }
32 else
33 {
34 215 scale = 0.0;
35 215 ssq = 1.0;
36  
37 /* The following loop is equivalent to this call to the LAPACK
38 auxiliary routine: CALL SLASSQ( N, X, INCX, SCALE, SSQ ) */
39  
40 3010 ▶ for (ix=(nn-1)*iincx; ix>=0; ix-=iincx)
Branch: 1 branch
BranchTrueFalseTotal
for (ix=(nn-1)*iincx; ix>=0; ix-=iincx) 2795 215 3010
41 {
42 2795 ▶ if (x[ix] != 0.0)
Branch: 1 branch
BranchTrueFalseTotal
if (x[ix] != 0.0) 2795 0 2795
43 {
44 2795 absxi = fabs(x[ix]);
45 2795 ▶ if (scale < absxi)
Branch: 1 branch
BranchTrueFalseTotal
if (scale < absxi) 390 2405 2795
46 {
47 390 temp = scale / absxi;
48 390 ssq = ssq * (temp * temp) + 1.0;
49 390 scale = absxi;
50 }
51 else
52 {
53 2405 temp = absxi / scale;
54 2405 ssq += temp * temp;
55 }
56 }
57 }
58 215 norm = scale * sqrt(ssq);
59 }
60 }
61 else
62 0 norm = 0.0;
63  
64 215 return norm;
65  
66 } /* dnrm2_ */
67  
68 #ifdef __cplusplus
69 }
70 #endif
« src/liblinear/blas/dscal.c ↑ Summary blib/lib/Algorithm/LibLinear/Types.pm »