Skip to content

Commit b474a13

Browse files
committed
add a method to change the dpert array after initialization
1 parent ed7529b commit b474a13

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/numerical_differentiation_module.f90

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ module numerical_differentiation_module
222222

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

226227
! internal routines:
227228
procedure :: destroy_sparsity_pattern !! destroy the sparsity pattern
@@ -1260,6 +1261,26 @@ subroutine set_numdiff_sparsity_bounds(me,xlow,xhigh)
12601261
end subroutine set_numdiff_sparsity_bounds
12611262
!*******************************************************************************
12621263

1264+
!*******************************************************************************
1265+
!>
1266+
! Change the `dpert` vector. Can be used after the class has been initialized
1267+
! to change the perturbation step sizes (e.g., after an iteration).
1268+
1269+
subroutine set_dpert(me,dpert)
1270+
1271+
class(numdiff_type),intent(inout) :: me
1272+
real(wp),dimension(:),intent(in) :: dpert !! perturbation vector for `x`
1273+
1274+
if (size(dpert)/=me%n) then
1275+
call me%raise_exception(29,'set_dpert',&
1276+
'incorrect size of dpert array')
1277+
else
1278+
me%dpert = abs(dpert) ! update
1279+
end if
1280+
1281+
end subroutine set_dpert
1282+
!*******************************************************************************
1283+
12631284
!*******************************************************************************
12641285
!>
12651286
! Initialize a [[numdiff_type]] class. This must be called first.

0 commit comments

Comments
 (0)