OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Public Member Functions | Private Member Functions | Private Attributes | List of all members
interpolation::SolveFactory Class Reference

SolveFactory is a factory class for solving a set of linear equations to generate a polynomial based on nearby points. More...

#include <SolveFactory.h>

Collaboration diagram for interpolation::SolveFactory:
Collaboration graph
[legend]

Public Member Functions

 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)
 
 ~SolveFactory ()
 
SquarePolynomialVectorPolynomialSolve (const std::vector< std::vector< double > > &values, const std::vector< std::vector< double > > &deriv_values)
 
std::vector< double > MakeSquareVector (std::vector< double > position)
 
std::vector< double > MakeSquareDerivVector (std::vector< double > position, std::vector< int > derivIndices)
 

Private Member Functions

void BuildHInvMatrix (std::vector< std::vector< double > > positions, std::vector< std::vector< double > > deriv_positions, std::vector< std::vector< int > > &deriv_indices)
 

Private Attributes

int n_poly_coeffs_
 
std::vector< std::vector< int > > square_points_
 
std::vector< std::vector< int > > square_deriv_nearby_points_
 
SquarePolynomialVector square_temp_
 
MMatrix< double > h_inv_
 

Detailed Description

SolveFactory is a factory class for solving a set of linear equations to generate a polynomial based on nearby points.

See also PPSolveFactory for more details

Definition at line 44 of file SolveFactory.h.

Constructor & Destructor Documentation

◆ SolveFactory()

interpolation::SolveFactory::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 
)

Construct a new SolveFactory.

Parameters
polynomial_orderOrder of the polynomial part of the fit
smoothing_orderOrder of the smoothing part of the fit; should always be >= polynomial_order
point_dimDimension of the points (i.e. space of x), for y = f(x)
value_dimDimension of the values (i.e. space of y), for y = f(x)
positionsPosition of the values; should be a vector of length polynomial_order^point_dim. Each element should be a vector of length point_dim
deriv_positionsPosition of the derivatives; should be a vector of length smoothing_order^point_dim - polynomial_order^point_dim. Each element should be a vector of length point_dim.
deriv_indicesIndex the derivatives. Should be a vector with same length as deriv_positions. Each element should be a vector of length point_dim. Each element tells us what derivative will be defined, indexing by the order of the derivative.

The constructor takes the set of positions; then performs a matrix inversion. Each call to PolynomialSolve uses the same matrix inversion in solution of the linear equations (hence when we do this lots of times as in PolynomialPatch, we get a lot faster). The matrix inversion can fail for badly formed sets of positions/deriv_positions; caveat emptor!

Definition at line 39 of file SolveFactory.cpp.

References BuildHInvMatrix(), interpolation::PPSolveFactory::getNearbyPointsSquares(), n_poly_coeffs_, interpolation::SquarePolynomialVector::NumberOfPolynomialCoefficients(), square_points_, and square_temp_.

Here is the call graph for this function:

◆ ~SolveFactory()

interpolation::SolveFactory::~SolveFactory ( )
inline

Destructor; does nothing

Definition at line 82 of file SolveFactory.h.

Member Function Documentation

◆ BuildHInvMatrix()

void interpolation::SolveFactory::BuildHInvMatrix ( std::vector< std::vector< double > >  positions,
std::vector< std::vector< double > >  deriv_positions,
std::vector< std::vector< int > > &  deriv_indices 
)
private

Definition at line 61 of file SolveFactory.cpp.

References h_inv_, interpolation::MMatrix< Tmplt >::invert(), MakeSquareDerivVector(), MakeSquareVector(), and n_poly_coeffs_.

Referenced by SolveFactory().

Here is the call graph for this function:

◆ MakeSquareDerivVector()

std::vector< double > interpolation::SolveFactory::MakeSquareDerivVector ( std::vector< double >  position,
std::vector< int >  derivIndices 
)

Convert a position vector to a derivative of a set of polynomial products

Parameters
positiona position vector \( x_{b} \)
derivIndicesindexes the derivative, \(\vec{q} \)

Return value is a set of derivatives of polynomial products \( p_j!/(p_j-q_j)! x_{b_j}^{p_j-q_j} \)

Definition at line 94 of file SolveFactory.cpp.

References square_points_.

Referenced by BuildHInvMatrix().

◆ MakeSquareVector()

std::vector< double > interpolation::SolveFactory::MakeSquareVector ( std::vector< double >  position)

Convert a position vector to a set of polynomial products

Parameters
positiona position vector \( x_{b} \)

Return value is a set of polynomial products \( x_{b}^{p} \)

Definition at line 84 of file SolveFactory.cpp.

References square_points_.

Referenced by BuildHInvMatrix().

◆ PolynomialSolve()

SquarePolynomialVector * interpolation::SolveFactory::PolynomialSolve ( const std::vector< std::vector< double > > &  values,
const std::vector< std::vector< double > > &  deriv_values 
)

Solve to get a SquarePolynomialVector

Parameters
valuesSet of y values for the solve, giving function values at the positions defined in the constructor
deriv_valuesSet of y derivatives for the solve, giving q^th derivatives, q defined by deriv_indices, at positions defined by deriv_positions (in constructor)

Definition at line 125 of file SolveFactory.cpp.

References h_inv_, n_poly_coeffs_, interpolation::SquarePolynomialVector::SetCoefficients(), and square_temp_.

Referenced by interpolation::PPSolveFactory::solve().

Here is the call graph for this function:

Member Data Documentation

◆ h_inv_

MMatrix<double> interpolation::SolveFactory::h_inv_
private

Definition at line 123 of file SolveFactory.h.

Referenced by BuildHInvMatrix(), and PolynomialSolve().

◆ n_poly_coeffs_

int interpolation::SolveFactory::n_poly_coeffs_
private

Definition at line 118 of file SolveFactory.h.

Referenced by BuildHInvMatrix(), PolynomialSolve(), and SolveFactory().

◆ square_deriv_nearby_points_

std::vector< std::vector<int> > interpolation::SolveFactory::square_deriv_nearby_points_
private

Definition at line 120 of file SolveFactory.h.

◆ square_points_

std::vector< std::vector<int> > interpolation::SolveFactory::square_points_
private

Definition at line 119 of file SolveFactory.h.

Referenced by MakeSquareDerivVector(), MakeSquareVector(), and SolveFactory().

◆ square_temp_

SquarePolynomialVector interpolation::SolveFactory::square_temp_
private

Definition at line 122 of file SolveFactory.h.

Referenced by PolynomialSolve(), and SolveFactory().


The documentation for this class was generated from the following files: