8#ifndef META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_H
9#define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_H
44 template <
typename TFirst,
typename TSecond>
52 using Element = std::pair<Index32, Vector2>;
98 inline void element(
const size_t groupIndex,
const size_t elementIndex, TFirst& first, TSecond& second)
const;
106 inline const TFirst&
firstElement(
const size_t groupIndex,
const size_t elementIndex)
const;
114 inline const TSecond&
secondElement(
const size_t groupIndex,
const size_t elementIndex)
const;
236 template <
typename TAccessor>
245 template <
typename TAccessor>
261 template <
typename TAccessor>
277 template <
typename TAccessor>
465 template <
typename T>
482 template <
typename T, Estimator::EstimatorType tEstimator>
499 template <
typename T>
516 template <
typename T, Estimator::EstimatorType tEstimator>
532 template <
typename T>
548 template <
typename T>
561 template <Estimator::EstimatorType tEstimator>
575 template <Estimator::EstimatorType tEstimator,
size_t tDimension>
589 template <Estimator::EstimatorType tEstimator>
615 template <
size_t tDimension>
632template <
typename TFirst,
typename TSecond>
638template <
typename TFirst,
typename TSecond>
645template <
typename TFirst,
typename TSecond>
652template <
typename TFirst,
typename TSecond>
659template <
typename TFirst,
typename TSecond>
666template <
typename TFirst,
typename TSecond>
672template <
typename TFirst,
typename TSecond>
675 ocean_assert(groupIndex <
groups());
680template <
typename TFirst,
typename TSecond>
683 ocean_assert(groupIndex <
groups());
692template <
typename TFirst,
typename TSecond>
695 ocean_assert(groupIndex <
groups());
701template <
typename TFirst,
typename TSecond>
704 ocean_assert(groupIndex <
groups());
710template <
typename TFirst,
typename TSecond>
717template <
typename TFirst,
typename TSecond>
720 if (
this != &accessor)
769 ocean_assert(
false &&
"Must be implemented in a derived class!");
775 ocean_assert(
false &&
"Must be implemented in a derived class!");
786 ocean_assert(
false &&
"Must be implemented in a derived class!");
792 ocean_assert(
false &&
"Must be implemented in a derived class!");
798 ocean_assert(
false &&
"Must be implemented in a derived class!");
803 ocean_assert(
false &&
"Must be implemented in a derived class!");
808 ocean_assert(
false &&
"Must be implemented in a derived class!");
819 ocean_assert(
false &&
"Must be implemented in a derived class!");
830 ocean_assert(
false &&
"Must be implemented in a derived class!");
836 ocean_assert(
false &&
"Must be implemented in a derived class!");
842 ocean_assert(
false &&
"Must be implemented in a derived class!");
847 ocean_assert(
false &&
"Must be implemented in a derived class!");
852 ocean_assert(
false &&
"Must be implemented in a derived class!");
858 ocean_assert(
false &&
"Must be implemented in a derived class!");
862template <
typename TAccessor>
866 ocean_assert(imagePoints0.size() == imagePoints1.size());
868 for (
size_t n = 0; n < imagePoints0.size(); ++n)
878template <
typename TAccessor>
884 for (
size_t n = 0; n < imagePointGroups.size(); ++n)
887 ocean_assert(imagePoints.
size() >= 2);
890 poseIndexImagePoints.reserve(imagePoints.
size());
892 for (
size_t i = 0; i < imagePoints.
size(); ++i)
894 poseIndexImagePoints.emplace_back(
Index32(i), imagePoints[i]);
901template <
typename TAccessor>
906 ocean_assert(sequentialImagePointGroups.size() % numberObjectPoints == 0);
908 const unsigned int numberImagePoints = (
unsigned int)(sequentialImagePointGroups.size() / numberObjectPoints);
910 unsigned int index = 0u;
912 for (
size_t n = 0; n < numberObjectPoints; ++n)
915 poseIndexImagePoints.reserve(numberImagePoints);
917 for (
unsigned int i = 0u; i < numberImagePoints; ++i)
919 poseIndexImagePoints.emplace_back(
Index32(i), sequentialImagePointGroups[index++]);
926template <
typename TAccessor>
931 ocean_assert(imagePoints.size() % numberObjectPoints == 0);
933 ocean_assert(numberObjectPoints != 0);
934 const unsigned int numberImagePoints = (
unsigned int)(imagePoints.size() / numberObjectPoints);
936 unsigned int poseIndex = 0u;
937 unsigned int index = 0u;
939 for (
size_t n = 0; n < numberImagePoints; ++n)
941 for (
size_t i = 0; i < numberObjectPoints; ++i)
953 ocean_assert(!poseIdImagePointPairs.empty());
959 return objectPointIndex;
983 ocean_assert(
false &&
"Invalid estimator!");
988template <
typename T, Estimator::EstimatorType tEstimator>
993 ocean_assert(lambda >=
Numeric::eps() && lambda <= maxLambda);
998 Matrix weightedErrorVector, swapWeightedErrorVector;
1000 Matrix weightVector, swapWeightVector;
1002 Matrix JTJ, jErrors, deltas;
1005 Matrix intermediateCovarianceJacobian;
1006 Matrix intermediateWeightedErrorVector;
1008 Scalar bestError = provider.template determineRobustError<tEstimator>(weightedErrorVector, weightVector, invertedCovariances);
1012 ocean_assert(
false &&
"The initial model was invalid and thus the optimization cannot be applied!");
1016 if (initialError !=
nullptr)
1018 *initialError = bestError;
1021 if (intermediateErrors !=
nullptr)
1023 ocean_assert(intermediateErrors->empty());
1024 intermediateErrors->push_back(bestError);
1027 bool oneValidIteration =
false;
1029 unsigned int i = 0u;
1030 while (i < iterations)
1032 provider.determineJacobian(jacobian);
1035 if (invertedCovariances)
1083 while (i < iterations)
1090 for (
unsigned int n = 0; n < JTJ.
columns(); ++n)
1092 JTJ(n, n) = JTJdiagonal(n, 0) * (
Scalar(1) + lambda);
1099 bool solved =
false;
1101 if (provider.hasSolver())
1103 solved = provider.solve(JTJ, jErrors, deltas);
1112 oneValidIteration =
true;
1121 provider.applyCorrection(deltas);
1123 const Scalar iterationError = provider.template determineRobustError<tEstimator>(swapWeightedErrorVector, swapWeightVector, invertedCovariances);
1126 if (iterationError >= bestError)
1129 if (lambdaFactor >
Numeric::eps() && lambda > 0 && lambda <= maxLambda)
1131 lambda *= lambdaFactor;
1135 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1145 bestError = iterationError;
1147 if (intermediateErrors !=
nullptr)
1149 intermediateErrors->push_back(bestError);
1152 provider.acceptCorrection();
1154 std::swap(swapWeightedErrorVector, weightedErrorVector);
1155 std::swap(swapWeightVector, weightVector);
1162 lambda /= lambdaFactor;
1169 else if (lambda >
Numeric::eps() && lambda <= maxLambda)
1171 lambda *= lambdaFactor;
1175 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1185 *finalError = bestError;
1188 return oneValidIteration;
1191template <
typename T>
1212 ocean_assert(
false &&
"Invalid estimator!");
1217template <
typename T, Estimator::EstimatorType tEstimator>
1222 ocean_assert(lambda >=
Numeric::eps() && lambda <= maxLambda);
1227 Matrix weightedErrorVector, swapWeightedErrorVector;
1229 Matrix weightVector, swapWeightVector;
1236 Scalar bestError = provider.template determineRobustError<tEstimator>(weightedErrorVector, weightVector, invertedCovariances);
1240 ocean_assert(
false &&
"The initial model was invalid and thus the optimization cannot be applied!");
1246 *initialError = bestError;
1249 if (intermediateErrors !=
nullptr)
1251 ocean_assert(intermediateErrors->empty());
1252 intermediateErrors->push_back(bestError);
1255 bool oneValidIteration =
false;
1257 unsigned int i = 0u;
1258 while (i < iterations)
1260 provider.determineJacobian(jacobian);
1263 if (invertedCovariances)
1275 JTJ = jacobianTransposed * (invertedCovarianceMatrix * jacobian);
1281 JTJ = jacobianTransposed * (invertedCovarianceMatrix * (
SparseMatrix(weightVector.
rows(), weightVector.
rows(), weightVector,
true) * jacobian));
1286 jErrors = jacobianTransposed * (invertedCovarianceMatrix * weightedErrorVector);
1301 JTJ = jacobianTransposed * jacobian;
1307 JTJ = jacobianTransposed *
SparseMatrix(weightVector.
rows(), weightVector.
rows(), weightVector,
true) * jacobian;
1312 jErrors = jacobianTransposed * weightedErrorVector;
1318 while (i < iterations)
1325 for (
unsigned int n = 0; n < JTJ.
columns(); ++n)
1327 if (JTJdiagonal(n, 0) !=
Scalar(0))
1329 ocean_assert(!JTJ.
isZero(n, n));
1330 JTJ(n, n) = JTJdiagonal(n, 0) * (
Scalar(1) + lambda);
1338 bool solved =
false;
1340 if (provider.hasSolver())
1342 solved = provider.solve(JTJ, jErrors, deltas);
1346 solved = JTJ.
solve(jErrors, deltas);
1351 oneValidIteration =
true;
1360 provider.applyCorrection(deltas);
1362 const Scalar iterationError = provider.template determineRobustError<tEstimator>(swapWeightedErrorVector, swapWeightVector, invertedCovariances);
1365 if (iterationError >= bestError)
1368 if (lambdaFactor >
Numeric::eps() && lambda > 0 && lambda <= maxLambda)
1370 lambda *= lambdaFactor;
1374 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1384 bestError = iterationError;
1386 if (intermediateErrors !=
nullptr)
1388 intermediateErrors->push_back(bestError);
1391 provider.acceptCorrection();
1393 std::swap(swapWeightedErrorVector, weightedErrorVector);
1394 std::swap(swapWeightVector, weightVector);
1401 lambda /= lambdaFactor;
1408 else if (lambda >
Numeric::eps() && lambda <= maxLambda)
1410 lambda *= lambdaFactor;
1414 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1424 *finalError = bestError;
1427 return oneValidIteration;
1430template <
typename T>
1435 ocean_assert(lambda >=
Scalar(0) && lambda <= maxLambda);
1436 ocean_assert((lambda ==
Scalar(0) && lambdaFactor ==
Scalar(1)) || (lambda >
Scalar(0) && lambdaFactor >
Scalar(1)));
1438 const bool useLevenbergMarquardt = (lambda > 0 && lambdaFactor > 1);
1442 Scalar bestError = advancedDenseProvider.determineError();
1446 ocean_assert(
false &&
"The initial model was invalid and thus the optimization cannot be applied!");
1452 *initialError = bestError;
1455 if (intermediateErrors !=
nullptr)
1457 ocean_assert(intermediateErrors->empty());
1458 intermediateErrors->push_back(bestError);
1461 bool oneValidIteration =
false;
1463 Matrix hessian, jacobianError, deltas;
1465 unsigned int i = 0u;
1466 while (!advancedDenseProvider.shouldStop() && i < iterations)
1474 if (!advancedDenseProvider.determineHessianAndErrorJacobian(hessian, jacobianError))
1476 ocean_assert(
false &&
"The Hessian and the Jacobian with combined error values could not be determined!");
1480 ocean_assert(hessian.
rows() == hessian.
columns());
1481 ocean_assert(hessian.
rows() == jacobianError.
rows() && jacobianError.
columns() == 1);
1486 ocean_assert(hessianDiagonal.
rows() == hessian.
rows() && hessianDiagonal.
columns() == 1);
1488 while (!advancedDenseProvider.shouldStop() && i++ < iterations)
1494 for (
unsigned int n = 0; n < hessian.
columns(); ++n)
1496 hessian(n, n) = hessianDiagonal(n, 0) * (
Scalar(1) + lambda);
1502 bool solved =
false;
1504 if (advancedDenseProvider.hasSolver())
1506 solved = advancedDenseProvider.solve(hessian, jacobianError, deltas);
1515 oneValidIteration =
true;
1524 advancedDenseProvider.applyCorrection(deltas);
1527 const Scalar iterationError = advancedDenseProvider.determineError();
1530 if (useLevenbergMarquardt && iterationError >= bestError)
1533 if (lambda > 0 && lambda <= maxLambda)
1535 lambda *= lambdaFactor;
1539 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1549 bestError = iterationError;
1551 if (intermediateErrors !=
nullptr)
1553 intermediateErrors->push_back(bestError);
1556 advancedDenseProvider.acceptCorrection();
1563 lambda /= lambdaFactor;
1570 else if (lambda >
Numeric::eps() && lambda <= maxLambda)
1572 lambda *= lambdaFactor;
1576 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1587 if (!useLevenbergMarquardt && !intermediateErrors)
1589 bestError = advancedDenseProvider.determineError();
1592 *finalError = bestError;
1595 return oneValidIteration;
1598template <
typename T>
1603 ocean_assert(lambda >=
Scalar(0) && lambda <= maxLambda);
1604 ocean_assert((lambda ==
Scalar(0) && lambdaFactor ==
Scalar(1)) || (lambda >
Scalar(0) && lambdaFactor >
Scalar(1)));
1606 const bool useLevenbergMarquardt = (lambda > 0 && lambdaFactor > 1);
1610 Scalar bestError = advancedSparseProvider.determineError();
1614 ocean_assert(
false &&
"The initial model was invalid and thus the optimization cannot be applied!");
1620 *initialError = bestError;
1623 if (intermediateErrors !=
nullptr)
1625 ocean_assert(intermediateErrors->empty());
1626 intermediateErrors->push_back(bestError);
1629 bool oneValidIteration =
false;
1633 unsigned int i = 0u;
1634 while (!advancedSparseProvider.shouldStop() && i < iterations)
1640 if (!advancedSparseProvider.determineParameters())
1642 ocean_assert(
false &&
"The provider failed to determine the abstract parameters.");
1646 while (!advancedSparseProvider.shouldStop() && i++ < iterations)
1648 ocean_assert(lambda >=
Scalar(0));
1649 if (advancedSparseProvider.solve(deltas, lambda))
1651 oneValidIteration =
true;
1660 advancedSparseProvider.applyCorrection(deltas);
1663 const Scalar iterationError = advancedSparseProvider.determineError();
1666 if (useLevenbergMarquardt && iterationError >= bestError)
1669 if (lambda > 0 && lambda <= maxLambda)
1671 lambda *= lambdaFactor;
1675 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1685 bestError = iterationError;
1687 if (intermediateErrors !=
nullptr)
1689 intermediateErrors->push_back(bestError);
1692 advancedSparseProvider.acceptCorrection();
1699 lambda /= lambdaFactor;
1706 else if (lambda >
Numeric::eps() && lambda <= maxLambda)
1708 lambda *= lambdaFactor;
1712 ocean_assert(oneValidIteration &&
"At this moment we should have at least one valid iteration!");
1723 if (!useLevenbergMarquardt && !intermediateErrors)
1725 bestError = advancedSparseProvider.determineError();
1728 *finalError = bestError;
1731 return oneValidIteration;
1734template <Estimator::EstimatorType tEstimator>
1742 for (
size_t n = 0; n < sqrErrors.size(); ++n)
1751 if (transposedInvertedCovariances)
1753 robustError += (transposedInvertedCovariances[n].
transposed() * weightedErrors[n]).sqr() * weight;
1757 robustError += sqrErrors[n] * weight;
1760 weightedErrors[n] *= weight;
1762 weightVectors[n] =
Vector2(weight, weight);
1766 return robustError /
Scalar(sqrErrors.size());
1769template <Estimator::EstimatorType tEstimator,
size_t tDimension>
1772 ocean_assert(transposedInvertedCovariances ==
nullptr &&
"Currently not implemented");
1773 OCEAN_SUPPRESS_UNUSED_WARNING(transposedInvertedCovariances);
1780 for (
size_t n = 0; n < sqrErrors.size(); ++n)
1792 robustError += sqrErrors[n] * weight;
1794 for (
size_t d = 0; d < tDimension; ++d)
1796 weightedErrorsPointer[d] *= weight;
1797 weightVectorsPointer[d] = weight;
1802 return robustError /
Scalar(sqrErrors.size());
1805template <Estimator::EstimatorType tEstimator>
1808 ocean_assert(transposedInvertedCovariances_i ==
nullptr &&
"Currently not implemented");
1809 OCEAN_SUPPRESS_UNUSED_WARNING(transposedInvertedCovariances_i);
1816 for (
size_t n = 0; n < sqrErrors.size(); ++n)
1818 Scalar*
const weightedErrorsPointer = weightedErrors_i + n * dimension;
1819 Scalar*
const weightVectorsPointer = weightVectors_i + n * dimension;
1827 robustError += sqrErrors[n] * weight;
1829 for (
size_t d = 0; d < dimension; ++d)
1831 weightedErrorsPointer[d] *= weight;
1832 weightVectorsPointer[d] = weight;
1837 return robustError /
Scalar(sqrErrors.size());
1860 ocean_assert(
false &&
"Invalid estimator!");
1865template <
size_t tDimension>
1886 ocean_assert(
false &&
"Invalid estimator!");
1911 ocean_assert(
false &&
"Invalid estimator!");
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
static Scalar robustWeightSquare(const Scalar sqrValue, const Scalar sqrSigma=0)
Returns the weight in relation to a squared error for a given residual error and a specified estimato...
Definition Estimator.h:721
static Scalar determineSigmaSquare(const Scalar *sqrErrors, const size_t number, const size_t modelParameters)
Determines the squared sigma for a specific set of squared residual errors and a specified estimator.
Definition Estimator.h:896
static constexpr bool needSigma()
Returns whether an estimator needs a standard deviation for computation.
Definition Estimator.h:380
EstimatorType
Definition of individual robust estimator types.
Definition Estimator.h:34
@ ET_HUBER
The Huber estimator type.
Definition Estimator.h:84
@ ET_TUKEY
The Tukey estimator.
Definition Estimator.h:102
@ ET_SQUARE
The standard square error estimator (L2).
Definition Estimator.h:52
@ ET_LINEAR
The linear estimator (L1).
Definition Estimator.h:66
@ ET_CAUCHY
The Cauchy estimator.
Definition Estimator.h:118
void acceptCorrection()
Accepts the current model candidate a new (better) model than the previous one.
Definition NonLinearOptimization.h:801
Scalar determineError()
Determines the error for the current model candidate (not the actual model).
Definition NonLinearOptimization.h:784
bool determineHessianAndErrorJacobian(Matrix &hessian, Matrix &jacobianError)
Determines the Hessian matrix and the Error-Jacobian vector based on the actual/current model (the tr...
Definition NonLinearOptimization.h:790
bool hasSolver() const
Returns whether the provider comes with an own solver for the linear equation.
Definition NonLinearOptimization.h:812
bool shouldStop()
Returns whether the optimization process should stop e.g., due to an external event.
Definition NonLinearOptimization.h:806
bool solve(const Matrix &hessian, const Matrix &jacobianError, Matrix &deltas) const
Solves the linear equation Hessian * deltas = -jacobianError.
Definition NonLinearOptimization.h:817
AdvancedDenseOptimizationProvider()
Protected default constructor.
Definition NonLinearOptimization.h:779
void applyCorrection(const Matrix &deltas)
Creates a new model candidate by adjusting the current model with delta values.
Definition NonLinearOptimization.h:796
void acceptCorrection()
Accepts the current model candidate a new (better) model than the previous one.
Definition NonLinearOptimization.h:845
bool determineParameters()
Determines any kind of (abstract) parameters based on the current/actual model (not the model candida...
Definition NonLinearOptimization.h:834
bool shouldStop()
Returns whether the optimization process should stop e.g., due to an external event.
Definition NonLinearOptimization.h:850
Scalar determineError()
Determines the error for the current model candidate (not the actual/actual model).
Definition NonLinearOptimization.h:828
bool solve(Matrix &deltas, const Scalar lambda=Scalar(0))
Solves the linear equation Hessian * deltas = -jacobianError based on the internal data.
Definition NonLinearOptimization.h:856
void applyCorrection(const Matrix &deltas)
Creates a new model candidate by adjusting the current/actual model with delta values.
Definition NonLinearOptimization.h:840
AdvancedSparseOptimizationProvider()
Protected default constructor.
Definition NonLinearOptimization.h:823
This class implements the base class for an accessor of groups of pairs.
Definition NonLinearOptimization.h:46
size_t groupElements(const size_t groupIndex) const
Returns the number of elements within a specified group.
Definition NonLinearOptimization.h:673
size_t groups() const
Returns the number of groups of this accessor.
Definition NonLinearOptimization.h:667
const TSecond & secondElement(const size_t groupIndex, const size_t elementIndex) const
Returns the first element of a pair of a specific group of this object.
Definition NonLinearOptimization.h:702
CorrespondenceGroupsAccessor< TFirst, TSecond > & operator=(const CorrespondenceGroupsAccessor< TFirst, TSecond > &accessor)
Copy constructor.
Definition NonLinearOptimization.h:711
void element(const size_t groupIndex, const size_t elementIndex, TFirst &first, TSecond &second) const
Returns one pair of a specific group of this object.
Definition NonLinearOptimization.h:681
const TFirst & firstElement(const size_t groupIndex, const size_t elementIndex) const
Returns the first element of a pair of a specific group of this object.
Definition NonLinearOptimization.h:693
CorrespondenceGroupsAccessor()
Creates a new accessor object.
Definition NonLinearOptimization.h:633
std::vector< Elements > ElementGroups
Definition of a vector holding a group of elements.
Definition NonLinearOptimization.h:62
CorrespondenceGroupsAccessor(const CorrespondenceGroupsAccessor< TFirst, TSecond > &accessor)
Copy constructor.
Definition NonLinearOptimization.h:653
std::vector< Element > Elements
Definition of a vector holding elements.
Definition NonLinearOptimization.h:57
std::pair< Index32, Vector2 > Element
Definition of a pair combining an object point id with an image point.
Definition NonLinearOptimization.h:52
ElementGroups elementGroups_
The groups of elements of this accessor.
Definition NonLinearOptimization.h:150
ObjectPointGroupsAccessor()
Creates a new accessor object.
Definition NonLinearOptimization.h:728
size_t addObjectPoint(Elements &&poseIdImagePointPairs)
Adds the observations of a new object point to this accessor.
Definition NonLinearOptimization.h:951
ObjectPointToPoseIndexImagePointCorrespondenceAccessor()=default
Default constructor.
This class implements the base optimization provider.
Definition NonLinearOptimization.h:292
bool solve(const Matrix &JTJ, const Matrix &jErrors, Matrix &deltas) const
Solves the linear equation JTJ * deltas = jErrors.
Definition NonLinearOptimization.h:767
bool hasSolver() const
Returns whether the provider comes with an own solver for the linear equation.
Definition NonLinearOptimization.h:762
PoseGroupsAccessor()
Creates a new accessor object.
Definition NonLinearOptimization.h:745
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition NonLinearOptimization.h:33
friend class NonLinearUniversalOptimizationDense
Definition NonLinearOptimization.h:34
static bool denseOptimization(T &provider, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
Invokes the optimization of a dense (matrix) optimization problem.
Definition NonLinearOptimization.h:963
static bool sparseOptimization(T &provider, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
Invokes the optimization of a sparse (matrix) optimization problem.
Definition NonLinearOptimization.h:1192
static Scalar sqrErrors2robustErrors_i(const Scalars &sqrErrors, const size_t modelParameters, const size_t dimension, Scalar *weightedErrors_i, Scalar *weightVectors_i, const Matrix *transposedInvertedCovariances_i)
Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
Definition NonLinearOptimization.h:1806
static Scalar sqrErrors2robustErrors2(const Scalars &sqrErrors, const size_t modelParameters, Vector2 *weightedErrors, Vector2 *weightVectors, const SquareMatrix2 *transposedInvertedCovariances)
Translates the n/2 squared errors that correspond to n elements in the error vector to robust errors.
Definition NonLinearOptimization.h:1735
static bool advancedDenseOptimization(T &advancedDenseProvider, const unsigned int iterations, Scalar lambda, const Scalar lambdaFactor, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Invokes the optimization of a dense (matrix) optimization problem using an advanced optimization prov...
Definition NonLinearOptimization.h:1431
static Scalar sqrErrors2robustErrors(const Scalars &sqrErrors, const size_t modelParameters, StaticBuffer< Scalar, tDimension > *weightedErrors, StaticBuffer< Scalar, tDimension > *weightVectors, const Matrix *transposedInvertedCovariances)
Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
Definition NonLinearOptimization.h:1770
static bool advancedSparseOptimization(T &advancedSparseProvider, const unsigned int iterations, Scalar lambda, const Scalar lambdaFactor, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Invokes the optimization of a sparse (matrix) optimization problem using an advanced optimization pro...
Definition NonLinearOptimization.h:1599
MatrixT< T > transposedMultiply(const MatrixT< T > &right) const
Multiplies this transposed matrix with a second matrix.
void weightedSelfTransposedSquareMatrix(const MatrixT< T > &weightDiagonal, MatrixT< T > &result) const
Returns the matrix product of transposed matrix of this matrix and this matrix and applies a further ...
size_t columns() const
Returns the count of columns.
Definition Matrix.h:709
MatrixT< T > selfTransposedSquareMatrix() const
Returns the matrix product of transposed matrix of this matrix and this matrix.
size_t elements() const
Returns the number of entire elements, which is the product of rows and columns.
Definition Matrix.h:715
MatrixT< T > diagonal() const
Returns a vector containing the values of the diagonal.
T norm() const
Determines the L1 norm (sum of absolute elements) of this matrix.
Definition Matrix.h:784
@ MP_SYMMETRIC
Definition Matrix.h:79
size_t rows() const
Returns the count of rows.
Definition Matrix.h:703
bool selfSquareDiagonalMatrixMultiply(const MatrixT< T > &right, MatrixT< T > &result) const
Interprets this matrix as diagonal matrix and multiplies a second matrix on the right of the interpre...
bool solve(const MatrixT< T > &b, MatrixT< T > &x, const MatrixProperty matrixProperty=MP_UNKNOWN) const
Solves the given linear system.
Definition Matrix.h:721
static constexpr Scalar weakEps()
static constexpr bool isWeakEqualEps(const Scalar value)
static constexpr Scalar eps()
static bool isEqual(const Scalar first, const Scalar second)
static constexpr Scalar sqr(const Scalar value)
static constexpr bool isEqualEps(const Scalar value)
static constexpr bool isNotEqualEps(const Scalar value)
static Scalar summedSqr(const Scalar *values, const size_t number)
static constexpr Scalar maxValue()
bool isZero(const size_t row, const size_t column) const
Returns whether a specified elements is zero.
SparseMatrixT< T > transposed() const
Returns the transposes matrix of this matrix.
size_t rows() const
Returns the number of rows this matrix has.
size_t columns() const
Returns the number of columns this matrix has.
bool solve(const MatrixT< T > &b, MatrixT< T > &x) const
Solves the given linear system.
MatrixT< T > diagonal() const
Returns a vector containing the values of the diagonal.
SquareMatrixT2< T > transposed() const
Returns the transposed of this matrix.
Definition SquareMatrix2.h:651
This class implements a static buffer that has a fixed capacity.
Definition StaticBuffer.h:24
const T * data() const
Returns the buffer data pointer.
Definition StaticBuffer.h:240
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
unsigned int sqr(const char value)
Returns the square value of a given value.
Definition base/Utilities.h:1099
SparseMatrixT< Scalar > SparseMatrix
Definition of the SparseMatrix object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with s...
Definition SparseMatrix.h:30
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
SquareMatrixT2< Scalar > SquareMatrix2
Definition of the SquareMatrix2 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition SquareMatrix2.h:29
MatrixT< Scalar > Matrix
Definition of the Matrix object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single ...
Definition Matrix.h:25
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
float Scalar
Definition of a scalar type.
Definition Math.h:129
Namespace of the Geometry library.
Definition AbsoluteTransformation.h:20
The namespace covering the entire Ocean framework.
Definition Accessor.h:15