Class NonLinearLeastSquare
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
cConstraintThe constraint.
accuracydoubleThe accuracy of the end criteria.
maxiterintThe most iterations.
Exceptions
- ArgumentNullException
cis null.- ArgumentOutOfRangeException
maxiteris 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
cConstraintThe constraint.
accuracydoubleThe accuracy of the end criteria.
maxiterintThe most iterations.
omOptimizationMethodThe optimization method.
Exceptions
- ArgumentNullException
coromis null.- ArgumentOutOfRangeException
maxiteris negative.
Methods
Perform(LeastSquareProblem, ReadOnlySpan<double>)
Fits the problem from an initial value.
public NonLinearLeastSquareResults Perform(LeastSquareProblem lsProblem, ReadOnlySpan<double> initialValue)
Parameters
lsProblemLeastSquareProblemThe problem.
initialValueReadOnlySpan<double>The initial value.
Returns
- NonLinearLeastSquareResults
The point found, the residual norm, the last value and the end criterion met.
Exceptions
- ArgumentNullException
lsProblemis null.