db2val_multi Subroutine

private pure subroutine db2val_multi(xval, yval, idx, idy, tx, ty, nx, ny, kx, ky, bcoef, f, iflag, inbvx, iloy, w1, extrap)

Multiple-output version of db2val: evaluates all nf outputs of a spline from db2ink (multiple-output version) at one point. The interval search and the basis functions in each direction are only computed once, for all of the outputs.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: xval

coordinate of evaluation point.

real(kind=wp), intent(in) :: yval

coordinate of evaluation point.

integer(kind=ip), intent(in) :: idx

derivative of piecewise polynomial to evaluate.

integer(kind=ip), intent(in) :: idy

derivative of piecewise polynomial to evaluate.

real(kind=wp), intent(in), dimension(nx+kx) :: tx

knots in the direction.

real(kind=wp), intent(in), dimension(ny+ky) :: ty

knots in the direction.

integer(kind=ip), intent(in) :: nx

the number of interpolation points in .

integer(kind=ip), intent(in) :: ny

the number of interpolation points in .

integer(kind=ip), intent(in) :: kx

order of polynomial pieces in .

integer(kind=ip), intent(in) :: ky

order of polynomial pieces in .

real(kind=wp), intent(in), dimension(:,:,:) :: bcoef

(nx,ny,nf) b-spline coefficients from db2ink (multiple-output version).

real(kind=wp), intent(out), dimension(:) :: f

(nf) interpolated values of the outputs

integer(kind=ip), intent(out) :: iflag

status flag:

  • : no errors
  • 6002: size(f) is not the number of outputs
  • 6004: the leading dimensions of bcoef are not (nx,ny)
  • other : error (see db2val)
integer(kind=ip), intent(inout) :: inbvx

initialization parameter which must be set to 1 the first time this routine is called, and must not be changed by the user.

integer(kind=ip), intent(inout) :: iloy

initialization parameter which must be set to 1 the first time this routine is called, and must not be changed by the user.

real(kind=wp), intent(inout), dimension(ky) :: w1

work array of dimension (ky)

logical, intent(in), optional :: extrap

if extrapolation is allowed (if not present, default is False)


Calls

proc~~db2val_multi~~CallsGraph proc~db2val_multi db2val_multi proc~check_value check_value proc~db2val_multi->proc~check_value proc~dbvalu_weights dbvalu_weights proc~db2val_multi->proc~dbvalu_weights proc~dintrv dintrv proc~dbvalu_weights->proc~dintrv proc~get_temp_x_for_extrap get_temp_x_for_extrap proc~dintrv->proc~get_temp_x_for_extrap

Called by

proc~~db2val_multi~~CalledByGraph proc~db2val_multi db2val_multi interface~db2val db2val interface~db2val->proc~db2val_multi proc~evaluate_2d bspline_2d%evaluate_2d proc~evaluate_2d->interface~db2val proc~evaluate_2d_multi bspline_2d%evaluate_2d_multi proc~evaluate_2d_multi->interface~db2val

Source Code

    pure subroutine db2val_multi(xval,yval,idx,idy,tx,ty,nx,ny,kx,ky,bcoef,f,iflag,inbvx,iloy,w1,extrap)

    implicit none

    real(wp),intent(in)                 :: xval   !! \(x\) coordinate of evaluation point.
    real(wp),intent(in)                 :: yval   !! \(y\) coordinate of evaluation point.
    integer(ip),intent(in)              :: idx    !! \(x\) derivative of piecewise polynomial to evaluate.
    integer(ip),intent(in)              :: idy    !! \(y\) derivative of piecewise polynomial to evaluate.
    integer(ip),intent(in)              :: nx     !! the number of interpolation points in \(x\).
    integer(ip),intent(in)              :: ny     !! the number of interpolation points in \(y\).
    integer(ip),intent(in)              :: kx     !! order of polynomial pieces in \(x\).
    integer(ip),intent(in)              :: ky     !! order of polynomial pieces in \(y\).
    real(wp),dimension(nx+kx),intent(in) :: tx !! knots in the \(x\) direction.
    real(wp),dimension(ny+ky),intent(in) :: ty !! knots in the \(y\) direction.
    real(wp),dimension(:,:,:),intent(in) :: bcoef  !! `(nx,ny,nf)` b-spline coefficients
                                                  !! from [[db2ink]] (multiple-output version).
    real(wp),dimension(:),intent(out)   :: f      !! `(nf)` interpolated values of the outputs
    integer(ip),intent(out)             :: iflag  !! status flag:
                                                  !!
                                                  !! * \( = 0 \)   : no errors
                                                  !! * 6002: `size(f)` is not the number of outputs
                                                  !! * 6004: the leading dimensions of `bcoef` are not `(nx,ny)`
                                                  !! * other \( \ne 0 \) : error (see [[db2val]])
    integer(ip),intent(inout)           :: inbvx  !! initialization parameter which must be
                                                  !! set to 1 the first time this routine is called,
                                                  !! and must not be changed by the user.
    integer(ip),intent(inout)           :: iloy   !! initialization parameter which must be
                                                  !! set to 1 the first time this routine is called,
                                                  !! and must not be changed by the user.
    logical,intent(in),optional         :: extrap !! if extrapolation is allowed
                                                  !! (if not present, default is False)

    integer(ip) :: leftx  !! interval index in \(x\)
    integer(ip) :: lefty  !! interval index in \(y\)
    integer(ip) :: ix     !! coefficient offset in \(x\)
    integer(ip) :: iy     !! coefficient offset in \(y\)
    real(wp),dimension(kx) :: bx  !! basis function weights in \(x\)
    real(wp),dimension(ky) :: by  !! basis function weights in \(y\)
    real(wp),dimension(ky),intent(inout) :: w1  !! work array of dimension `(ky)`
    integer(ip) :: j  !! counter in \(y\)
    integer(ip) :: jf  !! output index

    f = 0.0_wp

    if (size(f,kind=ip)/=size(bcoef,3,kind=ip)) then
        iflag = 6002_ip
        return
    end if
    if (size(bcoef,1,kind=ip)/=nx .or. &
        size(bcoef,2,kind=ip)/=ny) then
        iflag = 6004_ip
        return
    end if

    iflag = check_value(xval,tx,1_ip,extrap); if (iflag/=0_ip) return
    iflag = check_value(yval,ty,2_ip,extrap); if (iflag/=0_ip) return

    ! interval and basis function weights in each direction (once for all outputs)
    call dbvalu_weights(tx,nx,kx,idx,xval,inbvx,leftx,bx,iflag,extrap)
    if (iflag/=0_ip) return
    call dbvalu_weights(ty,ny,ky,idy,yval,iloy,lefty,by,iflag,extrap)
    if (iflag/=0_ip) return

    ix = leftx - kx
    iy = lefty - ky

    do jf = 1_ip, size(f,kind=ip)
        ! contract the coefficients one direction at a time
        do j=1_ip,ky
            w1(j) = dot_product(bx,bcoef(ix+1_ip:leftx,iy+j,jf))
        end do
        f(jf) = dot_product(by,w1)
    end do

    end subroutine db2val_multi