@@ -453,14 +453,20 @@ end subroutine get_finite_diff_formula
453453! * \( (-f(x-3h)+6f(x-2h)-18f(x-h)+10f(x)+3f(x+h)) / (12h) \)
454454! * \( (-25f(x)+48f(x+h)-36f(x+2h)+16f(x+3h)-3f(x+4h)) / (12h) \)
455455! * \( (3f(x-4h)-16f(x-3h)+36f(x-2h)-48f(x-h)+25f(x)) / (12h) \)
456+ ! * \( (3f(x-2h)-30f(x-h)-20f(x)+60f(x+h)-15f(x+2h)+2f(x+3h)) / (60h) ])
457+ ! * \( (-2f(x-3h)+15f(x-2h)-60f(x-h)+20f(x)+30f(x+h)-3f(x+2h)) / (60h) ])
458+ ! * \( (-12f(x-h)-65f(x)+120f(x+h)-60f(x+2h)+20f(x+3h)-3f(x+4h)) / (60h) ])
459+ ! * \( (3f(x-4h)-20f(x-3h)+60f(x-2h)-120f(x-h)+65f(x)+12f(x+h)) / (60h) ])
460+ ! * \( (-137f(x)+300f(x+h)-300f(x+2h)+200f(x+3h)-75f(x+4h)+12f(x+5h)) / (60h) ])
461+ ! * \( (-12f(x-5h)+75f(x-4h)-200f(x-3h)+300f(x-2h)-300f(x-h)+137f(x)) / (60h) ])
456462!
457463! Where \(f(x)\) is the user-defined function of \(x\)
458464! and \(h\) is a "small" perturbation.
459465!
460466! @note This is the only routine that has to be changed if a new
461467! finite difference method is added.
462468!
463- ! @note The order within a class is assumed to be the order that we would perfer
469+ ! @note The order within a class is assumed to be the order that we would prefer
464470! to use them (e.g., central diffs are first, etc.) This is used in
465471! the [[select_finite_diff_method]] routine.
466472
@@ -469,7 +475,8 @@ subroutine get_finite_difference_method(id,fd,found)
469475 implicit none
470476
471477 integer ,intent (in ) :: id ! ! the id code for the method
472- type (finite_diff_method),intent (out ) :: fd ! ! this method (can be used in [[compute_jacobian]])
478+ type (finite_diff_method),intent (out ) :: fd ! ! this method (can be used
479+ ! ! in [[compute_jacobian]])
473480 logical ,intent (out ) :: found ! ! true if it was found
474481
475482 found = .true.
@@ -517,6 +524,24 @@ subroutine get_finite_difference_method(id,fd,found)
517524 case (14 )
518525 ! (3f(x-4h)-16f(x-3h)+36f(x-2h)-48f(x-h)+25f(x)) / (12h)
519526 fd = finite_diff_method(id,' 5-point backward 1' , 5 ,[- 4 ,- 3 ,- 2 ,- 1 ,0 ],[3 ,- 16 ,36 ,- 48 ,25 ],12 )
527+ case (15 )
528+ ! (3f(x-2h)-30f(x-h)-20f(x)+60f(x+h)-15f(x+2h)+2f(x+3h)) / (60h)
529+ fd = finite_diff_method(id,' 6-point forward 3' , 6 ,[- 2 ,- 1 ,0 ,1 ,2 ,3 ],[3 ,- 30 ,- 20 ,60 ,- 15 ,2 ],60 )
530+ case (16 )
531+ ! (-2f(x-3h)+15f(x-2h)-60f(x-h)+20f(x)+30f(x+h)-3f(x+2h)) / (60h)
532+ fd = finite_diff_method(id,' 6-point backward 3' , 6 ,[- 3 ,- 2 ,- 1 ,0 ,1 ,2 ],[- 2 ,15 ,- 60 ,20 ,30 ,- 3 ],60 )
533+ case (17 )
534+ ! (-12f(x-h)-65f(x)+120f(x+h)-60f(x+2h)+20f(x+3h)-3f(x+4h)) / (60h)
535+ fd = finite_diff_method(id,' 6-point forward 2' , 6 ,[- 1 ,0 ,1 ,2 ,3 ,4 ],[- 12 ,- 65 ,120 ,- 60 ,20 ,- 3 ],60 )
536+ case (18 )
537+ ! (3f(x-4h)-20f(x-3h)+60f(x-2h)-120f(x-h)+65f(x)+12f(x+h)) / (60h)
538+ fd = finite_diff_method(id,' 6-point backward 2' , 6 ,[- 4 ,- 3 ,- 2 ,- 1 ,0 ,1 ],[3 ,- 20 ,60 ,- 120 ,65 ,12 ],60 )
539+ case (19 )
540+ ! (-137f(x)+300f(x+h)-300f(x+2h)+200f(x+3h)-75f(x+4h)+12f(x+5h)) / (60h)
541+ fd = finite_diff_method(id,' 6-point forward 1' , 6 ,[0 ,1 ,2 ,3 ,4 ,5 ],[- 137 ,300 ,- 300 ,200 ,- 75 ,12 ],60 )
542+ case (20 )
543+ ! (-12f(x-5h)+75f(x-4h)-200f(x-3h)+300f(x-2h)-300f(x-h)+137f(x)) / (60h)
544+ fd = finite_diff_method(id,' 6-point backward 1' , 6 ,[- 5 ,- 4 ,- 3 ,- 2 ,- 1 ,0 ],[- 12 ,75 ,- 200 ,300 ,- 300 ,137 ],60 )
520545 case default
521546 found = .false.
522547 end select
@@ -526,7 +551,8 @@ end subroutine get_finite_difference_method
526551
527552! *******************************************************************************
528553! >
529- ! Returns all the methods with the given `class`.
554+ ! Returns all the methods with the given `class`
555+ ! (i.e., number of points in the formula).
530556
531557 function get_all_methods_in_class (class ) result(list_of_methods)
532558
@@ -795,14 +821,12 @@ subroutine set_numdiff_bounds(me,xlow,xhigh)
795821 else if (any (xlow>= xhigh)) then
796822 error stop ' Error: all xlow must be < xhigh'
797823 else
798-
799824 if (allocated (me% xlow)) deallocate (me% xlow)
800825 if (allocated (me% xhigh)) deallocate (me% xhigh)
801826 allocate (me% xlow(me% n))
802827 allocate (me% xhigh(me% n))
803828 me% xlow = xlow
804829 me% xhigh = xhigh
805-
806830 end if
807831
808832 end subroutine set_numdiff_bounds
0 commit comments