Evaluate derivative at x of all basis functions with support in local cell derivs[j] = B_j'(x) for jmin <= j <= jmin+degree
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(sll_t_bsplines_uniform), | intent(in) | :: | self |
uniform B-splines |
||
| real(kind=wp), | intent(in) | :: | x |
evaluation point |
||
| real(kind=wp), | intent(out) | :: | derivs(0:) | |||
| integer, | intent(out) | :: | jmin |
index of first non-zero B-spline |
SLL_PURE subroutine s_bsplines_uniform__eval_deriv( self, x, derivs, jmin ) class(sll_t_bsplines_uniform), intent(in ) :: self real(wp) , intent(in ) :: x real(wp) , intent( out) :: derivs(0:) integer , intent( out) :: jmin integer :: icell real(wp) :: x_offset integer :: j, r real(wp) :: j_real real(wp) :: xx real(wp) :: temp real(wp) :: saved real(wp) :: bj, bjm1 ! Check on inputs SLL_ASSERT( size(derivs) == 1+self%degree ) ! 1. Compute cell index 'icell' and x_offset call s_bsplines_uniform__get_icell_and_offset( self, x, icell, x_offset ) ! 2. Compute index range of B-splines with support over cell 'icell' jmin = icell - self%offset ! 3. Compute derivatives of aforementioned B-splines ! Derivatives are normalized, hence they should be divided by dx associate( bspl => derivs, spline_degree => self%degree, start => self%inv_dx ) ! only need splines of lower degree to compute derivatives bspl(0) = start do j = 1, spline_degree - 1 j_real = real(j,wp) xx = -x_offset saved = 0.0_wp do r = 0, j-1 xx = xx + 1.0_wp temp = bspl(r) * inv(j) bspl(r) = saved + xx * temp saved = (j_real - xx) * temp end do bspl(j) = saved end do ! compute derivatives bjm1 = bspl(0) bj = bjm1 bspl(0) = -bjm1 do j=1, spline_degree - 1 bj = bspl(j) bspl(j) = bjm1 - bj bjm1 = bj end do bspl(spline_degree) = bj end associate ! bspl, spline_degree end subroutine s_bsplines_uniform__eval_deriv