GCGlib  0.04.228
GCG Graphics Engine

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

#include <gcg.h>

Inheritance diagram for gcgLEGENDREBASIS1D< NUMTYPE >:
gcgBASIS1D< NUMTYPE > gcgCLASS

Public Member Functions

bool setBasisDegree (unsigned int degree)
 Sets the maximum degree of the polynomials of the basis. The number of polynomials = maximum degree + 1. More...
 
bool setNumberOfSamples (unsigned int nsamples)
 Sets the number of samples for the discretization of polynomial functions. Call it 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 1D polynomial projection/reconstruction. More...
 
NUMTYPE getPointValue (unsigned int idegree, NUMTYPE x)
 Computes the value of the polynomial of idegree degree at point x in [-1, 1]. More...
 
NUMTYPE getIntegralValue (unsigned int idegree, NUMTYPE a, NUMTYPE b)
 Computes the integral of the polynomial of degree idegree in the interval [a, b]. More...
 
NUMTYPE getDiscreteValue (unsigned int idegree, unsigned int i)
 Compute normalized i-th sample of the polynomial of degree idegree. Parameter i in [0, nsamples-1] is the i-th sample of a uniform discretization of the domain [-1,1] with nsamples samples. Call setNumberOfSamples() to set the number of samples to be used. More...
 
bool projectSignal (int atX, gcgDISCRETE1D< float > *vector, gcgDISCRETE1D< NUMTYPE > *outputcoef)
 Computes the npolynomials coefficients of the projection of the vector (as 1D signal) on the discretized basis of current degree + 1 polynomials = npolynomials. Only nsamples elements starting at atX are used. The coefficients are stored in array outputcoef (as 1D signal) that is adjusted to have current degree + 1 elements. Call setNumberOfSamples() to set the number of samples to be used. More...
 
bool reconstructSignal (int atX, gcgDISCRETE1D< NUMTYPE > *inputcoef, gcgDISCRETE1D< float > *outputvector)
 Computes up to nsamples components of a vector (as 1D signal), using the degree + 1 coefficients given in array inputcoef (as 1D signal). The components are stored in the array outputvector (as 1D signal) starting at position atX. Call setNumberOfSamples() to set the number of samples to be used. More...
 
bool basisInformation (const char *filename)
 Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamples elements. Call setNumberOfSamples() to set the number of samples to be used. 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 = number of polynomials - 1. Read-only. See setBasisDegree().
 
unsigned int nsamples
 Current number of samples of each discretized polynomial. Read-only. See setNumberOfSamples().
 

Detailed Description

template<>
class gcgLEGENDREBASIS1D< NUMTYPE >

Class for Legendre 1D polynomials computation.

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

Use gcgLEGENDREBASIS1D<float> for single precision and gcgLEGENDREBASIS1D<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 gcgLEGENDREBASIS1D< NUMTYPE >::basisInformation ( const char *  filename)

Output basis information with current degree for numerical analysis. Saves information of the orthogonality of the basis with nsamples elements. Call setNumberOfSamples() to set the number of samples to be used.

Parameters
[in]filenamename of output text file.
Returns
true if file creation was successful.
See also
setNumberOfSamples()

◆ getDiscreteValue()

NUMTYPE gcgLEGENDREBASIS1D< NUMTYPE >::getDiscreteValue ( unsigned int  idegree,
unsigned int  i 
)

Compute normalized i-th sample of the polynomial of degree idegree. Parameter i in [0, nsamples-1] is the i-th sample of a uniform discretization of the domain [-1,1] with nsamples samples. Call setNumberOfSamples() to set the number of samples to be used.

Parameters
[in]idegreedegree of the polynomial function.
[in]iindex of the sample. Must be in the interval [0 nsamples - 1].
Returns
the value of the i-th sample.
See also
setBasisDegree()
setNumberOfSamples()

◆ getIntegralValue()

NUMTYPE gcgLEGENDREBASIS1D< NUMTYPE >::getIntegralValue ( unsigned int  idegree,
NUMTYPE  a,
NUMTYPE  b 
)

Computes the integral of the polynomial of degree idegree in the interval [a, b].

Parameters
[in]idegreeof the polynomial function.
[in]ainferior limit of the interval [a, b].
[in]bsuperior limit of the interval [a, b].
Returns
the value of the integral in the interval [a, b].

◆ getNumberOfCoefficients()

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

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

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

Implements gcgBASIS1D< NUMTYPE >.

◆ getPointValue()

NUMTYPE gcgLEGENDREBASIS1D< NUMTYPE >::getPointValue ( unsigned int  idegree,
NUMTYPE  x 
)

Computes the value of the polynomial of idegree degree at point x in [-1, 1].

Parameters
[in]idegreedegree of the polynomial function.
[in]xcoordinate of the point to be evaluated. Must be in the interval [-1, 1]
Returns
the value of the polynomial at point x.
See also
getSampleValue()
getDiscreteValue()

◆ projectSignal()

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

Computes the npolynomials coefficients of the projection of the vector (as 1D signal) on the discretized basis of current degree + 1 polynomials = npolynomials. Only nsamples elements starting at atX are used. The coefficients are stored in array outputcoef (as 1D signal) that is adjusted to have current degree + 1 elements. Call setNumberOfSamples() to set the number of samples to be used.

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

Implements gcgBASIS1D< NUMTYPE >.

◆ reconstructSignal()

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

Computes up to nsamples components of a vector (as 1D signal), using the degree + 1 coefficients given in array inputcoef (as 1D signal). The components are stored in the array outputvector (as 1D signal) starting at position atX. Call setNumberOfSamples() to set the number of samples to be used.

Parameters
[in]atXorigin of the signal for this projection (relative to outputvector).
[in]inputcoefarray (as 1D signal) of coefficients representing the vector to be reconstructed.
[out]outputvectorarray (as 1D signal) that receives the reconstructed vector.
Returns
true if reconstruction is successful.
See also
setBasisDegree()
setNumberOfSamples()
projectSignal()

Implements gcgBASIS1D< NUMTYPE >.

◆ setBasisDegree()

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

Sets the maximum degree of the polynomials of the basis. The number of polynomials = maximum degree + 1.

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

◆ setNumberOfSamples()

bool gcgLEGENDREBASIS1D< NUMTYPE >::setNumberOfSamples ( unsigned int  nsamples)
virtual

Sets the number of samples for the discretization of polynomial functions. Call it 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]nsamplesnumber of samples of a discretization of poynomials domain [-1, 1].
Returns
true if discretized basis creation is successful.
See also
getDiscreteValue()
projectSignal()
reconstructSignal()
basisInformation()

Implements gcgBASIS1D< NUMTYPE >.


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