3 #include "sll_assert.h"
4 #include "sll_memory.h"
5 #include "sll_working_precision.h"
26 sll_int32 :: index_gap
31 sll_real64,
dimension(:),
pointer :: wj
32 sll_real64,
dimension(:),
pointer :: wj_scale
33 sll_real64,
dimension(:),
pointer :: data_out
34 sll_int32 :: periodic_last
48 sll_int32,
intent(in) :: d, num_points, bc_type
49 sll_int32,
intent(in),
optional :: periodic_last
50 sll_real64 :: xmin, xmax
63 if (
present(periodic_last))
then
75 sll_int32,
dimension(1:4*lagrange%d - 2) :: table
76 sll_real64,
dimension(1:2*lagrange%d) :: wj
78 do i = 1, 2*lagrange%d - 1
79 table(i) = 2*lagrange%d - 1 - (i - 1)
80 table(i + 2*lagrange%d - 1) = i
85 do j = 1, 2*lagrange%d - 1
86 wj(i) = wj(i)*real(table(i + j - 1), f64)
88 wj(i) = ((-1.0_f64)**(lagrange%d + i))*wj(i)
91 wj(i + lagrange%d) = -wj(lagrange%d - i + 1)
102 sll_real64,
intent(in) :: alpha
103 sll_int32 ::i, j, index_gap
104 sll_real64 :: sum1, sum2, beta, h
105 sll_real64,
dimension(1:lagrange%nb_cell + 1),
intent(in) :: fi
107 lagrange%alpha = -alpha
111 index_gap = floor(lagrange%alpha/h)
112 beta = lagrange%alpha/h - real(index_gap, f64)
115 if (beta == 1.0_f64)
then
117 index_gap = index_gap + 1
121 if (beta == 0.0_f64)
then
122 select case (lagrange%bc_type)
123 case (sll_p_periodic)
124 do j = 1, lagrange%nb_cell + lagrange%periodic_last
125 lagrange%data_out(j) = fi(modulo(index_gap + j - 1, lagrange%nb_cell) + 1);
128 do j = 1, lagrange%nb_cell + 1
129 lagrange%data_out(j) = fi(min(max(1, index_gap + j), lagrange%nb_cell + 1));
136 do j = 1, 2*lagrange%d
137 lagrange%wj_scale(j) = lagrange%wj(j)/(beta + real(lagrange%d - j, f64))
138 sum2 = sum2 + lagrange%wj_scale(j)
141 select case (lagrange%bc_type)
142 case (sll_p_periodic)
144 do i = 1, lagrange%nb_cell + lagrange%periodic_last
146 do j = 1, lagrange%d*2
147 sum1 = sum1 + lagrange%wj_scale(j)*fi(modulo(index_gap + (i - 1) + (j - 1) - (lagrange%d - 1), lagrange%nb_cell) + 1)
149 lagrange%data_out(i) = sum1/sum2
154 do i = 1, lagrange%nb_cell + 1
156 do j = 1, lagrange%d*2
157 if (index_gap + (i - 1) + (j - 1) - (lagrange%d - 1) < 0)
then
158 sum1 = sum1 + lagrange%wj_scale(j)*fi(1)
159 else if (index_gap + (i - 1) + (j - 1) - (lagrange%d - 1) > lagrange%nb_cell)
then
160 sum1 = sum1 + lagrange%wj_scale(j)*fi(lagrange%nb_cell + 1)
162 sum1 = sum1 + lagrange%wj_scale(j)*fi(index_gap + (i - 1) + (j - 1) - (lagrange%d - 1) + 1)
165 lagrange%data_out(i) = sum1/sum2
169 print *,
'ERROR: sll_s_compute_lagrange_interpolation_1d(): not recognized boundary condition'
Describe different boundary conditions.
subroutine, public sll_s_cubic_spline_1d_eval_array(fi, alpha, lagrange)
This function computes the value at the grid points displacement by -alpha.
subroutine delete_lagrange_interpolation_1d(sll_m_lagrange_interpolation)
subroutine, public sll_s_compute_lagrange_interpolation_1d(lagrange)
This function computes the weights w_j for the barycentric formula.
type(sll_t_lagrange_interpolation_1d) function, pointer, public sll_f_new_lagrange_interpolation_1d(num_points, xmin, xmax, bc_type, d, periodic_last)