|
gramods
|
This is a polygonal fitter for any number of in- and output dimensions allowing for inter- and extrapolation. More...
#include <PolyFit.hh>
Classes | |
| struct | Impl |
Public Types | |
| typedef Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > | polco |
| Matrix holding the polynomial coefficients, one row for each output dimension. | |
Public Member Functions | |
| PolyFit (size_t idim, size_t odim, size_t ord) | |
| Creates a PolyFit instance for the specified number of input and output dimensions, and polynomial order. | |
| PolyFit (const std::vector< std::vector< double > > &invals, const std::vector< std::vector< double > > &outvals, size_t ord) | |
| Creates a PolyFit instance and adds the specified sample values. | |
| void | addSample (const std::vector< double > &inval, const std::vector< double > &outval) |
| Add a sample specifying the relation between input and output values. | |
| polco | estimateCoefficients () const |
| Estimate and return the coefficients of the polynomial that best fits the data. | |
| std::vector< double > | getValue (const std::vector< double > &inval) const |
| Estimates the polynomial result from the specified input. | |
| Eigen::MatrixXd | getJacobian (const std::vector< double > &in_values) const |
| Estimates the polynomial Jacobian from the specified input. | |
| double | getSingle (double inval) const |
| Convenience method for 1D polynomials. | |
| double | getDerivative (double inval) const |
| Estimates the polynomial derivative from the specified input for 1D polynomials. | |
| void | clear () |
| Resets the contents of this object. | |
This is a polygonal fitter for any number of in- and output dimensions allowing for inter- and extrapolation.
| typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> gramods::gmMisc::PolyFit::polco |
Matrix holding the polynomial coefficients, one row for each output dimension.
| gramods::gmMisc::PolyFit::PolyFit | ( | size_t | idim, |
| size_t | odim, | ||
| size_t | ord | ||
| ) |
Creates a PolyFit instance for the specified number of input and output dimensions, and polynomial order.
| [in] | idim | Input dimensionality. |
| [in] | odim | Output dimensionality. |
| [in] | ord | Order of the polynomial. |
| gramods::gmMisc::PolyFit::PolyFit | ( | const std::vector< std::vector< double > > & | invals, |
| const std::vector< std::vector< double > > & | outvals, | ||
| size_t | ord | ||
| ) |
Creates a PolyFit instance and adds the specified sample values.
| void gramods::gmMisc::PolyFit::addSample | ( | const std::vector< double > & | inval, |
| const std::vector< double > & | outval | ||
| ) |
Add a sample specifying the relation between input and output values.
The dimensions must match the dimensionality of the object or exception will be thrown.
| [in] | inval | The parameter value that should give rise to the specified output value. |
| [in] | outval | The output value for the specified inval. |
| void gramods::gmMisc::PolyFit::clear | ( | ) |
Resets the contents of this object.
| PolyFit::polco gramods::gmMisc::PolyFit::estimateCoefficients | ( | ) | const |
Estimate and return the coefficients of the polynomial that best fits the data.
The order for these components matches the recursive expansion of [ 1, x, x², ... ] × [ 1, y, y², ... ] × ... into [ 1, x, x², ..., yx, yx², ..., y²x, y²x², ... ] (column wise) for each output (row wise).
This method will cache the coefficients until new samples have been added.
| double gramods::gmMisc::PolyFit::getDerivative | ( | double | inval | ) | const |
Estimates the polynomial derivative from the specified input for 1D polynomials.
This method calls estimateCoefficients (if necessary) and calculates the resulting polynomial with the specified input.
| Eigen::MatrixXd gramods::gmMisc::PolyFit::getJacobian | ( | const std::vector< double > & | in_values | ) | const |
Estimates the polynomial Jacobian from the specified input.
This method calls estimateCoefficients (if necessary) and calculates the Jacobian of the polynomial with the specified input. For n input variables, x₀ to xₙ, and m output variables, y₀ to yₘ, the returned matrix follows the convention
![\[
\left(
\begin{array}{cccc}
\frac{\partial y_0}{\partial x_0} & \frac{\partial y_0}{\partial x_1} & \dots & \frac{\partial y_0}{\partial x_n} \\
\frac{\partial y_1}{\partial x_0} & \frac{\partial y_1}{\partial x_1} & \dots & \frac{\partial y_1}{\partial x_n} \\
\vdots \\
\frac{\partial y_m}{\partial x_0} & \frac{\partial y_m}{\partial x_1} & \dots & \frac{\partial y_m}{\partial x_n}
\end{array}
\right)
\]](form_0.png)
The dimensions of the input must match the dimensionality of the object or exception will be thrown.
| double gramods::gmMisc::PolyFit::getSingle | ( | double | inval | ) | const |
Convenience method for 1D polynomials.
| std::vector< double > gramods::gmMisc::PolyFit::getValue | ( | const std::vector< double > & | inval | ) | const |
Estimates the polynomial result from the specified input.
This method calls estimateCoefficients (if necessary) and calculates the resulting polynomial with the specified input. This method can be used both for inter- and extrapolation.
The dimensions of the input must match the dimensionality of the object or exception will be thrown.