fesa-core  4.0.0
fesa::ImmutableFunctionList Class Reference

Represents a FESA function list. Allows conversion from a function list to arrays of points and vice versa. More...

#include <ImmutableFunctionList.h>

Inheritance diagram for fesa::ImmutableFunctionList:
fesa::FunctionList

Public Member Functions

 ImmutableFunctionList (const ImmutableArray< double > &data, bool checkValidity=true)
 Constructor using a function list specified as an ImmutableArray. No copy of the data is performed. More...
 
 ImmutableFunctionList (const double data[], const std::size_t size, bool copyData=false, bool checkValidity=true, bool forceValid=false)
 Constructor using a function list specified as an array. More...
 
 ImmutableFunctionList (const ImmutableArray2D< double > &x, const ImmutableArray2D< double > &y)
 Construct a function list from two 2D arrays of points specified as Array2D. The points are copied. More...
 
 ImmutableFunctionList (const double x[], const double y[], std::size_t nRows, std::size_t nCols)
 Construct a function list from two flat arrays of points. The points are copied. More...
 
 ImmutableFunctionList (const ImmutableFunctionList &other)
 Copy constructor. If 'other' has its own data, the data is copied and this object will work on its own data as well. Otherwise, no copy is performed, and this object will use the same data as 'other'. More...
 
bool isValid () const
 
std::size_t getNFunctions () const
 
std::size_t getTotalNPoints () const
 
std::size_t getNPoints (std::size_t function) const
 
std::size_t getMaxNPoints () const
 
bool hasOwnData () const
 
const double * get (std::size_t &size) const
 
ImmutableArray< double > get () const
 
const double * getX (std::size_t &nRows, std::size_t &nCols) const
 
ImmutableArray2D< double > getX () const
 
const double * getY (std::size_t &nRows, std::size_t &nCols) const
 
ImmutableArray2D< double > getY () const
 
double getXValue (std::size_t function, std::size_t point) const
 
double getYValue (std::size_t function, std::size_t point) const
 
FunctionList getMutable () const
 
ConstFunctionsIterator begin () const
 Get a constant iterator pointing to the first function in the list.
 
ConstFunctionsIterator end () const
 Get a constant iterator pointing to the location of a function that would theoretically follow the last function in the list.
 

Static Public Member Functions

static std::size_t getMaxNElements (std::size_t nFunctions, std::size_t maxNPoints)
 

Protected Member Functions

std::size_t findPoint (std::size_t function, std::size_t point, ImmutableFunctionList::CoordinateOffset coordinateOffset) const
 

Protected Attributes

std::vector< double > ownData_
 
const double * data_
 
const std::size_t size_
 
const std::vector< const double * > functionPtrs_
 
Array x_
 
Array y_
 
boost::tribool valid_
 

Detailed Description

Represents a FESA function list. Allows conversion from a function list to arrays of points and vice versa.

A function list is a compact way to store x-coordinates and y-coordinates of several functions of different sizes Let #f be the number of functions #pi be the number of points in the ith function

The function list is [#f, #p1, (x, y) * #p1, #p2, (x, y) * #p2, ...]

If we represent as 2D arrays of coordinates, we have f1 [ x, x, ... x] [ y, y, ... y] f2 [ x, x, ... nan] [ y, y, ... nan] ... fn [ x, nan, ... nan] [ y, nan, ... nan]

Constructor & Destructor Documentation

fesa::ImmutableFunctionList::ImmutableFunctionList ( const ImmutableArray< double > &  data,
bool  checkValidity = true 
)

Constructor using a function list specified as an ImmutableArray. No copy of the data is performed.

Parameters
dataAn array describing a function list
checkValidityIf true, the data of the function list is checked for validity
Exceptions
FesaExceptionIf checkValidity is true and data is not valid
fesa::ImmutableFunctionList::ImmutableFunctionList ( const double  data[],
const std::size_t  size,
bool  copyData = false,
bool  checkValidity = true,
bool  forceValid = false 
)

Constructor using a function list specified as an array.

Parameters
dataAn array describing a function list
sizeThe size of the data of the function list
copyDataIf true, data is copied; otherwise, data must remain accessible until this object is destroyed
checkValidityIf true, the data of the function list is checked for validity
forceValidIf true, checkValidity is ignored and data is marked as valid without being checked. Use carefully
Exceptions
FesaExceptionIf checkValidity is true, forceValid is false, and data is not valid
fesa::ImmutableFunctionList::ImmutableFunctionList ( const ImmutableArray2D< double > &  x,
const ImmutableArray2D< double > &  y 
)

Construct a function list from two 2D arrays of points specified as Array2D. The points are copied.

Parameters
xAn array of x-coordinates of the functions' points
yAn array of y-coordinates of the functions' points
fesa::ImmutableFunctionList::ImmutableFunctionList ( const double  x[],
const double  y[],
std::size_t  nRows,
std::size_t  nCols 
)

Construct a function list from two flat arrays of points. The points are copied.

Parameters
xAn array of x-coordinates of the functions' points
yAn array of y-coordinates of the functions' points
nRowsThe number of rows of the arrays of points (the number of functions)
nColsThe number of columns of the arrays of points (the number of points)
fesa::ImmutableFunctionList::ImmutableFunctionList ( const ImmutableFunctionList other)

Copy constructor. If 'other' has its own data, the data is copied and this object will work on its own data as well. Otherwise, no copy is performed, and this object will use the same data as 'other'.

Parameters
otherThe other function list

Member Function Documentation

std::size_t fesa::ImmutableFunctionList::findPoint ( std::size_t  function,
std::size_t  point,
ImmutableFunctionList::CoordinateOffset  coordinateOffset 
) const
protected

Find the point index in the FunctionList data

const double * fesa::ImmutableFunctionList::get ( std::size_t &  size) const
Parameters
[out]sizesize of the function list
Returns
the function list
ImmutableArray< double > fesa::ImmutableFunctionList::get ( ) const
Returns
the function list
std::size_t fesa::ImmutableFunctionList::getMaxNElements ( std::size_t  nFunctions,
std::size_t  maxNPoints 
)
static

Returns the maximum number of elements (double) needed to represent the function list, assuming every function has maxNPoints points.

std::size_t fesa::ImmutableFunctionList::getMaxNPoints ( ) const
Returns
the maximum number of points for the functions in the function list
FunctionList fesa::ImmutableFunctionList::getMutable ( ) const

Returns a FunctionList object that contains a copy of the elements of this FunctionList

std::size_t fesa::ImmutableFunctionList::getNFunctions ( ) const
Returns
the number of functions in the function list
std::size_t fesa::ImmutableFunctionList::getNPoints ( std::size_t  function) const
Returns
the number of points in the function
std::size_t fesa::ImmutableFunctionList::getTotalNPoints ( ) const
Returns
the total number of points in the function list
const double * fesa::ImmutableFunctionList::getX ( std::size_t &  nRows,
std::size_t &  nCols 
) const
Parameters
[out]nRowsnumber of rows of the flat 2D array returned
[out]nColsnumber of columns of the flat 2D array returned
Returns
flat 2D array of x-coordinates of the functions' points
ImmutableArray2D< double > fesa::ImmutableFunctionList::getX ( ) const
Returns
Array2D of x-coordinates of the functions' points
double fesa::ImmutableFunctionList::getXValue ( std::size_t  function,
std::size_t  point 
) const
Parameters
function
point
Returns
the value of the x-axis function's point
const double * fesa::ImmutableFunctionList::getY ( std::size_t &  nRows,
std::size_t &  nCols 
) const
Parameters
[out]nRowsnumber of rows of the flat 2D array returned
[out]nColsnumber of columns of the flat 2D array returned
Returns
flat 2D array of y-coordinates of the functions' points
ImmutableArray2D< double > fesa::ImmutableFunctionList::getY ( ) const
Returns
Array2D of y-coordinates of the functions' points
double fesa::ImmutableFunctionList::getYValue ( std::size_t  function,
std::size_t  point 
) const
Parameters
function
point
Returns
the value of the x-axis function's point
bool fesa::ImmutableFunctionList::hasOwnData ( ) const

Indicate whether this object owns its data

bool fesa::ImmutableFunctionList::isValid ( ) const

Checks that raw data of this function list (as an array of doubles) is valid.

Member Data Documentation

const double* fesa::ImmutableFunctionList::data_
protected

Pointer to the elements of this FunctionList.

const std::vector<const double*> fesa::ImmutableFunctionList::functionPtrs_
protected

A vector of pointers to the beginnings of functions in a function list, plus a pointer to the theoretical beginning of a function that would follow the last function. A beginning of a function stores the number of points in the function

std::vector<double> fesa::ImmutableFunctionList::ownData_
protected

Used only when the object contains its own data If used, data_ must point on &ownData_[0].

const std::size_t fesa::ImmutableFunctionList::size_
protected

Size of the function list

boost::tribool fesa::ImmutableFunctionList::valid_
mutableprotected

Tells if the data is valid

Array fesa::ImmutableFunctionList::x_
mutableprotected

Contains flat 2D arrays of x-coordinates of the functions' points This member is lazily initialized

Array fesa::ImmutableFunctionList::y_
mutableprotected

Contains flat 2D arrays of y-coordinates of the functions' points This member is lazily initialized


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