brent_solver Derived Type

type, public, extends(equation_solver_1var) :: brent_solver

Defines a solver based upon Brent's method for solving an equation of one variable without using derivatives.


Contents


Type-Bound Procedures

procedure, public :: get_diff_tolerance => es1_get_diff_tol

  • private pure function es1_get_diff_tol(this) result(x)

    Gets the convergence on slope of the function (derivative) tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(in) :: this

    The equation_solver_1var object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_fcn_tolerance => es1_get_fcn_tol

  • private pure function es1_get_fcn_tol(this) result(x)

    Gets the convergence on function value tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(in) :: this

    The equation_solver_1var object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_max_fcn_evals => es1_get_max_eval

  • private pure function es1_get_max_eval(this) result(n)

    Gets the maximum number of function evaluations allowed during a single solve.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(in) :: this

    The equation_solver_1var object.

    Return Value integer(kind=int32)

    The maximum number of function evaluations.

procedure, public :: get_print_status => es1_get_print_status

  • private pure function es1_get_print_status(this) result(x)

    Gets a logical value determining if iteration status should be printed.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(in) :: this

    The equation_solver_1var object.

    Return Value logical

    True if the iteration status should be printed; else, false.

procedure, public :: get_var_tolerance => es1_get_var_tol

  • private pure function es1_get_var_tol(this) result(x)

    Gets the convergence on change in variable tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(in) :: this

    The equation_solver_1var object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: set_diff_tolerance => es1_set_diff_tol

  • private subroutine es1_set_diff_tol(this, x)

    Sets the convergence on slope of the function (derivative) tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(inout) :: this

    The equation_solver_1var object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_fcn_tolerance => es1_set_fcn_tol

  • private subroutine es1_set_fcn_tol(this, x)

    Sets the convergence on function value tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(inout) :: this

    The equation_solver_1var object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_max_fcn_evals => es1_set_max_eval

  • private subroutine es1_set_max_eval(this, n)

    Sets the maximum number of function evaluations allowed during a single solve.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(inout) :: this

    The equation_solver_1var object.

    integer(kind=int32), intent(in) :: n

    The maximum number of function evaluations.

procedure, public :: set_print_status => es1_set_print_status

  • private subroutine es1_set_print_status(this, x)

    Sets a logical value determining if iteration status should be printed.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(inout) :: this

    The equation_solver_1var object.

    logical, intent(in) :: x

    True if the iteration status should be printed; else, false.

procedure, public :: set_var_tolerance => es1_set_var_tol

  • private subroutine es1_set_var_tol(this, x)

    Sets the convergence on change in variable tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(equation_solver_1var), intent(inout) :: this

    The equation_solver_1var object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: solve => brent_solve

  • private subroutine brent_solve(this, fcn, x, lim, f, ib, err)

    Solves an equation of one variable using Brent's method.

    See Also

    • Wikipedia

    • Numerical Recipes

    • R.P. Brent, "Algorithms for Minimization without Derivatives," Dover Publications, January 2002. ISBN 0-486-41998-3. Further information available here.

    Arguments

    Type IntentOptional Attributes Name
    class(brent_solver), intent(inout) :: this

    The brent_solver object.

    class(fcn1var_helper), intent(in) :: fcn

    The fcn1var_helper object containing the equation to solve.

    real(kind=real64), intent(inout) :: x

    A parameter used to return the solution. Notice, any input value will be ignored as this routine relies upon the search limits in lim to provide a starting point.

    type(value_pair), intent(in) :: lim

    A value_pair object defining the search limits.

    real(kind=real64), intent(out), optional :: f

    An optional parameter used to return the function residual as computed at x.

    type(iteration_behavior), optional :: ib

    An optional output, that if provided, allows the caller to obtain iteration performance statistics.

    class(errors), intent(inout), optional, target :: err

    An error handling object.