mir.numeric

Base numeric algorithms.

Reworked part of std.numeric.

Members

Aliases

FindRootResult
alias FindRootResult = mir_find_root_result
FindRootStatus
alias FindRootStatus = mir_find_root_status

Enums

mir_find_root_status
enum mir_find_root_status

Functions

diff
DiffResult!T diff(T x, T h, T factor, T safe)
diffImpl
DiffResult!T diffImpl(T delegate(T) @(safe) pure nothrow @(nogc) f, T x, T h, T factor, T safe)

Calculate the derivative of a function. This function uses Ridders' method of extrapolating the results of finite difference formulas for consecutively smaller step sizes, with an improved stopping criterion described in the Numerical Recipes books by Press et al.

findLocalMin
FindLocalMinResult!T findLocalMin(T ax, T bx, T relTolerance, T absTolerance)

Find a real minimum of a real function f(x) via bracketing. Given a function f and a range (ax .. bx), returns the value of x in the range which is closest to a minimum of f(x). f is never evaluted at the endpoints of ax and bx. If f(x) has more than one minimum in the range, one will be chosen arbitrarily. If f(x) returns NaN or -Infinity, (x, f(x), NaN) will be returned; otherwise, this algorithm is guaranteed to succeed.

findRoot
FindRootResult!T findRoot(T ax, T bx, T fax, T fbx, T lowerBound, T upperBound, uint maxIterations, uint steps)

Find root of a real function f(x) by bracketing, allowing the termination condition to be specified.

findRootImpl
FindRootResult!float findRootImpl(float ax, float bx, float fax, float fbx, float lowerBound, float upperBound, uint maxIterations, uint steps, float delegate(float) @(safe) pure nothrow @(nogc) f, bool delegate(float, float) @(safe) pure nothrow @(nogc) tolerance)
FindRootResult!double findRootImpl(double ax, double bx, double fax, double fbx, double lowerBound, double upperBound, uint maxIterations, uint steps, double delegate(double) @(safe) pure nothrow @(nogc) f, bool delegate(double, double) @(safe) pure nothrow @(nogc) tolerance)
FindRootResult!real findRootImpl(real ax, real bx, real fax, real fbx, real lowerBound, real upperBound, uint maxIterations, uint steps, real delegate(real) @(safe) pure nothrow @(nogc) f, bool delegate(real, real) @(safe) pure nothrow @(nogc) tolerance)

findRoot implementations.

Structs

DiffResult
struct DiffResult(T)
FindLocalMinResult
struct FindLocalMinResult(T)
mir_find_root_result
struct mir_find_root_result(T)

Meta

License

Apache-2.0

Authors

Ilya Yaroshenko (API, findLocalMin, findRoot extension), Don Clugston (findRoot), Lars Tandle Kyllingstad (diff)