GCGlib  0.04.228
GCG Graphics Engine

Class for Legendre 2D polynomials computation. More...

#include <gcg.h>

Inheritance diagram for gcgLEGENDREBASIS2D< NUMTYPE >:
gcgBASIS2D< NUMTYPE > gcgCLASS

Public Member Functions

bool setBasisDegree (unsigned int degree)
 Sets the maximum degree of the polynomials of the basis. The number of polynomials = (degree + 1)*(degree+2)/2. More...
 
bool setNumberOfSamples (unsigned int nsamplesX, unsigned int nsamplesY)
 Sets the number of samples in X and Y directions for the discretization of polynomial functions. Call it (or call synchBasisWithFile()) BEFORE using getDiscreteValue(), projectSignal(), reconstructSignal() or basisInformation(). This method computes all polynomial basis vectors which might be slow if current degree is big. More...
 
unsigned int getNumberOfCoefficients ()
 Returns the number of coefficients used in 2D polynomial projection/reconstruction. More...
 
bool synchBasisWithFile (const char *filename, unsigned int nsamplesX, unsigned int nsamplesY)
 Loads the basis functions of current degree, discretized with nsamplesX * nsamplesY elements, stored in the given file. All missing polynomials of the file are discretized and saved for further use. This function sychronizes file and memory polynomial functions and can considerably save time. Use this function instead of setNumberOfSamples() to avoid the computation of all basis functions that might be stored in the file. More...
 
NUMTYPE getPointValue (unsigned int i, unsigned int j, NUMTYPE x, NUMTYPE y)
 Computes the value Pi,j(x,y), where i+j <= degree, are the polynomial degrees in X and Y axe, and x, y in [-1, 1] * [-1, 1] are the coordinates of the point to be evaluated. More...
 
NUMTYPE getIntegralValue (unsigned int i, unsigned int j, NUMTYPE xmin, NUMTYPE xmax, NUMTYPE ymin, NUMTYPE ymax)
 Computes the integral of the polynomial Pi,j in the region [xmin, xmax] * [ymin, ymax]. More...
 
NUMTYPE getDiscreteValue (unsigned int i, unsigned int j, unsigned int ix, unsigned int iy)
 Compute normalized value Pi,j(ix, iy), where i+j <= degree, are the polynomial degrees in x and y, and ix in [0, nsamplesX-1], and iy in [0, nsamplesY-1] are the coordinates of the sample of a uniform discretization of the domain [-1, 1] * [-1, 1] with nsamplesX * nsamplesY samples. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used. More...
 
bool projectSignal (int atX, int atY, gcgDISCRETE2D< float > *vector, gcgDISCRETE1D< NUMTYPE > *outputcoef)
 Computes the ((degree-2) * (degree-1)) / 2) coefficients of the projection of the 2D vector (as 2D signal) on a discretized polynomial basis. Only nsamplesX * nsamplesY elements starting at (atX, atY) are used. The coefficients are stored in the array outputcoef (as 1D signal) that is adjusted to have (degree+2)* (degre+1)/2 elements. Call setNumberOfSamples() to set the number of samples to be used. More...
 
bool reconstructSignal (int atX, int atY, gcgDISCRETE1D< NUMTYPE > *inputcoef, gcgDISCRETE2D< float > *outputvector)
 Computes the nsamplesX * nsamplesY components of a 2D vector, using the (degree+1)*(degree+2)/2 coefficients given in array inputcoef (as 1D signal). The components are stored in the 2D array outputvector (as 2D signal) starting at position (atX, atY). Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used. More...
 
bool basisInformation (const char *filename, bool checkorthogonality, bool savefunctionsasimages)
 Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamplesX * nsamplesY elements. More...
 
- Public Member Functions inherited from gcgCLASS
void * operator new (size_t size)
 Defines a new operator to be used by instatiations of GCGlib classes instead the global one. More...
 
void * operator new (size_t size, const std::nothrow_t &) throw ()
 Defines a new operator to be used by instantiations of GCGlib classes instead the global one. Returns a NULL pointer instead of throwing an exception if an error occurs. More...
 
void * operator new[] (size_t size)
 Defines a new operator to be used by GCGlib array allocations instead the global one. More...
 
void * operator new[] (size_t size, const std::nothrow_t &) throw ()
 Defines a new operator to be used by vector allocations instead the global one. More...
 
void operator delete (void *p)
 Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
 
void operator delete (void *p, const std::nothrow_t &) throw ()
 Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
 
void operator delete[] (void *p)
 Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
 
void operator delete[] (void *p, const std::nothrow_t &) throw ()
 Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
 

Public Attributes

unsigned int degree
 Degree of the polynomials. Read-only. See setBasisDegree().
 
unsigned int nsamplesX
 Current samples in X direction. Read-only. See setNumberOfSamples().
 
unsigned int nsamplesY
 Current samples in Y direction. Read-only. See setNumberOfSamples().
 

Detailed Description

template<>
class gcgLEGENDREBASIS2D< NUMTYPE >

Class for Legendre 2D polynomials computation.

Template Parameters
NUMTYPEType of the samples representing the signal. Supported types: float or double.

Use gcgLEGENDREBASIS2D<float> for single precision and gcgLEGENDREBASIS2D<double> for double precision. Methods for projection and reconstruction are avalaible. The performance of the numeric methods can be verified by using the basisInformation() method.

Since
0.01.6

Member Function Documentation

◆ basisInformation()

bool gcgLEGENDREBASIS2D< NUMTYPE >::basisInformation ( const char *  filename,
bool  checkorthogonality,
bool  savefunctionsasimages 
)

Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamplesX * nsamplesY elements.

Parameters
[in]filenamename of output text file. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used.
[in]checkorthogonalityif true, computes the internal product of all functions of the basis. This can be time consuming.
[in]savefunctionsasimagesif true, saves the function basis as gray scale images to be visually checked.
Returns
true if file creation was successful.

◆ getDiscreteValue()

NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getDiscreteValue ( unsigned int  i,
unsigned int  j,
unsigned int  ix,
unsigned int  iy 
)

Compute normalized value Pi,j(ix, iy), where i+j <= degree, are the polynomial degrees in x and y, and ix in [0, nsamplesX-1], and iy in [0, nsamplesY-1] are the coordinates of the sample of a uniform discretization of the domain [-1, 1] * [-1, 1] with nsamplesX * nsamplesY samples. Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used.

Parameters
[in]idegree of the polynomial function in X direction.
[in]jdegree of the polynomial function in Y direction.
[in]ixindex of the sample in X. Must be in the interval [0 nsamplesX - 1].
[in]iyindex of the sample in Y. Must be in the interval [0 nsamplesY - 1].
Returns
the normalized value of the sample of function Pi,j at position (ix,iy).
See also
setNumberOfSamples()
synchBasisWithFile()
setBasisDegree()
getSampleValue()
getPointValue()

◆ getIntegralValue()

NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getIntegralValue ( unsigned int  i,
unsigned int  j,
NUMTYPE  xmin,
NUMTYPE  xmax,
NUMTYPE  ymin,
NUMTYPE  ymax 
)

Computes the integral of the polynomial Pi,j in the region [xmin, xmax] * [ymin, ymax].

Parameters
[in]idegree of the polynomial function in X direction.
[in]jdegree of the polynomial function in Y direction.
[in]xmininferior limit of the interval in X.
[in]xmaxsuperior limit of the interval in X.
[in]ymininferior limit of the interval in Y.
[in]ymaxsuperior limit of the interval in Y.
Returns
the value of the integral of polynomial Pi,j in the interval [xmin, xmax] * [ymin, ymax].

◆ getNumberOfCoefficients()

unsigned int gcgLEGENDREBASIS2D< NUMTYPE >::getNumberOfCoefficients ( )
virtual

Returns the number of coefficients used in 2D polynomial projection/reconstruction.

Returns
the number of polynomials of the basis = degree + 1.

Implements gcgBASIS2D< NUMTYPE >.

◆ getPointValue()

NUMTYPE gcgLEGENDREBASIS2D< NUMTYPE >::getPointValue ( unsigned int  i,
unsigned int  j,
NUMTYPE  x,
NUMTYPE  y 
)

Computes the value Pi,j(x,y), where i+j <= degree, are the polynomial degrees in X and Y axe, and x, y in [-1, 1] * [-1, 1] are the coordinates of the point to be evaluated.

Parameters
[in]idegree of the polynomial function in X direction.
[in]jdegree of the polynomial function in Y direction.
[in]xabcissa coordinate of the point to be evaluated. Must be in the interval [-1, 1]
[in]ycoordinate of the point to be evaluated. Must be in the interval [-1, 1]
Returns
the value of the polynomial Pi,j at point (x, y).
See also
getSampleValue()
getDiscreteValue()

◆ projectSignal()

bool gcgLEGENDREBASIS2D< NUMTYPE >::projectSignal ( int  atX,
int  atY,
gcgDISCRETE2D< float > *  vector,
gcgDISCRETE1D< NUMTYPE > *  outputcoef 
)
virtual

Computes the ((degree-2) * (degree-1)) / 2) coefficients of the projection of the 2D vector (as 2D signal) on a discretized polynomial basis. Only nsamplesX * nsamplesY elements starting at (atX, atY) are used. The coefficients are stored in the array outputcoef (as 1D signal) that is adjusted to have (degree+2)* (degre+1)/2 elements. Call setNumberOfSamples() to set the number of samples to be used.

Parameters
[in]atXorigin X coordinate of the signal for this projection (relative to vector).
[in]atYorigin Y coordinate of the signal for this projection (relative to vector).
[in]vectorarray (as 2D signal) containing components of the 2D vector to be projected onto the basis.
[out]outputcoefarray (as 1D signal) that receives the computed coefficients. It is adjusted to have (degree+2)*(degre+1)/2 elements.
Returns
true if projection is successful.
See also
setBasisDegree()
setNumberOfSamples()
synchBasisWithFile()
reconstructSignal()

Implements gcgBASIS2D< NUMTYPE >.

◆ reconstructSignal()

bool gcgLEGENDREBASIS2D< NUMTYPE >::reconstructSignal ( int  atX,
int  atY,
gcgDISCRETE1D< NUMTYPE > *  inputcoef,
gcgDISCRETE2D< float > *  outputvector 
)
virtual

Computes the nsamplesX * nsamplesY components of a 2D vector, using the (degree+1)*(degree+2)/2 coefficients given in array inputcoef (as 1D signal). The components are stored in the 2D array outputvector (as 2D signal) starting at position (atX, atY). Call setNumberOfSamples() or synchBasisWithFile() to set the number of samples to be used.

Parameters
[in]atXorigin X coordinate of the signal for this projection (relative to outputvector).
[in]atYorigin Y coordinate of the signal for this projection (relative to outputvector).
[in]inputcoefarray (as 1D signal) of (degree+1)*(degree+2)/2 coefficients representing the vector to be reconstructed.
[out]outputvector2D array (as 2D signal) that receives the reconstructed vector. Must have room for nsamplesX * nsamplesY elements.
Returns
true if reconstruction is successful.
See also
setBasisDegree()
setNumberOfSamples()
synchBasisWithFile()
projectSignal()

Implements gcgBASIS2D< NUMTYPE >.

◆ setBasisDegree()

bool gcgLEGENDREBASIS2D< NUMTYPE >::setBasisDegree ( unsigned int  degree)

Sets the maximum degree of the polynomials of the basis. The number of polynomials = (degree + 1)*(degree+2)/2.

Parameters
[in]degreemaximum degree of the polynomial basis.
Returns
true if setup succeded

◆ setNumberOfSamples()

bool gcgLEGENDREBASIS2D< NUMTYPE >::setNumberOfSamples ( unsigned int  nsamplesX,
unsigned int  nsamplesY 
)

Sets the number of samples in X and Y directions for the discretization of polynomial functions. Call it (or call synchBasisWithFile()) BEFORE using getDiscreteValue(), projectSignal(), reconstructSignal() or basisInformation(). This method computes all polynomial basis vectors which might be slow if current degree is big.

Parameters
[in]nsamplesXnumber of points in X.
[in]nsamplesYnumber of points in Y.
Returns
true if discretized basis creation is successful.
See also
synchBasisWithFile()
getDiscreteValue()
projectSignal()
reconstructSignal()
basisInformation()

◆ synchBasisWithFile()

bool gcgLEGENDREBASIS2D< NUMTYPE >::synchBasisWithFile ( const char *  filename,
unsigned int  nsamplesX,
unsigned int  nsamplesY 
)

Loads the basis functions of current degree, discretized with nsamplesX * nsamplesY elements, stored in the given file. All missing polynomials of the file are discretized and saved for further use. This function sychronizes file and memory polynomial functions and can considerably save time. Use this function instead of setNumberOfSamples() to avoid the computation of all basis functions that might be stored in the file.

Parameters
[in]filenamename of the file containing discretized polynomial basis.
[in]nsamplesXnumber of points in X.
[in]nsamplesYnumber of points in Y.
Returns
true if synchronization succeded.
See also
setNumberOfSamples()

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