![]() |
Project
|
#include <MultivariatePolynomial.h>
Inherits o2::gpu::FlatObject, and o2::gpu::MultivariatePolynomialHelper< Dim, Degree, InteractionOnly >.
Public Member Functions | |
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim==0 &&Degree==0)), int32_t >::type = 0> | |
MultivariatePolynomial (const uint32_t nDim, const uint32_t degree, const bool interactionOnly=false) | |
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim !=0 &&Degree !=0)), int32_t >::type = 0> | |
MultivariatePolynomial () | |
constructor for compile time evaluation of polynomial formula | |
~MultivariatePolynomial ()=default | |
default destructor | |
MultivariatePolynomial (const MultivariatePolynomial &obj) | |
Copy constructor. | |
void | cloneFromObject (const MultivariatePolynomial &obj, char *newFlatBufferPtr) |
========== FlatObject functionality, see FlatObject class for description ================= | |
void | moveBufferTo (char *newBufferPtr) |
void | destroy () |
destroy the object (release internal flat buffer) | |
void | setActualBufferAddress (char *actualFlatBufferPtr) |
set location of external flat buffer | |
void | setFutureBufferAddress (char *futureFlatBufferPtr) |
set future location of the flat buffer | |
GPUd () float eval(const float x[]) const | |
================================================================================================ | |
uint32_t | getNParams () const |
void | setParams (const float params[]) |
void | setParam (const uint32_t param, const float val) |
const float * | getParams () const |
void | loadFromFile (TFile &inpf, const char *name) |
void | writeToFile (TFile &outf, const char *name) const |
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim==0 &&Degree==0)), int32_t >::type = 0> | |
void | fit (std::vector< double > &x, std::vector< double > &y, std::vector< double > &error, const bool clearPoints) |
MultivariatePolynomialContainer | getContainer () const |
converts the parameters to a container which can be written to a root file | |
void | setFromContainer (const MultivariatePolynomialContainer &container) |
![]() | |
FlatObject ()=default | |
_____________ Constructors / destructors __________________________ | |
~FlatObject () | |
FlatObject (const FlatObject &)=delete | |
FlatObject & | operator= (const FlatObject &)=delete |
void | destroy () |
_______________ Utilities _______________________________________________ | |
size_t | getFlatBufferSize () const |
Gives size of the flat buffer. | |
const char * | getFlatBufferPtr () const |
Gives pointer to the flat buffer. | |
bool | isConstructed () const |
Tells if the object is constructed. | |
bool | isBufferInternal () const |
Tells if the buffer is internal. | |
void | adoptInternalBuffer (char *buf) |
void | clearInternalBufferPtr () |
void | printC () const |
Print the content of the flat buffer. | |
![]() | |
GPUd () static const expr float evalPol(GPUgeneric() const float par[] | |
GPUd () static const expr uint32_t getDim() | |
GPUd () static const expr uint32_t getDegree() | |
GPUd () static const expr bool isInteractionOnly() | |
![]() | |
GPUd () static const expr uint32_t getNParametersAllTerms(const uint32_t degree | |
GPUd () static const expr uint32_t getNParametersInteractionOnly(const uint32_t degree | |
GPUd () static const expr uint32_t getNParameters(const uint32_t degree | |
Additional Inherited Members | |
![]() | |
static size_t | alignSize (size_t sizeBytes, size_t alignmentBytes) |
_______________ Generic utilities _______________________________________________ | |
template<class T > | |
static T * | relocatePointer (const char *oldBase, char *newBase, const T *ptr) |
Relocates a pointer inside a buffer to the new buffer address. | |
template<class T , class TFile > | |
static int32_t | writeToFile (T &obj, TFile &outf, const char *name) |
write a child class object to the file | |
template<class T , class TFile > | |
static T * | readFromFile (TFile &inpf, const char *name) |
read a child class object from the file | |
template<class T > | |
static std::string | stressTest (T &obj) |
Test the flat object functionality for a child class T. | |
![]() | |
const float | x [] { return par[0] + loopDegrees<1>(par, x) |
![]() | |
const uint32_t | dim { return (degree == 0) ? binomialCoeff(dim - 1, 0) : binomialCoeff(dim - 1 + degree, degree) + getNParametersAllTerms(degree - 1, dim) |
![]() | |
enum | ConstructionState : uint32_t { NotConstructed = 0x0 , Constructed = 0x1 , InProgress = 0x2 } |
GPUCA_GPUCODE. More... | |
![]() | |
void | startConstruction () |
_____________ Construction _________ | |
void | finishConstruction (int32_t flatBufferSize) |
void | cloneFromObject (const FlatObject &obj, char *newFlatBufferPtr) |
char * | releaseInternalBuffer () |
_____________ Methods for making the data buffer external __________________________ | |
void | moveBufferTo (char *newBufferPtr) |
void | setActualBufferAddress (char *actualFlatBufferPtr) |
_____________ Methods for moving the class with its external buffer to another location __________________________ | |
void | setFutureBufferAddress (char *futureFlatBufferPtr) |
ClassDefNV (FlatObject, 1) | |
Pointer to the flat buffer. | |
![]() | |
static constexpr size_t | getClassAlignmentBytes () |
_____________ Memory alignment __________________________ | |
static constexpr size_t | getBufferAlignmentBytes () |
Gives minimal alignment in bytes required for the flat buffer. | |
![]() | |
int32_t | mFlatBufferSize = 0 |
size of the flat buffer | |
uint32_t | mConstructionMask = ConstructionState::NotConstructed |
mask for constructed object members, first two bytes are used by this class | |
char * | mFlatBufferContainer = nullptr |
char * | mFlatBufferPtr = nullptr |
Class for multivariate polynomials. The parameters of the coefficients have to be provided as input and can be obtained from TLinear fitter or from sklearn (PolynomialFeatures) etc. The evaluation of the polynomials can be speed up by providing the dimensions and degree during compile time!
Usage: see example in testMultivarPolynomials.cxx Dim > 0 && Degree > 0 : the number of dimensions and the degree is known at compile time Dim = 0 && Degree = 0 : the number of dimensions and the degree will be set during runtime InteractionOnly: consider only interaction terms: ignore x[0]*x[0]..., x[1]*x[1]*x[2]... etc. terms (same feature as 'interaction_only' in sklearn https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PolynomialFeatures.html) can be used for N-linear interpolation (https://en.wikipedia.org/wiki/Trilinear_interpolation#Alternative_algorithm)
Definition at line 44 of file MultivariatePolynomial.h.
|
inline |
constructor for runtime evaluation of polynomial formula
nDim | number of dimensions |
degree | degree of the polynomial |
Definition at line 52 of file MultivariatePolynomial.h.
|
inline |
constructor for compile time evaluation of polynomial formula
Definition at line 59 of file MultivariatePolynomial.h.
|
default |
default destructor
|
inline |
Copy constructor.
Definition at line 72 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::cloneFromObject | ( | const MultivariatePolynomial< Dim, Degree, InteractionOnly > & | obj, |
char * | newFlatBufferPtr | ||
) |
========== FlatObject functionality, see FlatObject class for description =================
cloning a container object (use newFlatBufferPtr=nullptr for simple copy)
Definition at line 216 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::destroy | ( | ) |
destroy the object (release internal flat buffer)
Definition at line 252 of file MultivariatePolynomial.h.
|
inline |
performs fit of input point
x | position of the points of length 'Dim * nPoints' (structured as in https://root.cern.ch/doc/master/classTLinearFitter.html) |
y | values which will be fitted of length 'nPoints' |
error | error of weigths of the points (if empty no weights are applied) |
clearPoints | perform the fit on new data points |
Definition at line 130 of file MultivariatePolynomial.h.
|
inline |
converts the parameters to a container which can be written to a root file
Definition at line 141 of file MultivariatePolynomial.h.
|
inline |
Definition at line 100 of file MultivariatePolynomial.h.
|
inline |
Definition at line 111 of file MultivariatePolynomial.h.
|
inline |
================================================================================================
evaluates the polynomial for given coordinates
x | query coordinates |
Definition at line 96 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::loadFromFile | ( | TFile & | inpf, |
const char * | name | ||
) |
load parameters from input file (which were written using the writeToFile method)
inpf | input file \parma name name of the object in the file |
Definition at line 170 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::moveBufferTo | ( | char * | newBufferPtr | ) |
move flat buffer to new location
newBufferPtr | new buffer location |
Definition at line 232 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setActualBufferAddress | ( | char * | actualFlatBufferPtr | ) |
set location of external flat buffer
Definition at line 259 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setFromContainer | ( | const MultivariatePolynomialContainer & | container | ) |
set the parameters from MultivariatePolynomialContainer
container | container for the parameters |
Definition at line 183 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setFutureBufferAddress | ( | char * | futureFlatBufferPtr | ) |
set future location of the flat buffer
Definition at line 266 of file MultivariatePolynomial.h.
|
inline |
parameter | which will be set \val value of the parameter |
Definition at line 108 of file MultivariatePolynomial.h.
|
inline |
set the parameters for the coefficients of the polynomial
params | parameter for the coefficients |
Definition at line 104 of file MultivariatePolynomial.h.
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::writeToFile | ( | TFile & | outf, |
const char * | name | ||
) | const |
write parameters to file
outf | output file |
name | name of the output object |
Definition at line 207 of file MultivariatePolynomial.h.