Base class to handle Radial Basis Function with a large set of nodes. More...


Public Member Functions | |
RBFKernel () | |
RBFKernel (const RBFKernel &other) | |
void | activateAllNodes () |
bool | activateNode (const std::vector< int > &) |
bool | activateNode (int) |
int | addData () |
int | addData (const std::vector< double > &) |
void | deactivateAllNodes () |
bool | deactivateNode (const std::vector< int > &) |
bool | deactivateNode (int) |
void | enablePolynomial (bool enable=true) |
double | evalBasis (double) |
double | evalBasisPair (int i, int j) |
std::vector< double > | evalRBF (const std::array< double, 3 > &) |
std::vector< double > | evalRBF (int jnode) |
void | fitDataToNodes () |
void | fitDataToNodes (int) |
int | getActiveCount () |
std::vector< int > | getActiveSet () |
int | getDataCount () |
RBFBasisFunction | getFunctionType () |
RBFMode | getMode () |
int | getPolynomialDimension () |
int | getPolynomialWeightsCount () |
double | getSupportRadius () |
double | getSupportRadius (int) |
const std::vector< std::vector< double > > & | getWeights () const |
int | greedy (double) |
bool | isActive (int) |
void | removeAllData () |
bool | removeData (int) |
bool | removeData (std::vector< int > &) |
void | setDataToAllNodes (int, const std::vector< double > &) |
void | setDataToNode (int, const std::vector< double > &) |
void | setFunction (double(&funct)(double)) |
void | setFunction (RBFBasisFunction) |
void | setMode (RBFMode mode) |
void | setSupportRadius (const std::vector< double > &) |
void | setSupportRadius (double) |
int | solve () |
Protected Member Functions | |
int | addGreedyPoint () |
double | evalError () |
int | solveLSQ () |
void | swap (RBFKernel &x) noexcept |
Protected Attributes | |
std::vector< bool > | m_activeNodes |
int | m_maxFields |
int | m_nodes |
std::vector< int > | m_polyActiveBasis |
bool | m_polyEnabled |
LinearPolynomial | m_polynomial |
std::vector< std::vector< double > > | m_value |
std::vector< std::vector< double > > | m_weight |
Detailed Description
Base class to handle Radial Basis Function with a large set of nodes.
The class can be used in two different ways:
- as interpolator, given a set of external fields
- as parameterizator, directly modifying the weights of rbf kernels.
The User can switch between modes, according to its needs. Some internal methods of the class can change their behaviour according to the class mode selected. Please check documentation of each single method to appreciate the differences. Default mode of the class is the "INTERP" RBFMode:: In case of interpolation the contribution of a linear polynomial can be added to regularize the interpolation problem by enabling the polynomial usage.
The actual abstract class does not implement the type of node you want to use; it can be a 3D point or an unstructured mesh. Anyway what you have to do in deriving your own RBF class is to specify a type of node you want to use and implement an evaluator of distances node/node or anywhere point in space/node.
Constructor & Destructor Documentation
◆ RBFKernel() [1/2]
bitpit::RBFKernel::RBFKernel | ( | ) |
Default constructor. RBFBasisFunction is WENDLANDC2 by default. RBFMode is INTERP, by default. Use setFunction and setMode for changing it.
◆ RBFKernel() [2/2]
bitpit::RBFKernel::RBFKernel | ( | const RBFKernel & | other | ) |
Member Function Documentation
◆ activateAllNodes()
void bitpit::RBFKernel::activateAllNodes | ( | ) |
◆ activateNode() [1/2]
bool bitpit::RBFKernel::activateNode | ( | const std::vector< int > & | list | ) |
◆ activateNode() [2/2]
bool bitpit::RBFKernel::activateNode | ( | int | n | ) |
◆ addData() [1/2]
int bitpit::RBFKernel::addData | ( | ) |
Increment container size for RBFKernel control data.The RBFKernel::fitDataToNodes() method is implicitly called, to ensure dimension consistency between data dimension and number of RBFKernel nodes. Use RBFKernel::setDataToAllNodes to fill them. In INTERP mode, increments and fits fields container, in PARAM mode, the weights one.
- Returns
- id of virtual data within the class
- Examples
- RBF_example_00001.cpp.
◆ addData() [2/2]
int bitpit::RBFKernel::addData | ( | const std::vector< double > & | data | ) |
Adds data attached to RBFKernel nodes to current set, a field to be interpolated in INTERP mode, a RBFKernel weight component in PARAM mode. Note: data vector is added even if its size is different from actual number of RBFKernel nodes. To ensure consistency use fitDataToNodes() method.
- Parameters
-
[in] data values of weight/fields for each RBFKernel node
- Returns
- id of data within the class
◆ addGreedyPoint()
|
protected |
◆ deactivateAllNodes()
void bitpit::RBFKernel::deactivateAllNodes | ( | ) |
◆ deactivateNode() [1/2]
bool bitpit::RBFKernel::deactivateNode | ( | const std::vector< int > & | list | ) |
◆ deactivateNode() [2/2]
bool bitpit::RBFKernel::deactivateNode | ( | int | n | ) |
◆ enablePolynomial()
void bitpit::RBFKernel::enablePolynomial | ( | bool | enable = true | ) |
◆ evalBasis()
double bitpit::RBFKernel::evalBasis | ( | double | dist | ) |
◆ evalBasisPair()
double bitpit::RBFKernel::evalBasisPair | ( | int | i, |
int | j ) |
Evaluates the contribution of the node j on the value of the basis at node i
- Parameters
-
[in] i point at which the basis function contribution is computed [in] j point from which the basis function contribution is computed
- Returns
- basis function contribution from j to i
- Examples
- RBF_example_00001.cpp.
◆ evalError()
|
protected |
◆ evalRBF() [1/2]
std::vector< double > bitpit::RBFKernel::evalRBF | ( | const std::array< double, 3 > & | point | ) |
Evaluates the RBF. Supported in both modes. Its size matches the number of fields/weights attached to RBF.
- Parameters
-
[in] point point where to evaluate the basis
- Returns
- vector containing interpolated/parameterized values.
- Examples
- RBF_example_00001.cpp.
◆ evalRBF() [2/2]
std::vector< double > bitpit::RBFKernel::evalRBF | ( | int | jnode | ) |
◆ fitDataToNodes() [1/2]
void bitpit::RBFKernel::fitDataToNodes | ( | ) |
Check dimensions of already available data and resize them to current RBFKernel node list dimension. The method resizes all data structures to current RBFKernel node list dimension and does not destroy any previous stored data within such dimension. Anyway, mismatches definitions could occur. Please use RBFKernel::setDataToAllNodesto load your data again. In RBFMode::PARAM mode data are meant as RBFKernel weights In RBFMode::INTERP mode data are meant as fields to be interpolated
◆ fitDataToNodes() [2/2]
void bitpit::RBFKernel::fitDataToNodes | ( | int | id | ) |
Check dimensions id-th data and resize it to current RBFKernel node list dimension. The method resizes id-th data structure to current RBFKernel node list dimension and does not destroy any previous stored data within such dimension. Anyway, mismatches definitions could occur. Please use RBFKernel::setDataToAllNodes to load your data again. In RBFMode::PARAM mode data are meant as RBFKernel weights In RBFMode::INTERP mode data are meant as fields to be interpolated
- Parameters
-
[in] id id of data
◆ getActiveCount()
int bitpit::RBFKernel::getActiveCount | ( | ) |
◆ getActiveSet()
std::vector< int > bitpit::RBFKernel::getActiveSet | ( | ) |
◆ getDataCount()
int bitpit::RBFKernel::getDataCount | ( | ) |
◆ getFunctionType()
RBFBasisFunction bitpit::RBFKernel::getFunctionType | ( | ) |
Gets the type of RBFBasisFunction linked to the class.
- Returns
- type of RBFBasisFunction linked
◆ getMode()
RBFMode bitpit::RBFKernel::getMode | ( | ) |
◆ getPolynomialWeightsCount()
int bitpit::RBFKernel::getPolynomialWeightsCount | ( | ) |
◆ getSupportRadius() [1/2]
double bitpit::RBFKernel::getSupportRadius | ( | ) |
◆ getSupportRadius() [2/2]
double bitpit::RBFKernel::getSupportRadius | ( | int | i | ) |
◆ getWeights()
const std::vector< std::vector< double > > & bitpit::RBFKernel::getWeights | ( | ) | const |
◆ greedy()
int bitpit::RBFKernel::greedy | ( | double | tolerance | ) |
Determines effective set of nodes to be used using greedy algorithm and calculate weights on them. Automatically choose which set of RBFKernel nodes is active or not, according to the given tolerance. Supported ONLY in INTERP mode.
- Parameters
-
[in] tolerance error tolerance for adding nodes
- Returns
- integer error flag . If 0-successfull computation and tolerance met, if 1-errors occurred, not enough nodes, if -1 dummy method call
◆ isActive()
bool bitpit::RBFKernel::isActive | ( | int | n | ) |
◆ removeAllData()
void bitpit::RBFKernel::removeAllData | ( | ) |
◆ removeData() [1/2]
bool bitpit::RBFKernel::removeData | ( | int | id | ) |
◆ removeData() [2/2]
bool bitpit::RBFKernel::removeData | ( | std::vector< int > & | list | ) |
Remove pre-existent set of data. RBF Data list is resized and renumbered after extraction. In PARAM mode data are meant as RBF weights In INTERP mode data are meant as fields to be interpolated
- Parameters
-
[in] list id list of candidates to extraction
- Returns
- boolean, true if all data set are successfully extracted, false if any of them are not extracted
◆ setDataToAllNodes()
void bitpit::RBFKernel::setDataToAllNodes | ( | int | id, |
const std::vector< double > & | value ) |
◆ setDataToNode()
void bitpit::RBFKernel::setDataToNode | ( | int | id, |
const std::vector< double > & | value ) |
Sets all the type of available data at one node. In INTERP mode, set each field value at the target node In PARAM mode, set the weight coefficient array at node
- Parameters
-
[in] id id of node [in] value data values to be set as RBFKernel parameters for the given node
◆ setFunction() [1/2]
void bitpit::RBFKernel::setFunction | ( | double(&)(double) | bfunc | ) |
◆ setFunction() [2/2]
void bitpit::RBFKernel::setFunction | ( | RBFBasisFunction | bfunc | ) |
Sets the rbf function to be used. Supported in both modes.
- Parameters
-
[in] bfunc basis function to be used
- Examples
- RBF_example_00001.cpp.
◆ setMode()
void bitpit::RBFKernel::setMode | ( | RBFMode | mode | ) |
Set usage mode of your class.
- Parameters
-
[in] mode class mode. Ref to RBFMode enum
- Examples
- RBF_example_00001.cpp.
◆ setSupportRadius() [1/2]
void bitpit::RBFKernel::setSupportRadius | ( | const std::vector< double > & | radius | ) |
◆ setSupportRadius() [2/2]
void bitpit::RBFKernel::setSupportRadius | ( | double | radius | ) |
Set the support radius of all RBFKernel kernel functions. Supported in both modes.
- Parameters
-
[in] radius support radius
- Examples
- RBF_example_00001.cpp.
◆ solve()
int bitpit::RBFKernel::solve | ( | ) |
Calculates the RBF weights using all currently active nodes and just given target fields. Regular LU solver for linear system A*X=B is employed (LAPACKE dgesv). Supported ONLY in INTERP mode.
- Returns
- integer error flag . If 0-successfull computation, if 1-errors occurred, if -1 dummy method call
◆ solveLSQ()
|
protected |
Calculates the RBFKernel weights using all active nodes and just given target fields. Compute weights as solution of a linear least squares problem (LAPACKE dglsd). Supported ONLY in INTERP mode.
- Returns
- integer error flag . If 0-successfull computation, if 1-errors occurred , -1 dummy call
◆ swap()
|
protectednoexcept |
Member Data Documentation
◆ m_activeNodes
|
protected |
◆ m_maxFields
|
protected |
◆ m_nodes
|
protected |
◆ m_polyActiveBasis
|
protected |
◆ m_polyEnabled
|
protected |
◆ m_polynomial
|
protected |
◆ m_value
|
protected |
◆ m_weight
|
protected |
The documentation for this class was generated from the following files:
