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:
9real(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
21implicit none
22! arguments
23integer, intent(in) :: n,d
24! local variables
25integer i
26! external functions
27real(8), external :: factn
28if (d == 1) then
29 factr=factn(n)
30 return
31end if
32if ((n < 0).or.(d < 0)) then
33 factr=0.d0
34 return
35end if
36if (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
42else if (n == d) then
43 factr=1.d0
44else
45 factr=dble(d+1)
46 do i=d+2,n
47 factr=factr*dble(i)
48 end do
49end if
50end function
51!EOC
52
elemental real(8) function factn(n)
Definition factn.f90:7
real(8) function factr(n, d)
Definition factr.f90:10