1 double precision function enorm
(n
,x
)
8 c given an n-vector x, this function calculates the
11 c the euclidean norm is computed by accumulating the sum of
12 c squares in three different sums. the sums of squares for the
13 c small and large components are scaled so that no overflows
14 c occur. non-destructive underflows are permitted. underflows
15 c and overflows do not occur in the computation of the unscaled
16 c sum of squares for the intermediate components.
17 c the definitions of small, intermediate and large components
18 c depend on two constants, rdwarf and rgiant. the main
19 c restrictions on these constants are that rdwarf**2 not
20 c underflow and rgiant**2 not overflow. the constants
21 c given here are suitable for every known computer.
23 c the function statement is
25 c double precision function enorm(n,x)
29 c n is a positive integer input variable.
31 c x is an input array of length n.
35 c fortran-supplied ... dabs,dsqrt
37 c argonne national laboratory. minpack project. march 1980.
38 c burton s. garbow, kenneth e. hillstrom, jorge j. more
42 double precision agiant
,floatn
,one
,rdwarf
,rgiant
,s1
,s2
,s3
,xabs
,
44 data one
,zero
,rdwarf
,rgiant
/1.0d0
,0.0d0
,3.834d
-20,1.304d19
/
51 agiant
= rgiant
/floatn
54 if (xabs
.gt
. rdwarf
.and
. xabs
.lt
. agiant
) go to 70
55 if (xabs
.le
. rdwarf
) go to 30
57 c sum for large components.
59 if (xabs
.le
. x1max
) go to 10
60 s1
= one
+ s1*
(x1max
/xabs
)**2
64 s1
= s1
+ (xabs
/x1max
)**2
69 c sum for small components.
71 if (xabs
.le
. x3max
) go to 40
72 s3
= one
+ s3*
(x3max
/xabs
)**2
76 if (xabs
.ne
. zero
) s3
= s3
+ (xabs
/x3max
)**2
82 c sum for intermediate components.
88 c calculation of norm.
90 if (s1
.eq
. zero
) go to 100
91 enorm
= x1max*dsqrt
(s1
+(s2
/x1max
)/x1max
)
94 if (s2
.eq
. zero
) go to 110
96 * enorm
= dsqrt
(s2*
(one
+(x3max
/s2
)*(x3max*s3
)))
98 * enorm
= dsqrt
(x3max*
((s2
/x3max
)+(x3max*s3
)))
101 enorm
= x3max*dsqrt
(s3
)
106 c last card of function enorm.