Table of Contents

Class NonLinearLeastSquare

Namespace
NanoQL.Numerics
Assembly
NanoQL.dll

Non-linear least squares: min r(x) over x ∈ Rⁿ, r(x) = |f(x)|² for f(x) = b − φ(x), by an optimization method (by default the conjugate gradient), under a constraint.

public sealed class NonLinearLeastSquare
Inheritance
NonLinearLeastSquare
Inherited Members

Remarks

Immutable, with QuantLib's settings: Perform(LeastSquareProblem, ReadOnlySpan<double>) takes the initial value and returns the results, where QuantLib's object holds both. QuantLib's iterationsNumber() isn't ported: it returns a member QuantLib never sets (leastsquare.cpp:109, its assignment commented out), its value undefined. The results are the point the method returns: on the conjugate gradient, the last one its line search accepted (Divergences/LineSearchReturnTests.cs), where QuantLib's is the point before; the residual norm, the function value there, is QuantLib's.

Constructors

NonLinearLeastSquare(Constraint, double, int)

Initializes a new instance of the NonLinearLeastSquare class on the conjugate gradient.

public NonLinearLeastSquare(Constraint c, double accuracy = 0.0001, int maxiter = 100)

Parameters

c Constraint

The constraint.

accuracy double

The accuracy of the end criteria.

maxiter int

The most iterations.

Exceptions

ArgumentNullException

c is null.

ArgumentOutOfRangeException

maxiter is negative.

NonLinearLeastSquare(Constraint, double, int, OptimizationMethod)

Initializes a new instance of the NonLinearLeastSquare class.

public NonLinearLeastSquare(Constraint c, double accuracy, int maxiter, OptimizationMethod om)

Parameters

c Constraint

The constraint.

accuracy double

The accuracy of the end criteria.

maxiter int

The most iterations.

om OptimizationMethod

The optimization method.

Exceptions

ArgumentNullException

c or om is null.

ArgumentOutOfRangeException

maxiter is negative.

Methods

Perform(LeastSquareProblem, ReadOnlySpan<double>)

Fits the problem from an initial value.

public NonLinearLeastSquareResults Perform(LeastSquareProblem lsProblem, ReadOnlySpan<double> initialValue)

Parameters

lsProblem LeastSquareProblem

The problem.

initialValue ReadOnlySpan<double>

The initial value.

Returns

NonLinearLeastSquareResults

The point found, the residual norm, the last value and the end criterion met.

Exceptions

ArgumentNullException

lsProblem is null.