39 INTEGER ,
INTENT(in ) :: n
40 REAL(kind_real),
INTENT( out) :: q(n)
41 REAL(kind_real),
INTENT(in ) :: x(n)
48 IF(j /= i)q(i)=q(i)/(x(i)-x(j))
59 INTEGER ,
INTENT(in ) :: n
60 REAL(kind_real),
DIMENSION(n),
INTENT( out) :: q,q_tl
61 REAL(kind_real),
DIMENSION(n),
INTENT(in ) :: x,x_tl
64 REAL(kind_real) :: rat
72 q_tl(i)=(q_tl(i)-q(i)*(x_tl(i)-x_tl(j))*rat)*rat
85 INTEGER ,
INTENT(in ) :: n
86 REAL(kind_real),
DIMENSION(n),
INTENT(in ) :: x
87 REAL(kind_real),
DIMENSION(n),
INTENT(inout) :: x_ad
88 REAL(kind_real),
DIMENSION(n),
INTENT(inout) :: q_ad
91 REAL(kind_real),
DIMENSION(n) :: q
92 REAL(kind_real),
DIMENSION(n,n) :: jac
99 jac(j,i)=q(i)/(x(i)-x(j))
100 jac(i,i)=jac(i,i)-jac(j,i)
104 x_ad=x_ad+matmul(jac,q_ad)
125 INTEGER ,
INTENT(IN ) :: n
126 REAL(kind_real) ,
INTENT(IN ) :: xt
127 REAL(kind_real),
INTENT(IN ) :: x(n),q(n)
128 REAL(kind_real),
INTENT( OUT) :: w(n),dw(n)
130 REAL(kind_real) :: d(n),pa(n),pb(n),dpa(n),dpb(n)
138 dpa(j+1)=dpa(j)*d(j)+pa(j)
146 dpb(j-1)=dpb(j)*d(j)+pb(j)
149 w(j)= pa(j)*pb(j)*q(j)
150 dw(j)=(pa(j)*dpb(j)+dpa(j)*pb(j))*q(j)
160 INTEGER ,
INTENT(IN ) :: n
161 REAL(kind_real) ,
INTENT(IN ) :: xt
162 REAL(kind_real),
DIMENSION(n),
INTENT(IN ) :: x,q,x_tl,q_tl
163 REAL(kind_real),
DIMENSION(n),
INTENT( OUT) :: w,dw,w_tl,dw_tl
165 REAL(kind_real),
DIMENSION(n) :: d,pa,pb,dpa,dpb
166 REAL(kind_real),
DIMENSION(n) :: d_tl,pa_tl,pb_tl,dpa_tl,dpb_tl
178 pa_tl(j+1)=pa_tl(j)*d(j)+pa(j)*d_tl(j)
179 dpa(j+1)=dpa(j)*d(j)+pa(j)
180 dpa_tl(j+1)=dpa_tl(j)*d(j)+dpa(j)*d_tl(j)+pa_tl(j)
191 pb_tl(j-1)=pb_tl(j)*d(j)+pb(j)*d_tl(j)
192 dpb(j-1)=dpb(j)*d(j)+pb(j)
193 dpb_tl(j-1)=dpb_tl(j)*d(j)+dpb(j)*d_tl(j)+pb_tl(j)
196 w(j)= pa(j)*pb(j)*q(j)
197 dw(j)=(pa(j)*dpb(j)+dpa(j)*pb(j))*q(j)
198 w_tl(j)=(pa_tl(j)*pb(j)+pa(j)*pb_tl(j))*q(j)+pa(j)*pb(j)*q_tl(j)
199 dw_tl(j)=(pa_tl(j)*dpb(j)+pa(j)*dpb_tl(j)+dpa_tl(j)*pb(j)+dpa(j)*pb_tl(j))*q(j)+ &
200 (pa(j)*dpb(j)+dpa(j)*pb(j))*q_tl(j)
211 INTEGER ,
INTENT(IN ) :: n
212 REAL(kind_real) ,
INTENT(IN ) :: xt
213 REAL(kind_real),
DIMENSION(n),
INTENT(IN ) :: x,q
214 REAL(kind_real),
DIMENSION(n),
INTENT(INOUT) :: q_ad,x_ad,w_ad,dw_ad
216 REAL(kind_real),
DIMENSION(n) :: d,pa,pb,dpa,dpb
217 REAL(kind_real),
DIMENSION(n) :: d_ad,pa_ad,pb_ad,dpa_ad,dpb_ad
230 dpa(j+1)=dpa(j)*d(j)+pa(j)
237 dpb(j-1)=dpb(j)*d(j)+pb(j)
241 pa_ad(j)=pa_ad(j)+ dpb(j)*q(j)*dw_ad(j)
242 dpb_ad(j)=dpb_ad(j)+ pa(j)*q(j)*dw_ad(j)
243 dpa_ad(j)=dpa_ad(j)+ pb(j)*q(j)*dw_ad(j)
244 pb_ad(j)=pb_ad(j)+ dpa(j)*q(j)*dw_ad(j)
245 q_ad(j)=q_ad(j)+(pa(j)*dpb(j)+dpa(j)*pb(j))*dw_ad(j)
246 pa_ad(j)=pa_ad(j)+ pb(j)*q(j)*w_ad(j)
247 pb_ad(j)=pb_ad(j)+ pa(j)*q(j)*w_ad(j)
248 q_ad(j)=q_ad(j)+ pa(j)*pb(j)*w_ad(j)
251 dpb_ad(j)=dpb_ad(j)+d(j)*dpb_ad(j-1)
252 d_ad(j)=d_ad(j)+dpb(j)*dpb_ad(j-1)
253 pb_ad(j)=pb_ad(j) +dpb_ad(j-1)
254 pb_ad(j)=pb_ad(j)+d(j)*pb_ad(j-1)
255 d_ad(j)=d_ad(j)+pb(j)*pb_ad(j-1)
261 x_ad(n)=x_ad(n)-d_ad(n)
263 dpa_ad(j)=dpa_ad(j)+d(j)*dpa_ad(j+1)
264 d_ad(j)=d_ad(j)+dpa(j)*dpa_ad(j+1)
265 pa_ad(j)=pa_ad(j) +dpa_ad(j+1)
266 pa_ad(j)=pa_ad(j)+d(j)*pa_ad(j+1)
267 d_ad(j)=d_ad(j)+pa(j)*pa_ad(j+1)
268 x_ad(j)=x_ad(j) -d_ad(j )
289 INTEGER ,
INTENT(IN ) :: n
290 REAL(kind_real) ,
INTENT(IN ) :: xt
291 REAL(kind_real),
INTENT(IN ) :: x(n)
292 REAL(kind_real),
INTENT(IN ) :: aq(n-1),bq(n-1)
293 REAL(kind_real),
INTENT( OUT) :: w(n),dw(n)
295 REAL(kind_real) :: aw(n),bw(n),daw(n),dbw(n)
296 REAL(kind_real) :: xa,xb,dwb,wb
306 IF(na*2 /= n)stop
'In lag_interp_smthWeights; n must be even' 331 INTEGER ,
INTENT(IN ) :: n
332 REAL(kind_real) ,
INTENT(IN ) :: xt
333 REAL(kind_real),
DIMENSION(n) ,
INTENT(IN ) :: x,x_tl
334 REAL(kind_real),
DIMENSION(n-1),
INTENT(IN ) :: aq,bq,aq_tl,bq_tl
335 REAL(kind_real),
DIMENSION(n) ,
INTENT( OUT) :: dw_tl,dw
337 REAL(kind_real),
DIMENSION(n) :: aw,bw,daw,dbw
338 REAL(kind_real),
DIMENSION(n) :: aw_tl,bw_tl,daw_tl,dbw_tl
339 REAL(kind_real) :: xa,xb,dwb,wb
340 REAL(kind_real) :: xa_tl,xb_tl,dwb_tl,wb_tl
344 daw(1:n-1),daw_tl(1:n-1),n-1)
346 dbw(2:n ),dbw_tl(2:n ),n-1)
357 IF(na*2 /= n)stop
'In lag_interp_smthWeights; n must be even' 363 dwb_tl=-(xb_tl-xa_tl)/(xb-xa)**2
365 wb_tl=(-xa_tl)*dwb+(xt-xa)*dwb_tl
371 ELSEIF(wb <
zero)
THEN 385 dw =daw + wb *dbw + dwb *bw
386 dw_tl=daw_tl+(wb_tl*dbw+wb*dbw_tl)+(dwb_tl*bw+dwb*bw_tl)
391 SUBROUTINE lag_interp_smthweights_ad(x,x_AD,xt,aq,aq_AD,bq,bq_AD,w_AD,dw,dw_AD,n)
393 INTEGER ,
INTENT(IN ) :: n
394 REAL(kind_real) ,
INTENT(IN ) :: xt
395 REAL(kind_real) ,
INTENT(IN ) :: x(n)
396 REAL(kind_real),
INTENT(IN ) :: aq(n-1),bq(n-1)
397 REAL(kind_real),
INTENT(INOUT) :: aq_ad(n-1),bq_ad(n-1)
398 REAL(kind_real),
INTENT( OUT) :: dw(n)
399 REAL(kind_real),
INTENT(INOUT) :: x_ad(n),dw_ad(n),w_ad(n)
401 REAL(kind_real) :: aw(n),bw(n),daw(n),dbw(n)
402 REAL(kind_real) :: aw_ad(n),bw_ad(n),daw_ad(n),dbw_ad(n)
403 REAL(kind_real) :: xa,xb,dwb,wb
404 REAL(kind_real) :: xa_ad,xb_ad,wb_ad,dwb_ad
419 IF(na*2 /= n)stop
'In lag_interp_smthWeights; n must be even' 438 wb_ad =wb_ad +dot_product(dbw,dw_ad)
439 dbw_ad=dbw_ad+wb*dw_ad
440 dwb_ad=dwb_ad+dot_product(bw,dw_ad)
441 bw_ad =bw_ad +dwb*dw_ad
444 wb_ad=wb_ad+dot_product(bw,w_ad)
458 xa_ad =xa_ad-wb_ad*dwb
459 dwb_ad =dwb_ad+(xt-xa)*wb_ad
460 xb_ad =xb_ad-(dwb_ad/(xb-xa)**2)
461 xa_ad =xa_ad+(dwb_ad/(xb-xa)**2)
462 x_ad(na+1)=x_ad(na+1)+xb_ad
463 x_ad(na )=x_ad(na )+xa_ad
subroutine, public lag_interp_weights_ad(x, x_AD, xt, q, q_AD, w_AD, dw_AD, n)
real(fp), parameter, public zero
subroutine, public lag_interp_smthweights(x, xt, aq, bq, w, dw, n)
subroutine, public lag_interp_const_tl(q, q_TL, x, x_TL, n)
Fortran module to prepare for Lagrange polynomial interpolation. based on GSI: lagmod.f90.
real(fp), parameter, public one
subroutine, public lag_interp_weights_tl(x, x_TL, xt, q, q_TL, w, w_TL, dw, dw_TL, n)
subroutine, public lag_interp_smthweights_ad(x, x_AD, xt, aq, aq_AD, bq, bq_AD, w_AD, dw, dw_AD, n)
subroutine, public lag_interp_const(q, x, n)
subroutine, public lag_interp_const_ad(q_AD, x, x_AD, n)
integer, parameter, public kind_real
subroutine, public lag_interp_weights(x, xt, q, w, dw, n)
subroutine, public lag_interp_smthweights_tl(x, x_TL, xt, aq, aq_TL, bq, bq_TL, dw, dw_TL, n)