LeastSquaresLM

Modified Levenberg-Marquardt parameters, data, and state.

struct LeastSquaresLM (
T
) if (
is(T == double) ||
is(T == float)
) {}

Constructors

this
this(size_t m, size_t n, Flag!"lowerBounds" lowerBounds = No.lowerBounds, Flag!"upperBounds" upperBounds = No.upperBounds)

Initialize iteration params and allocates vectors in GC and resets iteration counters, states a.

this
this(size_t m, size_t n, T[] lowerBounds, T[] upperBounds)

Initialize default params and allocates vectors in GC. lowerBounds and upperBounds are binded to lm struct.

Members

Aliases

FunctionDelegate
alias FunctionDelegate = void delegate(Slice!(const(T)*) x, Slice!(T*) y) @safe nothrow @nogc pure

Delegates for low level D API.

FunctionFunction
alias FunctionFunction = void function(void* context, size_t m, size_t n, const(T)* x, T* y) @system nothrow @nogc pure

Delegates for low level C API.

JacobianDelegate
alias JacobianDelegate = void delegate(Slice!(const(T)*) x, Slice!(T*, 2) J) @safe nothrow @nogc pure

Delegates for low level D API.

JacobianFunction
alias JacobianFunction = void function(void* context, size_t m, size_t n, const(T)* x, T* J) @system nothrow @nogc pure

Functions

fConverged
bool fConverged()

ditto residual <= maxGoodResidual

gcAlloc
auto gcAlloc(size_t m, size_t n, bool lowerBounds = false, bool upperBounds = false)

Allocates data in GC.

initParams
void initParams()

Initialize LM data structure with default params for iteration.

reset
void reset()

Resets all counters and flags, fills x, y, upper, lower, vecors with default values.

stdcAlloc
void stdcAlloc(size_t m, size_t n, bool lowerBounds = false, bool upperBounds = false)

Allocates data using C Runtime.

stdcFree
void stdcFree()

Frees vectors including x, y, upper, lower. Use in pair with .stdcAlloc.

Properties

deltaX
Slice!(T*) deltaX [@property getter]
lower
Slice!(T*) lower [@property getter]
upper
Slice!(T*) upper [@property getter]
x
Slice!(T*) x [@property getter]
y
Slice!(T*) y [@property getter]

Variables

fCalls
size_t fCalls;
gCalls
size_t gCalls;
gConverged
bool gConverged;

Counters and state values.

goodStepQuality
T goodStepQuality;

for steps above this quality, the trust region is expanded

goodStepQualityDefault
enum T goodStepQualityDefault;

Default scale such as for steps above thsis quality, the trust region is expanded

iterCt
size_t iterCt;

Counters and state values.

jacobianEpsilon
T jacobianEpsilon;

epsilon for finite difference Jacobian approximation

jacobianEpsilonDefault
enum T jacobianEpsilonDefault;

Default epsilon for finite difference Jacobian approximation

lambda
T lambda;

(inverse of) initial trust region radius

lambdaDecrease
T lambdaDecrease;

lambda is multiplied by this factor after good quality steps

lambdaDecreaseDefault
enum T lambdaDecreaseDefault;

Default lambda is multiplied by this factor after good quality steps

lambdaIncrease
T lambdaIncrease;

lambda is multiplied by this factor after step below min quality

lambdaIncreaseDefault
enum T lambdaIncreaseDefault;

Default lambda is multiplied by this factor after step below min quality

m
size_t m;

Y = f(X) dimension.

maxAge
uint maxAge;

Counters and state values.

maxGoodResidual
T maxGoodResidual;

the algorithm stops iteration when the residual value is less or equal to maxGoodResidual.

maxGoodResidualDefault
enum T maxGoodResidualDefault;

Default value for maxGoodResidual.

maxIter
size_t maxIter;

maximum number of iterations

maxLambda
T maxLambda;

minimum trust region radius

maxLambdaDefault
enum T maxLambdaDefault;

Default maximum trust region radius

minLambda
T minLambda;

maximum trust region radius

minLambdaDefault
enum T minLambdaDefault;

Default maximum trust region radius

minStepQuality
T minStepQuality;

for steps below this quality, the trust region is shrinked

minStepQualityDefault
enum T minStepQualityDefault;

Default scale such as for steps below this quality, the trust region is shrinked

n
size_t n;

X dimension.

residual
T residual;
status
LMStatus status;

Counters and state values.

tolG
T tolG;

tolerance in gradient

tolGDefault
enum T tolGDefault;

Default tolerance in gradient

tolX
T tolX;

tolerance in x

tolXDefault
enum T tolXDefault;

Default tolerance in x

xConverged
bool xConverged;

Counters and state values.

Meta