-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhfunc.f90
42 lines (34 loc) · 928 Bytes
/
hfunc.f90
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
DOUBLE PRECISION FUNCTION hfunc( x )
!
implicit none
!
DOUBLE PRECISION :: x
!
! Purpose
! ============
! This function is used to compute the parameter ak in QDWH algorithm.
!
! =====================
! Written by Shengguo Li, NUDT, China.
! =============================
!
DOUBLE PRECISION, PARAMETER :: FOUR=4.0D+0, EIGHT=8.0D+0, TWO=2.0D+0, &
ONE = 1.0D+0, THREE=3.0D+0, ZERO=0.0D+0
DOUBLE PRECISION :: tmp, ww, sum1, x2, eps, tol
!
INTRINSIC :: SQRT
DOUBLE PRECISION, EXTERNAL :: DLAMCH
!
EPS = DLAMCH('Precision');
TOL = 30*EPS
x2 = x*x
if ( abs(x-one) .le. Tol ) then
ww = ZERO
else
tmp = four*(ONE - x2) / (x2*x2)
ww = EXP( LOG( tmp )/ THREE )
endif
sum1 = SQRT( ONE+ ww )
hfunc = SQRT( EIGHT-FOUR*ww + EIGHT*(TWO-x2)/(x2*sum1) )
hfunc = sum1+ hfunc / TWO
END FUNCTION hfunc