EFTCAMB  Reference documentation for version 3.0
02_interpolation.f90
Go to the documentation of this file.
1 !----------------------------------------------------------------------------------------
2 !
3 ! This file is part of EFTCAMB.
4 !
5 ! Copyright (C) 2013-2016 by the EFTCAMB authors
6 !
7 ! The EFTCAMB code is free software;
8 ! You can use it, redistribute it, and/or modify it under the terms
9 ! of the GNU General Public License as published by the Free Software Foundation;
10 ! either version 3 of the License, or (at your option) any later version.
11 ! The full text of the license can be found in the file eftcamb/LICENSE at
12 ! the top level of the EFTCAMB distribution.
13 !
14 !----------------------------------------------------------------------------------------
15 
18 
19 
20 !----------------------------------------------------------------------------------------
22 
24 
26 
27  use precision
28 
29  implicit none
30 
31  private
32 
33  public polint
34 
35 contains
36 
37  ! ---------------------------------------------------------------------------------------------
39  subroutine polint( n, xa, ya, xpl, ypl, dypl )
40 
41  implicit none
42 
43  integer , intent(in) :: n
44  real(dl), intent(in) :: xa(n)
45  real(dl), intent(in) :: ya(n)
46  real(dl), intent(in) :: xpl
47  real(dl), intent(out) :: ypl
48  real(dl), intent(out) :: dypl
49 
50  integer :: i,m,ns
51  real(dl) :: den,dif,dift,ho,hp,wpl,cc(n),d(n)
52 
53  ns = 1
54  dif = abs( xpl-xa(1) )
55  do i=1,n
56  dift=abs(xpl-xa(i))
57  if (dift<dif) then
58  ns=i
59  dif=dift
60  endif
61  cc(i)=ya(i)
62  d(i)=ya(i)
63  end do
64  ypl = ya(ns)
65  ns = ns -1
66  do m=1, n-1
67  do i=1, n-m
68  ho = xa(i)-xpl
69  hp = xa(i+m)-xpl
70  wpl = cc(i+1)-d(i)
71  den = ho-hp
72  if (den==0.) then
73  write(*,*) 'failure in polint'
74  stop
75  end if
76  den = wpl/den
77  d(i) = hp*den
78  cc(i) = ho*den
79  end do
80  if (2*ns<n-m) then
81  dypl=cc(ns+1)
82  else
83  dypl=d(ns)
84  ns=ns-1
85  endif
86  ypl=ypl+dypl
87  end do
88 
89  return
90 
91  end subroutine polint
92 
93 end module eftcamb_interpolation
94 
95 !----------------------------------------------------------------------------------------
subroutine, public polint(n, xa, ya, xpl, ypl, dypl)
Neville interpolator: computes polynomial interpolation of a set of points.
This module contains the definitions of all the EFTCAMB interpolation algorithms. ...