Loading [MathJax]/extensions/tex2jax.js
MRFFL: MR Fortran Finance Library 2024-12-28
Computational Tools For Finance
All Namespaces Files Functions Variables
mrffl_solver_ne Module Reference

Experimental root solvers that take a data payload in addition to a function. More...

Functions/Subroutines

subroutine, public bisection (xc, x0_init, x1_init, f, r_dat, i_dat, x_epsilon, y_epsilon, max_itr, status, progress)
 Search for a root for the function f in the interval [x0_init, x1_init].
 
subroutine, public multi_bisection (xc, x0_init, x1_init, f, r_dat, i_dat, x_epsilon, y_epsilon, max_itr, status, progress)
 Use bisection() to search for a root for the function f in a list of intervals returning the first root found.
 

Detailed Description

Experimental root solvers that take a data payload in addition to a function.

The idea is to avoid shared variables. This is especially difficult for nested functions because they require the resulting binary to have an executable stack – something frowned upon. Unfortuntly this code currently causes code generated by the NVIDIA HPC compiler to core dump. That's why this code is "experimental".

Function/Subroutine Documentation

◆ bisection()

subroutine, public mrffl_solver_ne::bisection ( real(kind=rk), intent(out) xc,
real(kind=rk), intent(in) x0_init,
real(kind=rk), intent(in) x1_init,
procedure(func_to_solve_t) f,
real(kind=rk), dimension(:), intent(in) r_dat,
integer(kind=ik), dimension(:), intent(in) i_dat,
real(kind=rk), intent(in) x_epsilon,
real(kind=rk), intent(in) y_epsilon,
integer(kind=ik), intent(in) max_itr,
integer(kind=ik), intent(out) status,
logical, intent(in) progress )

Search for a root for the function f in the interval [x0_init, x1_init].

The process is iterative. At each step the size of the search interval is cut in half. If the search interval gets too small (< x_epsilon), then the process is abandoned. If no zero is found after max_itr, then the process is abandoned.

Parameters
xcThe solution (or last value tested if no solution is found)
x0_initLeft side of search interval
x1_initRight side of search interval
fFunction to solve for zero
r_datReal data passed to f
i_datInteger data passed to f
x_epsilonUsed to test if current search interval is too small
y_epsilonUsed to test if f is near zero
max_itrMaximum number of iterations before giving up
statusReturns status of computation. 0 if everything worked. Range: 0 & 4001-4032.
progressPrint progress as solver searches for a solution

Definition at line 71 of file mrffl_solver_ne.f90.

References mrffl_config::mrfflik, and mrffl_config::mrfflrk.

Referenced by multi_bisection().

Here is the caller graph for this function:

◆ multi_bisection()

subroutine, public mrffl_solver_ne::multi_bisection ( real(kind=rk), intent(out) xc,
real(kind=rk), dimension(:), intent(in) x0_init,
real(kind=rk), dimension(:), intent(in) x1_init,
procedure(func_to_solve_t) f,
real(kind=rk), dimension(:), intent(in) r_dat,
integer(kind=ik), dimension(:), intent(in) i_dat,
real(kind=rk), intent(in) x_epsilon,
real(kind=rk), intent(in) y_epsilon,
integer(kind=ik), intent(in) max_itr,
integer(kind=ik), intent(out) status,
logical, intent(in) progress )

Use bisection() to search for a root for the function f in a list of intervals returning the first root found.

Parameters
xcThe solution (or last value tested if no solution is found)
x0_initA VECTOR of left sides for search intervals
x1_initA VECTOR of right sides for search intervals
fFunction to solve for zero
r_datReal data passed to f
i_datInteger data passed to f
x_epsilonUsed to test if current search interval is too small
y_epsilonUsed to test if f is near zero
max_itrMaximum number of iterations before giving up
statusReturns status of computation. 0 if everything worked. Range: 0 & 4033-4064.
progressPrint progress as solver searches for a solution

Definition at line 163 of file mrffl_solver_ne.f90.

References bisection(), mrffl_config::mrfflik, and mrffl_config::mrfflrk.

Here is the call graph for this function: