Skip to content

Commit

Permalink
add a method to change the dpert array after initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwilliams committed Feb 26, 2024
1 parent ed7529b commit b474a13
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/numerical_differentiation_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ module numerical_differentiation_module

procedure,public :: failed !! to check if an exception was raised.
procedure,public :: get_error_status !! the status of error condition
procedure,public :: set_dpert !! change the `dpert` values

! internal routines:
procedure :: destroy_sparsity_pattern !! destroy the sparsity pattern
Expand Down Expand Up @@ -1260,6 +1261,26 @@ subroutine set_numdiff_sparsity_bounds(me,xlow,xhigh)
end subroutine set_numdiff_sparsity_bounds
!*******************************************************************************

!*******************************************************************************
!>
! Change the `dpert` vector. Can be used after the class has been initialized
! to change the perturbation step sizes (e.g., after an iteration).

subroutine set_dpert(me,dpert)

class(numdiff_type),intent(inout) :: me
real(wp),dimension(:),intent(in) :: dpert !! perturbation vector for `x`

if (size(dpert)/=me%n) then
call me%raise_exception(29,'set_dpert',&
'incorrect size of dpert array')
else
me%dpert = abs(dpert) ! update
end if

end subroutine set_dpert
!*******************************************************************************

!*******************************************************************************
!>
! Initialize a [[numdiff_type]] class. This must be called first.
Expand Down

0 comments on commit b474a13

Please sign in to comment.