The Elk Code
Loading...
Searching...
No Matches
factr.f90
Go to the documentation of this file.
1
2
! Copyright (C) 2002-2005 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3
! This file is distributed under the terms of the GNU Lesser General Public
4
! License. See the file COPYING for license details.
5
6
!BOP
7
! !ROUTINE: factr
8
! !INTERFACE:
9
real(8)
function
factr
(n,d)
10
! !INPUT/OUTPUT PARAMETERS:
11
! n : numerator (in,integer)
12
! d : denominator (in,integer)
13
! !DESCRIPTION:
14
! Returns the ratio $n!/d!$ for $n,d\ge 0$. Performs no under- or overflow
15
! checking.
16
!
17
! !REVISION HISTORY:
18
! Created October 2002 (JKD)
19
!EOP
20
!BOC
21
implicit none
22
! arguments
23
integer
,
intent(in)
:: n,d
24
! local variables
25
integer
i
26
! external functions
27
real
(8),
external
::
factn
28
if
(d == 1)
then
29
factr
=
factn
(n)
30
return
31
end if
32
if
((n < 0).or.(d < 0))
then
33
factr
=0.d0
34
return
35
end if
36
if
(n < d)
then
37
factr
=dble(n+1)
38
do
i=n+2,d
39
factr
=
factr
*dble(i)
40
end do
41
factr
=1.d0/
factr
42
else
if
(n == d)
then
43
factr
=1.d0
44
else
45
factr
=dble(d+1)
46
do
i=d+2,n
47
factr
=
factr
*dble(i)
48
end do
49
end if
50
end function
51
!EOC
52
factn
elemental real(8) function factn(n)
Definition
factn.f90:7
factr
real(8) function factr(n, d)
Definition
factr.f90:10
factr.f90
Generated by
1.9.8