cisst-saw
Loading...
Searching...
No Matches
cisstNumerical

Classes

class  nmrFminSolver
class  nmrFnJacobianSolver
class  nmrFnSolver
class  nmrHFTISolver
class  nmrInverseDynamicData
 Data for Inverse problem (Dynamic). More...
class  nmrInverseFixedSizeData< _size, _storageOrder >
 Data for Inverse problem (Fixed size). More...
class  nmrIsOrthonormalDynamicData< _elementType >
 Data (workspace) for nmrIsOrthonormal (Dynamic). More...
class  nmrIsOrthonormalFixedSizeData< _elementType, _rows >
 Data for nmrIsOrthonormal (Fixed size). More...
class  nmrLDPSolver
class  nmrLinearRegressionSolver< _elementType >
class  nmrLinearRegressionWindowSolver< _elementType >
class  nmrLinearRegressionWindowRecursiveSolver< _elementType >
class  nmrLSEISolver
class  nmrLSISolver
class  nmrLSNonLinJacobianSolver
class  nmrLSNonLinSolver
class  nmrLSqLinSolutionDynamic
class  nmrLSSolver
class  nmrLUDynamicData
 Data of LU problem (Dynamic). More...
class  nmrLUFixedSizeData< _rows, _cols >
 Data of LU problem (Fixed size). More...
class  nmrLUSolver
class  nmrNNLSSolver
class  nmrPInverseEconomyDynamicData
class  nmrPInverseSolver
class  nmrPolynomialTermPowerIndex
 Represents the power index of a single term in a multi-variable polynomial. More...
class  nmrStandardPolynomial
class  nmrSVDDynamicData
 Data for SVD problem (Dynamic). More...
class  nmrSVDFixedSizeData< _rows, _cols, _storageOrder >
 Data of SVD problem (Fixed size). More...
class  nmrSVDEconomyDynamicData
 Data for SVD problem (Dynamic). More...
class  nmrSVDRSSolver
class  nmrSVDSolver

Functions

 nmrBernsteinPolynomial (VariableIndexType numVariables, PowerType degree)
template<class _vectorType>
bool nmrLinearRegression (const _vectorType &x, const _vectorType &y, typename _vectorType::value_type &slope, typename _vectorType::value_type &yint, typename _vectorType::value_type *mse=0, typename _vectorType::value_type tolerance=cmnTypeTraits< typename _vectorType::value_type >::DefaultTolerance)

Detailed Description

The main features of cisstNumerical are:

Note
All the classes and global functions of cisstNumerical start with the prefix nmr. To use cisstNumerical, you can either include a specific file with:
#include <cisstNumerical/nmrXyz.h>
or include all the files with:

Function Documentation

◆ nmrBernsteinPolynomial()

nmrBernsteinPolynomial ( VariableIndexType numVariables,
PowerType degree )

class nmrBernsteinPolynomial defines a polynomial in Bernstein basis. In a Bernstein polynomial, all the terms are of equal degree (that is, the sum of powers is a constant), and the variables sum up to a unity. Each term is associated with a scalar coefficient and with a multinomial factor, which reflects the relative weight of the term in the expression:

\(1 = (x_0 + ... + x_{n-1}) ^ d = \sum_{(p_0 + ... + p_{n-1}) = d} \choose{d}{p_0 p_1 ... p_{n-1}} x_0^{p_0} ... x_{n-1}^{p_{n-1}}\)

To make repeated evaluations quicker, we cache the multinomial factor along with the coefficient of the term in a BernsteinTermInfo object. Appropriate accessors are defined.

Since the sum of the variables is 1, one of the variables depends on the others. Typically, it is either the last or the first, but the user can choose any variable to be the ``implicit'' variable. Once the implicit variable has been determined, its value cannot be updated directly, and instead it is reassigned every time one of the other variables is set. However, the user of the class still has the flexibility to replace the choice of the implicit variable at any time. The only thing that matters is that the variables sum to 1.

Note: We use dynamic allocation for the term information (BernsteinTermInfo), which is separate from the STL provided dynamic allocation for the container elements. We store the pointer to the dynamically allocated term info in the container. Therefore:

  1. We had to override the base-class's RemoveTerm() and Clear() methods.
  2. Do not even try to make a copy of a nmrBernsteinPolynomial using copy-ctor or operator= (yeah, like you would). Just for safety, we declare these operations protected, and do not provide implementation.
  3. A better solution may be to define a common base type for TermInfo, and have it declare a virtual dtor. Go for it, if you have time. */ class CISST_EXPORT nmrBernsteinPolynomial : public nmrDynAllocPolynomialContainer { public: typedef nmrDynAllocPolynomialContainer BaseType;

    typedef std::pair<nmrPolynomialBase::CoefficientType, nmrPolynomialTermPowerIndex::MultinomialCoefficientType> BernsteinTermInfo;

ifdef CISST_COMPILER_IS_MSVC /*! Constructor determines the number of variables and the degree of the polynomial. Note that Bernstein polynomial contains an additional implicit variable. The argument numVariables must include the implicit variable, since we want to be consistent with the GetNumVariables() method. The degree defines both maximum and minimum degrees for the terms, as all terms are of equal degree. The constructor initializes the free variables to zero, and the implicit variable to 1, so that they all sum up to

  1. The constructor sets the implicit variable to be the last one (the numVariable - 1) by default. The user can change this setting by calling SetImplicitVarIndex().

◆ nmrLinearRegression()

template<class _vectorType>
bool nmrLinearRegression ( const _vectorType & x,
const _vectorType & y,
typename _vectorType::value_type & slope,
typename _vectorType::value_type & yint,
typename _vectorType::value_type * mse = 0,
typename _vectorType::value_type tolerance = cmnTypeTraits<typename _vectorType::value_type>::DefaultTolerance )

This computes a linear regression using the least-squares solution. If the regression is successfully computed, the function returns true; otherwise it returns false. Possible reasons for failure are if the x and y vectors are different sizes, if there are fewer than 2 points, or if the line is near vertical (near infinite slope). Note that this check is based on a specified tolerance value. The default tolerances are obtained from cmnTypeTraits. These defaults may be too large for some applications (e.g., the default for float is currently 1e-5 and for double it is 1e-9).

Parameters
xA vector of all the x values
yA vector of all the y values
slopePointer for returning computed slope (if not null)
yintPointer for returning computed y-intercept (if not null)
msePointer for returning mean square error (if not null)
toleranceTolerance to use when checking for division by (near) 0 (default from cmnTypeTraits)
Returns
true if the linear regression is successful; false otherwise.