The Elk Code
 
Loading...
Searching...
No Matches
pade.f90
Go to the documentation of this file.
1
2! Copyright (C) A. Sanna and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6!BOP
7! !ROUTINE: pade
8! !INTERFACE:
9pure subroutine pade(ni,zi,ui,no,zo,uo)
10! !INPUT/OUTPUT PARAMETERS:
11! ni : number of input points (in,integer)
12! zi : input points (in,complex(ni))
13! ui : input function values (in,complex(ni))
14! no : number of output points (in,integer)
15! zo : output points (in,complex(no))
16! uo : output function values (out,complex(no))
17! !DESCRIPTION:
18! Calculates a Pad\'{e} approximant of a function, given the function
19! evaluated on a set of points in the complex plane. The function is returned
20! for a set of complex output points. The algorithm from H. J. Vidberg and
21! J. W. Serene {\it J. Low Temp. Phys.} {\bf 29}, 179 (1977) is used.
22!
23! !REVISION HISTORY:
24! Created December 2010 (Antonio Sanna)
25!EOP
26!BOC
27implicit none
28! arguments
29integer, intent(in) :: ni
30complex(8), intent(in) :: zi(ni),ui(ni)
31integer, intent(in) :: no
32complex(8), intent(in) :: zo(no)
33complex(8), intent(out) :: uo(no)
34! local variables
35integer i,i0,i1,j
36real(8) t1
37complex(8) a0,a1,b0,b1,z1,z2
38! automatic arrays
39complex(8) g(0:1,ni),gd(ni)
40! define the g functions using Eq. (A2)
41g(0,1:ni)=ui(1:ni)
42gd(1)=ui(1)
43do i=2,ni
44 i0=mod(i-2,2)
45 i1=mod(i-1,2)
46 do j=i,ni
47 z1=(zi(j)-zi(i-1))*g(i0,j)
48 if (abs(z1%re)+abs(z1%im) > 1.d-14) then
49 g(i1,j)=(g(i0,i-1)-g(i0,j))/z1
50 else
51 g(i1,j)=0.d0
52 end if
53 end do
54! store diagonal elements
55 gd(i)=g(i1,i)
56end do
57! loop over output points
58do i=1,no
59! use recursive algorithm in Eq. (A3) to evaluate function
60 a0=0.d0
61 a1=gd(1)
62 b0=1.d0
63 b1=1.d0
64 do j=2,ni
65 z1=(zo(i)-zi(j-1))*gd(j)
66 z2=a1+z1*a0
67 a0=a1
68 a1=z2
69 z2=b1+z1*b0
70 b0=b1
71 b1=z2
72! check for overflow and rescale
73 if ((abs(a1%re) > 1.d100).or.(abs(a1%im) > 1.d100)) then
74 t1=1.d0/abs(a1)
75 a0=a0*t1
76 b0=b0*t1
77 a1=a1*t1
78 b1=b1*t1
79 end if
80 if ((abs(b1%re) > 1.d100).or.(abs(b1%im) > 1.d100)) then
81 t1=1.d0/abs(b1)
82 a0=a0*t1
83 b0=b0*t1
84 a1=a1*t1
85 b1=b1*t1
86 end if
87 end do
88 if (abs(b1%re)+abs(b1%im) > 1.d-14) then
89 uo(i)=a1/b1
90 else
91 uo(i)=0.d0
92 end if
93end do
94end subroutine
95!EOC
96
pure subroutine pade(ni, zi, ui, no, zo, uo)
Definition pade.f90:10