brent_class Derived Type

type, public :: brent_class

the main class


Components

Type Visibility Attributes Name Initial
procedure(func), public, pointer :: f => null()

function to be minimized


Type-Bound Procedures

procedure, public :: set_function

  • private subroutine set_function(me, f)

    Author
    Jacob Williams
    Date
    7/19/2014

    Set the function to be minimized.

    Arguments

    Type IntentOptional Attributes Name
    class(brent_class), intent(inout) :: me
    procedure(func) :: f

procedure, public :: minimize => fmin

  • private function fmin(me, ax, bx, tol) result(xmin)

    An approximation x to the point where f attains a minimum on the interval (ax,bx) is determined.

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(brent_class), intent(inout) :: me
    real(kind=wp), intent(in) :: ax

    left endpoint of initial interval

    real(kind=wp), intent(in) :: bx

    right endpoint of initial interval

    real(kind=wp), intent(in) :: tol

    desired length of the interval of uncertainty of the final result (>=0)

    Return Value real(kind=wp)

    abcissa approximating the point where f attains a minimum

procedure, public :: find_zero => zeroin

  • private subroutine zeroin(me, ax, bx, tol, xzero, fzero, iflag, fax, fbx)

    Find a zero of the function in the given interval to within a tolerance , where is the relative machine precision defined as the smallest representable number such that .

    Read more…

    Arguments

    Type IntentOptional Attributes Name
    class(brent_class), intent(inout) :: me
    real(kind=wp), intent(in) :: ax

    left endpoint of initial interval

    real(kind=wp), intent(in) :: bx

    right endpoint of initial interval

    real(kind=wp), intent(in) :: tol

    desired length of the interval of uncertainty of the final result (>=0)

    real(kind=wp), intent(out) :: xzero

    abscissa approximating a zero of f in the interval ax,bx

    real(kind=wp), intent(out) :: fzero

    value of f at the root (f(xzero))

    integer, intent(out) :: iflag

    status flag (-1=error, 0=root found)

    real(kind=wp), intent(in), optional :: fax

    if f(ax) is already known, it can be input here

    real(kind=wp), intent(in), optional :: fbx

    if f(ax) is already known, it can be input here

Source Code

    type,public :: brent_class
        !! the main class
        procedure(func),pointer :: f => null()  !! function to be minimized
    contains
        procedure :: set_function
        procedure :: minimize => fmin
        procedure :: find_zero => zeroin
    end type brent_class