Project
Loading...
Searching...
No Matches
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly > Class Template Reference

#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)
 
- Public Member Functions inherited from o2::gpu::FlatObject
 FlatObject ()=default
 _____________ Constructors / destructors __________________________
 
 ~FlatObject ()
 
 FlatObject (const FlatObject &)=delete
 
FlatObjectoperator= (const FlatObject &)=delete
 
void destroy ()
 _______________ Utilities _______________________________________________
 
size_t getFlatBufferSize () const
 Gives size of the flat buffer.
 
const chargetFlatBufferPtr () 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.
 
- Public Member Functions inherited from o2::gpu::MultivariatePolynomialHelper< Dim, Degree, InteractionOnly >
 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()
 
- Public Member Functions inherited from o2::gpu::MultivariatePolynomialParametersHelper
 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 Public Member Functions inherited from o2::gpu::FlatObject
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.
 
- Public Attributes inherited from o2::gpu::MultivariatePolynomialHelper< Dim, Degree, InteractionOnly >
const float x [] { return par[0] + loopDegrees<1>(par, x)
 
- Public Attributes inherited from o2::gpu::MultivariatePolynomialParametersHelper
const uint32_t dim { return (degree == 0) ? binomialCoeff(dim - 1, 0) : binomialCoeff(dim - 1 + degree, degree) + getNParametersAllTerms(degree - 1, dim)
 
- Protected Types inherited from o2::gpu::FlatObject
enum  ConstructionState : uint32_t { NotConstructed = 0x0 , Constructed = 0x1 , InProgress = 0x2 }
 GPUCA_GPUCODE. More...
 
- Protected Member Functions inherited from o2::gpu::FlatObject
void startConstruction ()
 _____________ Construction _________
 
void finishConstruction (int32_t flatBufferSize)
 
void cloneFromObject (const FlatObject &obj, char *newFlatBufferPtr)
 
charreleaseInternalBuffer ()
 _____________ 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 Protected Member Functions inherited from o2::gpu::FlatObject
static constexpr size_t getClassAlignmentBytes ()
 _____________ Memory alignment __________________________
 
static constexpr size_t getBufferAlignmentBytes ()
 Gives minimal alignment in bytes required for the flat buffer.
 
- Protected Attributes inherited from o2::gpu::FlatObject
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
 
charmFlatBufferContainer = nullptr
 
charmFlatBufferPtr = nullptr
 

Detailed Description

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
class o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >

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.

Constructor & Destructor Documentation

◆ MultivariatePolynomial() [1/3]

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim==0 &&Degree==0)), int32_t >::type = 0>
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::MultivariatePolynomial ( const uint32_t  nDim,
const uint32_t  degree,
const bool  interactionOnly = false 
)
inline

constructor for runtime evaluation of polynomial formula

Parameters
nDimnumber of dimensions
degreedegree of the polynomial

Definition at line 52 of file MultivariatePolynomial.h.

◆ MultivariatePolynomial() [2/3]

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim !=0 &&Degree !=0)), int32_t >::type = 0>
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::MultivariatePolynomial ( )
inline

constructor for compile time evaluation of polynomial formula

Definition at line 59 of file MultivariatePolynomial.h.

◆ ~MultivariatePolynomial()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::~MultivariatePolynomial ( )
default

default destructor

◆ MultivariatePolynomial() [3/3]

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::MultivariatePolynomial ( const MultivariatePolynomial< Dim, Degree, InteractionOnly > &  obj)
inline

Copy constructor.

Definition at line 72 of file MultivariatePolynomial.h.

Member Function Documentation

◆ cloneFromObject()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
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.

◆ destroy()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::destroy ( )

destroy the object (release internal flat buffer)

Definition at line 252 of file MultivariatePolynomial.h.

◆ fit()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
template<bool IsEnabled = true, typename std::enable_if<(IsEnabled &&(Dim==0 &&Degree==0)), int32_t >::type = 0>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::fit ( std::vector< double > &  x,
std::vector< double > &  y,
std::vector< double > &  error,
const bool  clearPoints 
)
inline

performs fit of input point

Parameters
xposition of the points of length 'Dim * nPoints' (structured as in https://root.cern.ch/doc/master/classTLinearFitter.html)
yvalues which will be fitted of length 'nPoints'
errorerror of weigths of the points (if empty no weights are applied)
clearPointsperform the fit on new data points

Definition at line 130 of file MultivariatePolynomial.h.

◆ getContainer()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
MultivariatePolynomialContainer o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::getContainer ( ) const
inline

converts the parameters to a container which can be written to a root file

Definition at line 141 of file MultivariatePolynomial.h.

◆ getNParams()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
uint32_t o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::getNParams ( ) const
inline
Returns
returns number of parameters of the polynomials

Definition at line 100 of file MultivariatePolynomial.h.

◆ getParams()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
const float * o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::getParams ( ) const
inline
Returns
returns the paramaters of the coefficients

Definition at line 111 of file MultivariatePolynomial.h.

◆ GPUd()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::GPUd ( ) const
inline

================================================================================================

evaluates the polynomial for given coordinates

Parameters
xquery coordinates

Definition at line 96 of file MultivariatePolynomial.h.

◆ loadFromFile()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
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)

Parameters
inpfinput file \parma name name of the object in the file

Definition at line 170 of file MultivariatePolynomial.h.

◆ moveBufferTo()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::moveBufferTo ( char newBufferPtr)

move flat buffer to new location

Parameters
newBufferPtrnew buffer location

Definition at line 232 of file MultivariatePolynomial.h.

◆ setActualBufferAddress()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setActualBufferAddress ( char actualFlatBufferPtr)

set location of external flat buffer

Definition at line 259 of file MultivariatePolynomial.h.

◆ setFromContainer()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setFromContainer ( const MultivariatePolynomialContainer container)

set the parameters from MultivariatePolynomialContainer

Parameters
containercontainer for the parameters

Definition at line 183 of file MultivariatePolynomial.h.

◆ setFutureBufferAddress()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
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.

◆ setParam()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setParam ( const uint32_t  param,
const float  val 
)
inline
Parameters
parameterwhich will be set \val value of the parameter

Definition at line 108 of file MultivariatePolynomial.h.

◆ setParams()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly = false>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::setParams ( const float  params[])
inline

set the parameters for the coefficients of the polynomial

Parameters
paramsparameter for the coefficients

Definition at line 104 of file MultivariatePolynomial.h.

◆ writeToFile()

template<uint32_t Dim, uint32_t Degree, bool InteractionOnly>
void o2::gpu::MultivariatePolynomial< Dim, Degree, InteractionOnly >::writeToFile ( TFile &  outf,
const char name 
) const

write parameters to file

Parameters
outfoutput file
namename of the output object

Definition at line 207 of file MultivariatePolynomial.h.


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