#include <BALL/DATATYPE/regularData1D.h>
Classes | |
struct | BlockValueType |
The block data type for reading and writing binary data. More... | |
Public Types | |
typedef ValueType | value_type |
typedef std::vector< ValueType > ::iterator | iterator |
typedef std::vector< ValueType > ::const_iterator | const_iterator |
typedef std::vector< ValueType > ::reference | reference |
typedef std::vector< ValueType > ::const_reference | const_reference |
typedef std::vector< ValueType > ::pointer | pointer |
typedef std::vector< ValueType > ::difference_type | difference_type |
typedef std::vector< ValueType > ::size_type | size_type |
Type definitions | |
typedef Position | IndexType |
The IndexType. | |
typedef std::vector< ValueType > | VectorType |
The type containing an STL vector of the corresponding ValueType. | |
typedef double | CoordinateType |
The coordinate type. | |
typedef std::vector< ValueType > ::iterator | Iterator |
A mutable iterator. | |
typedef std::vector< ValueType > ::const_iterator | ConstIterator |
A constant iterator. | |
Public Member Functions | |
Constructors and Destructors. | |
TRegularData1D () | |
Default constructor. | |
TRegularData1D (const TRegularData1D &data) throw (Exception::OutOfMemory) | |
Copy constructor. | |
TRegularData1D (const CoordinateType &origin, const CoordinateType &dimension, const CoordinateType &spacing) throw (Exception::OutOfMemory) | |
TRegularData1D (const IndexType &size) throw (Exception::OutOfMemory) | |
This constructor sets origin to 0.0 and dimension to 1.0. | |
TRegularData1D (const VectorType &data, const CoordinateType &origin=0.0, const CoordinateType &dimension=1.0) throw (Exception::OutOfMemory) | |
virtual | ~TRegularData1D () |
Destructor. | |
virtual void | clear () |
Clear the contents. | |
Assignment | |
TRegularData1D & | operator= (const TRegularData1D< ValueType > &data) throw (Exception::OutOfMemory) |
TRegularData1D & | operator= (const VectorType &data) throw (Exception::OutOfMemory) |
Predicates | |
bool | operator== (const TRegularData1D &data) const |
Equality operator. | |
BALL_INLINE bool | operator!= (const TRegularData1D &data) const |
Inequality operator. | |
BALL_INLINE bool | empty () const |
Empty predicate. | |
bool | isInside (const CoordinateType &x) const |
Test whether a point is inside the grid. | |
Iterators | |
BALL_INLINE ConstIterator | begin () const |
BALL_INLINE ConstIterator | end () const |
BALL_INLINE Iterator | begin () |
BALL_INLINE Iterator | end () |
Accessors | |
BALL_INLINE size_type | size () const |
BALL_INLINE size_type | max_size () const |
BALL_INLINE void | swap (TRegularData1D< ValueType > &data) |
const ValueType & | getData (const IndexType &index) const throw (Exception::OutOfGrid) |
ValueType & | getData (const IndexType &index) throw (Exception::OutOfGrid) |
const ValueType & | operator[] (const IndexType &index) const |
ValueType & | operator[] (const IndexType &index) |
ValueType | operator() (const CoordinateType &x) const |
ValueType | getInterpolatedValue (const CoordinateType &x) const throw (Exception::OutOfGrid) |
void | getEnclosingIndices (const CoordinateType &x, Position &lower, Position &upper) const throw (Exception::OutOfGrid) |
void | getEnclosingValues (const CoordinateType &x, ValueType &lower, ValueType &upper) const throw (Exception::OutOfGrid) |
CoordinateType | getCoordinates (const IndexType &index) const throw (Exception::OutOfGrid) |
IndexType | getClosestIndex (const CoordinateType &x) const throw (Exception::OutOfGrid) |
IndexType | getLowerIndex (const CoordinateType &x) const throw (Exception::OutOfGrid) |
const ValueType & | getClosestValue (const CoordinateType &x) const throw (Exception::OutOfGrid) |
ValueType & | getClosestValue (const CoordinateType &x) throw (Exception::OutOfGrid) |
BALL_INLINE IndexType | getSize () const |
Return the number of points in the data set. | |
BALL_INLINE const CoordinateType & | getOrigin () const |
BALL_INLINE const CoordinateType & | getSpacing () const |
BALL_INLINE void | setOrigin (const CoordinateType &origin) |
BALL_INLINE const CoordinateType & | getDimension () const |
BALL_INLINE void | setDimension (const CoordinateType &dimension) |
void | resize (const IndexType &size) throw (Exception::OutOfMemory) |
void | rescale (const IndexType &new_size) throw (Exception::OutOfMemory) |
void | binaryWrite (const String &filename) const throw (Exception::FileNotFound) |
void | binaryRead (const String &filename) throw (Exception::FileNotFound) |
Protected Attributes | |
CoordinateType | origin_ |
The origin of the data set. | |
CoordinateType | dimension_ |
The dimension (length). | |
CoordinateType | spacing_ |
The spacing. | |
VectorType | data_ |
The data. |
A class to store regularaly spaced data. This class can is intended to hold regularly spaced, one-dimensional data sets. It might be useful to hold data sets like spectra, or precomputed function values.
Container
and Unary Function
requirements. typedef std::vector<ValueType>::const_iterator BALL::TRegularData1D< ValueType >::const_iterator |
typedef std::vector<ValueType>::const_reference BALL::TRegularData1D< ValueType >::const_reference |
typedef std::vector<ValueType>::const_iterator BALL::TRegularData1D< ValueType >::ConstIterator |
A constant iterator.
typedef double BALL::TRegularData1D< ValueType >::CoordinateType |
The coordinate type.
typedef std::vector<ValueType>::difference_type BALL::TRegularData1D< ValueType >::difference_type |
typedef Position BALL::TRegularData1D< ValueType >::IndexType |
The IndexType.
typedef std::vector<ValueType>::iterator BALL::TRegularData1D< ValueType >::iterator |
typedef std::vector<ValueType>::iterator BALL::TRegularData1D< ValueType >::Iterator |
A mutable iterator.
typedef std::vector<ValueType>::pointer BALL::TRegularData1D< ValueType >::pointer |
typedef std::vector<ValueType>::reference BALL::TRegularData1D< ValueType >::reference |
typedef std::vector<ValueType>::size_type BALL::TRegularData1D< ValueType >::size_type |
typedef ValueType BALL::TRegularData1D< ValueType >::value_type |
typedef std::vector<ValueType> BALL::TRegularData1D< ValueType >::VectorType |
The type containing an STL vector of the corresponding ValueType.
BALL::TRegularData1D< ValueType >::TRegularData1D | ( | ) | [inline] |
Default constructor.
BALL::TRegularData1D< ValueType >::TRegularData1D | ( | const TRegularData1D< ValueType > & | data | ) | throw (Exception::OutOfMemory) [inline] |
Copy constructor.
BALL::TRegularData1D< ValueType >::TRegularData1D | ( | const CoordinateType & | origin, | |
const CoordinateType & | dimension, | |||
const CoordinateType & | spacing | |||
) | throw (Exception::OutOfMemory) |
BALL::TRegularData1D< ValueType >::TRegularData1D | ( | const IndexType & | size | ) | throw (Exception::OutOfMemory) |
This constructor sets origin to 0.0 and dimension to 1.0.
BALL::TRegularData1D< ValueType >::TRegularData1D | ( | const VectorType & | data, | |
const CoordinateType & | origin = 0.0 , |
|||
const CoordinateType & | dimension = 1.0 | |||
) | throw (Exception::OutOfMemory) |
BALL::TRegularData1D< ValueType >::~TRegularData1D | ( | ) | [inline, virtual] |
Destructor.
BALL_INLINE Iterator BALL::TRegularData1D< ValueType >::begin | ( | ) | [inline] |
BALL_INLINE ConstIterator BALL::TRegularData1D< ValueType >::begin | ( | ) | const [inline] |
Referenced by BALL::operator>>().
void BALL::TRegularData1D< ValueType >::binaryRead | ( | const String & | filename | ) | throw (Exception::FileNotFound) [inline] |
Read the grid contents from a file written with binaryWrite
FileNotFound | thrown if file doesnt exists or could not be read |
References BALL::File::close(), BALL::BinaryFileAdaptor< T >::getData(), and BALL::File::isValid().
void BALL::TRegularData1D< ValueType >::binaryWrite | ( | const String & | filename | ) | const throw (Exception::FileNotFound) [inline] |
Write the grid contents in a (non-portable) binary format.
FileNotFound | thrown if file could not be written |
References BALL::File::close(), BALL::File::isValid(), and BALL::BinaryFileAdaptor< T >::setData().
void BALL::TRegularData1D< ValueType >::clear | ( | ) | [inline, virtual] |
Clear the contents.
Reimplemented in BALL::TFFT1D< ComplexTraits >.
References BALL::TRegularData1D< ValueType >::data_.
BALL_INLINE bool BALL::TRegularData1D< ValueType >::empty | ( | ) | const [inline] |
Empty predicate.
BALL_INLINE Iterator BALL::TRegularData1D< ValueType >::end | ( | ) | [inline] |
BALL_INLINE ConstIterator BALL::TRegularData1D< ValueType >::end | ( | ) | const [inline] |
BALL_INLINE TRegularData1D< ValueType >::IndexType BALL::TRegularData1D< ValueType >::getClosestIndex | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) [inline] |
Return the index of the closest grid point. This method first performs a range check for the argument x
and then returns the index of the closest grid point to the left or right of x
.
References BALL::Maths::floor().
BALL_INLINE ValueType & BALL::TRegularData1D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) | throw (Exception::OutOfGrid) [inline] |
Return a mutable reference to the closest non-interpolated value. This method first performs a range check for the argument x
and then returns the value of the closest data point to the left or right of x
.
References BALL::Maths::floor().
BALL_INLINE const ValueType & BALL::TRegularData1D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) [inline] |
Return a nonmutable reference to the closest non-interpolated value. This method first performs a range check for the argument x
and then returns the value of the closest data point to the left or right of x
.
References BALL::Maths::floor().
CoordinateType BALL::TRegularData1D< ValueType >::getCoordinates | ( | const IndexType & | index | ) | const throw (Exception::OutOfGrid) |
Return the exact coordinates of a grid point.
OutOfGrid | if the point is outside the grid |
BALL_INLINE ValueType & BALL::TRegularData1D< ValueType >::getData | ( | const IndexType & | index | ) | throw (Exception::OutOfGrid) [inline] |
Return a mutable reference to a specific data element. This is the range chacking version of operator []
.
BALL_INLINE const ValueType & BALL::TRegularData1D< ValueType >::getData | ( | const IndexType & | index | ) | const throw (Exception::OutOfGrid) [inline] |
Return a nonmutable reference to a specific data element. This is the range chacking version of operator []
.
BALL_INLINE const CoordinateType& BALL::TRegularData1D< ValueType >::getDimension | ( | ) | const [inline] |
Return the dimension of the data. The dimension represents the length of the data vector. Hence, the coordinate of the rightmost element, data_[getSize() - 1]
is the origin plus the dimension (getOrigin() + getDimension()
).
void BALL::TRegularData1D< ValueType >::getEnclosingIndices | ( | const CoordinateType & | x, | |
Position & | lower, | |||
Position & | upper | |||
) | const throw (Exception::OutOfGrid) |
Return the indices of the grid points to the left and to the right of a point.
OutOfGrid | if the point is outside the grid |
x | a point inside the grid | |
lower | index of the grid point to the left | |
upper | index of the grid point to the right |
void BALL::TRegularData1D< ValueType >::getEnclosingValues | ( | const CoordinateType & | x, | |
ValueType & | lower, | |||
ValueType & | upper | |||
) | const throw (Exception::OutOfGrid) |
Return the data at the grid points to the left and to the right of a point. getEnclosingIndices
BALL_INLINE ValueType BALL::TRegularData1D< ValueType >::getInterpolatedValue | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) [inline] |
Return the linearly interpolated value of the surrounding two grid points. This method first performs a range check for the argument x
and then calls operator () (x)
to determine an interpolated value at that position.
BALL_INLINE TRegularData1D< ValueType >::IndexType BALL::TRegularData1D< ValueType >::getLowerIndex | ( | const CoordinateType & | x | ) | const throw (Exception::OutOfGrid) [inline] |
Return the index of the grid point with the next lowest coordinate. This method first performs a range check for the argument x
and then returns the index of the closest grid point to the left (i.e. with a lesser coordinate) of x
.
References BALL::Maths::floor().
BALL_INLINE const CoordinateType& BALL::TRegularData1D< ValueType >::getOrigin | ( | ) | const [inline] |
Return the origin of the data. The origin represents the coordinate of the very first (leftmost) element, i.e. data_[0]
.
BALL_INLINE IndexType BALL::TRegularData1D< ValueType >::getSize | ( | ) | const [inline] |
Return the number of points in the data set.
BALL_INLINE const CoordinateType& BALL::TRegularData1D< ValueType >::getSpacing | ( | ) | const [inline] |
Return the spacing of the data. The spacing corresponds to the distance between two adjacent data elements.
bool BALL::TRegularData1D< ValueType >::isInside | ( | const CoordinateType & | x | ) | const |
Test whether a point is inside the grid.
BALL_INLINE size_type BALL::TRegularData1D< ValueType >::max_size | ( | ) | const [inline] |
BALL_INLINE bool BALL::TRegularData1D< ValueType >::operator!= | ( | const TRegularData1D< ValueType > & | data | ) | const [inline] |
Inequality operator.
BALL_INLINE ValueType BALL::TRegularData1D< ValueType >::operator() | ( | const CoordinateType & | x | ) | const [inline] |
Function operator. This operator allows the use of a TRegularData1D instance as a unary function. As required by the STL Unary Function
concept, the argument x
is required to be within the correct range. A more robust (range-checking) version of this operator is implemented as getInterpolatedValue .
References BALL::TRegularData1D< ValueType >::data_, BALL::Maths::floor(), BALL::TRegularData1D< ValueType >::origin_, and BALL::TRegularData1D< ValueType >::spacing_.
TRegularData1D< ValueType > & BALL::TRegularData1D< ValueType >::operator= | ( | const VectorType & | data | ) | throw (Exception::OutOfMemory) [inline] |
Assignment from a vector
of ValueType
. Copy the contents of the data without changing the boundaries.
References BALL::TRegularData1D< ValueType >::resize().
TRegularData1D< ValueType > & BALL::TRegularData1D< ValueType >::operator= | ( | const TRegularData1D< ValueType > & | data | ) | throw (Exception::OutOfMemory) [inline] |
Assignment operator. Copy the data and the boundaries.
References BALL::TRegularData1D< ValueType >::origin_.
bool BALL::TRegularData1D< ValueType >::operator== | ( | const TRegularData1D< ValueType > & | data | ) | const [inline] |
Equality operator.
References BALL::TRegularData1D< ValueType >::data_, BALL::TRegularData1D< ValueType >::dimension_, and BALL::TRegularData1D< ValueType >::origin_.
Referenced by BALL::TRegularData1D< float >::operator!=().
ValueType& BALL::TRegularData1D< ValueType >::operator[] | ( | const IndexType & | index | ) | [inline] |
Mutable random access operator.
const ValueType& BALL::TRegularData1D< ValueType >::operator[] | ( | const IndexType & | index | ) | const [inline] |
Constant random access operator.
void BALL::TRegularData1D< ValueType >::rescale | ( | const IndexType & | new_size | ) | throw (Exception::OutOfMemory) |
Rescale the data. Keep the current boundaries of the data and reinterpolate the data to reflect the new size. To create a data set of new_size
data points, the data is interpolated linearly at the new data points from the closest points in the old data set.
new_size | the new data set size |
void BALL::TRegularData1D< ValueType >::resize | ( | const IndexType & | size | ) | throw (Exception::OutOfMemory) |
Resize the data. If new_size
is larger than the current size, the data vector
is extended to the new size and filled with default constructed items of type ValueType
. Resizing to a value lesser than the current size truncates the vector.
new_size | the new size |
Referenced by BALL::TRegularData1D< ValueType >::operator=(), and BALL::operator>>().
BALL_INLINE void BALL::TRegularData1D< ValueType >::setDimension | ( | const CoordinateType & | dimension | ) | [inline] |
Set the dimension of the data. This will affect neither the origin of the data, nor the number of elements stored (in contrast to resize() ). It will just store the appropriate scaling factor and affect the spacing.
Referenced by BALL::operator<<(), and BALL::operator>>().
BALL_INLINE void BALL::TRegularData1D< ValueType >::setOrigin | ( | const CoordinateType & | origin | ) | [inline] |
Set the origin of the data.
Referenced by BALL::operator<<(), and BALL::operator>>().
BALL_INLINE size_type BALL::TRegularData1D< ValueType >::size | ( | ) | const [inline] |
BALL_INLINE void BALL::TRegularData1D< ValueType >::swap | ( | TRegularData1D< ValueType > & | data | ) | [inline] |
Referenced by BALL::TRegularData1D< float >::swap().
VectorType BALL::TRegularData1D< ValueType >::data_ [protected] |
The data.
Referenced by BALL::TRegularData1D< float >::begin(), BALL::TRegularData1D< ValueType >::clear(), BALL::TRegularData1D< float >::empty(), BALL::TRegularData1D< float >::end(), BALL::TRegularData1D< float >::getSize(), BALL::TRegularData1D< float >::max_size(), BALL::TRegularData1D< ValueType >::operator()(), BALL::TRegularData1D< ValueType >::operator==(), BALL::TRegularData1D< float >::operator[](), and BALL::TRegularData1D< float >::size().
CoordinateType BALL::TRegularData1D< ValueType >::dimension_ [protected] |
The dimension (length).
Referenced by BALL::TRegularData1D< float >::getDimension(), BALL::TRegularData1D< ValueType >::operator==(), and BALL::TRegularData1D< float >::setDimension().
CoordinateType BALL::TRegularData1D< ValueType >::origin_ [protected] |
The origin of the data set.
Reimplemented in BALL::TFFT1D< ComplexTraits >.
Referenced by BALL::TRegularData1D< float >::getOrigin(), BALL::TRegularData1D< ValueType >::operator()(), BALL::TRegularData1D< ValueType >::operator=(), BALL::TRegularData1D< ValueType >::operator==(), and BALL::TRegularData1D< float >::setOrigin().
CoordinateType BALL::TRegularData1D< ValueType >::spacing_ [protected] |
The spacing.
Referenced by BALL::TRegularData1D< float >::getSpacing(), and BALL::TRegularData1D< ValueType >::operator()().