30 #include <gsl/gsl_sf_pow_int.h>
42 std::vector< std::vector<double> > positions,
43 std::vector< std::vector<double> > deriv_positions,
44 std::vector< std::vector<int> >& deriv_indices) {
47 if (positions.size() + deriv_positions.size() -
n_poly_coeffs_ != 0) {
49 ss <<
"Total size of positions and deriv_positions ("
50 << positions.size() <<
"+" << deriv_positions.size() <<
") should be "
53 "SolveFactory::SolveFactory",
62 std::vector< std::vector<double> > positions,
63 std::vector< std::vector<double> > deriv_positions,
64 std::vector< std::vector<int> >& deriv_indices) {
65 int nCoeffs = positions.size();
67 for (
int i = 0; i < nCoeffs; ++i) {
69 for (
int j = 0; j < int(poly_vec.size()); ++j) {
70 h_inv_(i+1, j+1) = poly_vec[j];
74 for (
size_t i = 0; i < deriv_positions.size(); ++i) {
78 h_inv_(i+1+nCoeffs, j+1) = deriv_vec[j];
88 for (
size_t j = 0; j < point.size(); ++j)
89 square_vector[i] *= gsl_sf_pow_int(x[j], point[j]);
95 std::vector<double> x,
96 std::vector<int> deriv_indices) {
105 for (
int i = 0; i < square_points_size; ++i) {
107 for (
int j = 0; j < dim; ++j) {
108 int power = point[j] - deriv_indices[j];
114 deriv_vec[i] *= gsl_sf_pow_int(x[j], power);
117 for (
int k = point[j]; k > power && k > 0; --k) {
126 const std::vector< std::vector<double> >& values,
127 const std::vector< std::vector<double> >& deriv_values) {
145 int nCoeffs = values.size();
146 int nDerivs = deriv_values.size();
147 if (values.size()+deriv_values.size() !=
size_t(
n_poly_coeffs_)) {
149 "SolveFactory::PolynomialSolve",
150 "Values and derivatives over or under constrained"
154 if (values[i].size() < values[0].size()) {
156 "The vector of values is too short");
159 for (
int i = 0; i < nDerivs; ++ i) {
160 if (deriv_values[i].size() < values[0].size()) {
162 "The vector of derivative values is too short");
167 if (values.size() != 0) {
168 valueDim = values[0].size();
169 }
else if (deriv_values.size() != 0) {
170 valueDim = deriv_values[0].size();
174 for (
size_t y_index = 0; y_index < values[0].size(); ++y_index) {
178 G(i+1) = values[i][y_index];
181 for (
int i = 0; i < nDerivs; ++i) {
182 G(i+nCoeffs+1) = deriv_values[i][y_index];
186 A(y_index+1, j+1) = A_vec(j+1);
void invert()
turns this matrix into its inverse
static std::vector< std::vector< int > > getNearbyPointsSquares(int pointDim, int polyOrderLower, int polyOrderUpper)
SolveFactory(int smoothing_order, int point_dim, int value_dim, std::vector< std::vector< double > > positions, std::vector< std::vector< double > > deriv_positions, std::vector< std::vector< int > > &deriv_indices)
std::vector< double > MakeSquareDerivVector(std::vector< double > position, std::vector< int > derivIndices)
void BuildHInvMatrix(std::vector< std::vector< double > > positions, std::vector< std::vector< double > > deriv_positions, std::vector< std::vector< int > > &deriv_indices)
SquarePolynomialVector * PolynomialSolve(const std::vector< std::vector< double > > &values, const std::vector< std::vector< double > > &deriv_values)
SquarePolynomialVector square_temp_
std::vector< std::vector< int > > square_points_
std::vector< double > MakeSquareVector(std::vector< double > position)
SquarePolynomialVector describes a vector of multivariate polynomials.
static unsigned int NumberOfPolynomialCoefficients(int pointDimension, int order)
void SetCoefficients(int pointDim, MMatrix< double > coeff)