perturb_x_and_compute_f_partitioned Subroutine

private subroutine perturb_x_and_compute_f_partitioned(me, x, dx_factor, dx, df_factor, columns, idx, df)

Perturb the specified optimization variable, and compute the function. This routine is designed so that df is accumulated as each function evaluation is done, to avoid having to allocate more temporary storage.

Type Bound

numdiff_type

Arguments

Type IntentOptional Attributes Name
class(numdiff_type), intent(inout) :: me
real(kind=wp), intent(in), dimension(:) :: x

nominal variable vector

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

factor to multiply dx

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

the perturbation value for this column

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

factor to multiply function value

integer, intent(in), dimension(:) :: columns

the variables to perturb

integer, intent(in), dimension(:) :: idx

the elements in this column of the Jacobian to compute (passed to function)

real(kind=wp), intent(inout), dimension(me%m) :: df

the accumulated function value note: for the first call, this should be set to zero


Called by

proc~~perturb_x_and_compute_f_partitioned~~CalledByGraph proc~perturb_x_and_compute_f_partitioned numerical_differentiation_module::numdiff_type%perturb_x_and_compute_f_partitioned proc~compute_jacobian_partitioned numerical_differentiation_module::compute_jacobian_partitioned proc~compute_jacobian_partitioned->proc~perturb_x_and_compute_f_partitioned

Source Code

    subroutine perturb_x_and_compute_f_partitioned(me,x,dx_factor,dx,&
                                       df_factor,columns,idx,df)

    implicit none

    class(numdiff_type),intent(inout) :: me
    real(wp),dimension(:),intent(in)  :: x         !! nominal variable vector
    real(wp),intent(in)               :: dx_factor !! factor to multiply `dx`
    real(wp),dimension(:),intent(in)  :: dx        !! the perturbation value for this column
    real(wp),intent(in)               :: df_factor !! factor to multiply function value
    integer,dimension(:),intent(in)   :: columns   !! the variables to perturb
    integer,dimension(:),intent(in)   :: idx       !! the elements in this
                                                   !! column of the Jacobian
                                                   !! to compute (passed to function)
    real(wp),dimension(me%m),intent(inout) :: df   !! the accumulated function value
                                                   !! note: for the first call, this
                                                   !! should be set to zero

    real(wp),dimension(me%n) :: xp  !! the perturbed variable vector
    real(wp),dimension(me%m) :: f   !! function evaluation

    if (me%exception_raised) return ! check for exceptions

    xp = x
    if (dx_factor/=zero) xp(columns) = xp(columns) + dx_factor * dx(columns)
    call me%compute_function(xp,f,idx)
    if (me%exception_raised) return ! check for exceptions
    df(idx) = df(idx) + df_factor * f(idx)

    end subroutine perturb_x_and_compute_f_partitioned