Loading...
Searching...
No Matches
BALL::TRegularData2D< ValueType > Class Template Reference
Foundation Classes » General datastructures » Generic Datastructures for Regularly Spaced Data

`#include <BALL/DATATYPE/regularData2D.h>`

Inheritance diagram for BALL::TRegularData2D< ValueType >:

## Classes

class | IndexType
| The index type used to refer to a specific element in the grid (x-, and y-index). More...
struct | BlockValueType
| The block data type for reading and writing binary data. More...

## Public Types

Type Definitions
typedef std::vector< ValueType > | VectorType
| The type containing an STL vector of the appropriate type.
typedef TVector2< float > | CoordinateType
| The coordinate type.
typedef std::vector< ValueType >::iterator | Iterator
| A mutable iterator.
typedef std::vector< ValueType >::const_iterator | ConstIterator
| A nonmutable iterator.
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

## Public Member Functions

Constructors and Destructors
| TRegularData2D ()
| TRegularData2D (const TRegularData2D< ValueType > &data)
| TRegularData2D (const CoordinateType &origin, const CoordinateType &dimension, const CoordinateType &spacing)
| TRegularData2D (const IndexType &size, const CoordinateType &origin=CoordinateType(0.0), const CoordinateType &dimension=CoordinateType(1.0))
virtual | ~TRegularData2D ()
virtual void | clear ()
Assignment
TRegularData2D & | operator= (const TRegularData2D< ValueType > &data)
Predicates
bool | operator== (const TRegularData2D< ValueType > &data) const
BALL_INLINE bool | operator!= (const TRegularData2D< ValueType > &data) const
| Inequality operator.
BALL_INLINE bool | empty () const
| Empty predicate.
bool | isInside (const CoordinateType &x) const
| Test if a given 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

VectorType | data_
| The grid data.
CoordinateType | origin_
| Origin of the grid (offset).
CoordinateType | dimension_
| Dimension of the grid.
CoordinateType | spacing_
| Grid spacing.
IndexType | size_
| The dimensions in grid points.
BALL_INLINE size_type | size () const
BALL_INLINE size_type | max_size () const
BALL_INLINE void | swap (TRegularData2D< ValueType > &data)
const ValueType & | getData (const IndexType &index) const
ValueType & | getData (const IndexType &index)
const ValueType & | getData (Position index) const
ValueType & | getData (Position index)
const ValueType & | operator[] (const IndexType &index) const
ValueType & | operator[] (const IndexType &index)
const ValueType & | operator[] (Position index) const
ValueType & | operator[] (Position index)
ValueType | operator() (const CoordinateType &x) const
ValueType | getInterpolatedValue (const CoordinateType &x) const
const ValueType & | getClosestValue (const CoordinateType &x) const
ValueType & | getClosestValue (const CoordinateType &x)
IndexType | getLowerIndex (const CoordinateType &v) const
IndexType | getClosestIndex (const CoordinateType &v) const
const IndexType & | getSize () const
const CoordinateType & | getOrigin () const
const CoordinateType & | getSpacing () const
void | setOrigin (const CoordinateType &origin)
const CoordinateType & | getDimension () const
void | setDimension (const CoordinateType &dimension)
void | resize (const IndexType &new_size)
void | rescale (const IndexType &new_size)
CoordinateType | getCoordinates (const IndexType &index) const
CoordinateType | getCoordinates (Position index) const
void | getEnclosingIndices (const CoordinateType &r, Position &ll, Position &lr, Position &ul, Position &ur) const
void | getEnclosingValues (const CoordinateType &r, ValueType &ll, ValueType &lr, ValueType &ul, ValueType &ur) const
ValueType | calculateMean () const
ValueType | calculateSD () const
void | binaryWrite (const String &filename) const
void | binaryRead (const String &filename)

## Detailed Description

template<typename ValueType>
class BALL::TRegularData2D< ValueType >

Two-dimensional grid class. This class represents a two-dimensional array. An instance of ValueType will be created for each point of the grid upon instantiation of TRegularData2D.

  This class fulfills the STL Container and Unary Function requirements. Iteration is along the x-axis first, then along the y-axis.

Definition at line 37 of file regularData2D.h.

## Member Typedef Documentation

## const_iterator

template<typename ValueType>

typedef std::vector<ValueType>::const_iterator BALL::TRegularData2D< ValueType >::const_iterator

Definition at line 76 of file regularData2D.h.

## const_reference

template<typename ValueType>

typedef std::vector<ValueType>::const_reference BALL::TRegularData2D< ValueType >::const_reference

Definition at line 78 of file regularData2D.h.

## ConstIterator

template<typename ValueType>

typedef std::vector<ValueType>::const_iterator BALL::TRegularData2D< ValueType >::ConstIterator

A nonmutable iterator.

Definition at line 69 of file regularData2D.h.

## CoordinateType

template<typename ValueType>

typedef TVector2<float> BALL::TRegularData2D< ValueType >::CoordinateType

The coordinate type.

Definition at line 65 of file regularData2D.h.

## difference_type

template<typename ValueType>

typedef std::vector<ValueType>::difference_type BALL::TRegularData2D< ValueType >::difference_type

Definition at line 80 of file regularData2D.h.

## Iterator

template<typename ValueType>

typedef std::vector<ValueType>::iterator BALL::TRegularData2D< ValueType >::Iterator

A mutable iterator.

Definition at line 67 of file regularData2D.h.

## iterator

template<typename ValueType>

typedef std::vector<ValueType>::iterator BALL::TRegularData2D< ValueType >::iterator

Definition at line 75 of file regularData2D.h.

## pointer

template<typename ValueType>

typedef std::vector<ValueType>::pointer BALL::TRegularData2D< ValueType >::pointer

Definition at line 79 of file regularData2D.h.

## reference

template<typename ValueType>

typedef std::vector<ValueType>::reference BALL::TRegularData2D< ValueType >::reference

Definition at line 77 of file regularData2D.h.

## size_type

template<typename ValueType>

typedef std::vector<ValueType>::size_type BALL::TRegularData2D< ValueType >::size_type

Definition at line 81 of file regularData2D.h.

## value_type

template<typename ValueType>

typedef ValueType BALL::TRegularData2D< ValueType >::value_type

Definition at line 74 of file regularData2D.h.

## VectorType

template<typename ValueType>

typedef std::vector<ValueType> BALL::TRegularData2D< ValueType >::VectorType

The type containing an STL vector of the appropriate type.

Definition at line 63 of file regularData2D.h.

## Constructor & Destructor Documentation

## TRegularData2D() [1/4]

template<class ValueType>

BALL::TRegularData2D< ValueType >::TRegularData2D | ( |  | ) |

Default constructor. Creates an empty TRegularData2D object.

Definition at line 418 of file regularData2D.h.

## TRegularData2D() [2/4]

template<class ValueType>

BALL::TRegularData2D< ValueType >::TRegularData2D | ( | const TRegularData2D< ValueType > & | data | ) |

Copy constructor.

Exceptions

  Exception::OutOfMemory | if the memory for the copy could not be allocated

Definition at line 429 of file regularData2D.h.

## TRegularData2D() [3/4]

template<typename ValueType>

BALL::TRegularData2D< ValueType >::TRegularData2D | ( | const CoordinateType & | origin,
|  | const CoordinateType & | dimension,
|  | const CoordinateType & | spacing )

Constructor.

Parameters

  origin | the origin of the grid
  dimension | the dimension of the grid (extension in x- and y-direction)
  spacing | the grid spacing along the x- and y-axis

Exceptions

  Exception::OutOfMemory | if the memory for the copy grid not be allocated

## TRegularData2D() [4/4]

template<typename ValueType>

BALL::TRegularData2D< ValueType >::TRegularData2D | ( | const IndexType & | size,
|  | const CoordinateType & | origin = CoordinateType(0.0),
|  | const CoordinateType & | dimension = CoordinateType(1.0) )

## ~TRegularData2D()

template<class ValueType>

BALL::TRegularData2D< ValueType >::~TRegularData2D | ( |  | ) |

virtual

Destructor.

Definition at line 508 of file regularData2D.h.

## Member Function Documentation

## begin() [1/2]

template<typename ValueType>

BALL_INLINE Iterator BALL::TRegularData2D< ValueType >::begin | ( |  | ) |

inline

Definition at line 164 of file regularData2D.h.

## begin() [2/2]

template<typename ValueType>

BALL_INLINE ConstIterator BALL::TRegularData2D< ValueType >::begin | ( |  | ) | const

inline

Definition at line 160 of file regularData2D.h.

## binaryRead()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::binaryRead | ( | const String & | filename | ) |

Read the grid contents from a file written with binaryWrite

Exceptions

  Exception::FileNotFound | thrown if file does not exist or could not be read

Definition at line 1071 of file regularData2D.h.

## binaryWrite()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::binaryWrite | ( | const String & | filename | ) | const

Write the grid contents in a (non-portable) binary format.

Exceptions

  Exception::FileNotFound | thrown if the file could not be written

Definition at line 1006 of file regularData2D.h.

## calculateMean()

template<typename ValueType>

BALL_INLINE ValueType BALL::TRegularData2D< ValueType >::calculateMean | ( |  | ) | const

Calculate the mean of the dataset

Returns
  ValueType

Definition at line 905 of file regularData2D.h.

## calculateSD()

template<typename ValueType>

BALL_INLINE ValueType BALL::TRegularData2D< ValueType >::calculateSD | ( |  | ) | const

Calculate the standard deviation of the dataset

Returns
  ValueType

Definition at line 919 of file regularData2D.h.

## clear()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::clear | ( |  | ) |

virtual

Clear method. Delete the grid contents and resize it to zero.

Reimplemented in BALL::TFFT2D< ComplexTraits >, and BALL::TFFT2D< BALL_FFTW_DEFAULT_TRAITS >.

Definition at line 934 of file regularData2D.h.

## empty()

template<typename ValueType>

BALL_INLINE bool BALL::TRegularData2D< ValueType >::empty | ( |  | ) | const

inline

Empty predicate.

Definition at line 150 of file regularData2D.h.

## end() [1/2]

template<typename ValueType>

BALL_INLINE Iterator BALL::TRegularData2D< ValueType >::end | ( |  | ) |

inline

Definition at line 166 of file regularData2D.h.

## end() [2/2]

template<typename ValueType>

BALL_INLINE ConstIterator BALL::TRegularData2D< ValueType >::end | ( |  | ) | const

inline

Definition at line 162 of file regularData2D.h.

## getClosestIndex()

template<typename ValueType>

BALL_INLINE TRegularData2D< ValueType >::IndexType BALL::TRegularData2D< ValueType >::getClosestIndex | ( | const CoordinateType & | v | ) | const

Return the position of the grid point closest to the given vector. If there are multiple grid points with equal distance, the grid point with the lowest indices in x, y direction is returned.

Exceptions

  Exception::OutOfGrid | if the point is outside the grid

Definition at line 854 of file regularData2D.h.

## getClosestValue() [1/2]

template<typename ValueType>

ValueType & BALL::TRegularData2D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) |

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.

Exceptions

  Exception::OutOfGrid | if x is outside the grid boundaries

## getClosestValue() [2/2]

template<typename ValueType>

const ValueType & BALL::TRegularData2D< ValueType >::getClosestValue | ( | const CoordinateType & | x | ) | const

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.

Exceptions

  Exception::OutOfGrid | if x is outside the grid boundaries

## getCoordinates() [1/2]

template<typename ValueType>

CoordinateType BALL::TRegularData2D< ValueType >::getCoordinates | ( | const IndexType & | index | ) | const

Returns the exact coordinates of a grid point.

Returns
  CoordinateType

Exceptions

  Exception::OutOfGrid | if the point is outside the grid boundaries

## getCoordinates() [2/2]

template<class ValueType>

BALL_INLINE TRegularData2D< ValueType >::CoordinateType BALL::TRegularData2D< ValueType >::getCoordinates | ( | Position | index | ) | const

Returns the exact coordinates of a grid point.

Returns
  CoordinateType

Exceptions

  Exception::OutOfGrid | if the point is outside the grid boundaries

Definition at line 730 of file regularData2D.h.

## getData() [1/4]

template<typename ValueType>

ValueType & BALL::TRegularData2D< ValueType >::getData | ( | const IndexType & | index | ) |

Return a mutable reference to a specific data element. This is the range checking version of operator [].

Exceptions

  Exception::OutOfGrid | if index is outside the grid boundaries

## getData() [2/4]

template<typename ValueType>

const ValueType & BALL::TRegularData2D< ValueType >::getData | ( | const IndexType & | index | ) | const

Return a nonmutable reference to a specific data element. This is the range checking version of operator [].

Exceptions

  Exception::OutOfGrid | if index is outside the grid boundaries

## getData() [3/4]

template<class ValueType>

BALL_INLINE ValueType & BALL::TRegularData2D< ValueType >::getData | ( | Position | index | ) |

Return a mutable reference to a specific data element. This is the range checking version of operator [].

Exceptions

  Exception::OutOfGrid | if index is outside the grid boundaries

Definition at line 702 of file regularData2D.h.

## getData() [4/4]

template<class ValueType>

BALL_INLINE const ValueType & BALL::TRegularData2D< ValueType >::getData | ( | Position | index | ) | const

Return a nonmutable reference to a specific data element. This is the range checking version of operator [].

Exceptions

  Exception::OutOfGrid | if index is outside the grid boundaries

Definition at line 691 of file regularData2D.h.

## getDimension()

template<typename ValueType>

const CoordinateType & BALL::TRegularData2D< 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()).

Definition at line 300 of file regularData2D.h.

## getEnclosingIndices()

template<typename ValueType>

BALL_INLINE void BALL::TRegularData2D< ValueType >::getEnclosingIndices | ( | const CoordinateType & | r,
|  | Position & | ll,
|  | Position & | lr,
|  | Position & | ul,
|  | Position & | ur ) const

Return the indices of the grid points of the enclosing rectangle. This method calculates the grid rectangle that contains the given vector and returns the indices of the grid points forming this rectangle. The given point lies either in the rectangle or is the lower left front edge of the rectangle.

Returns
  bool true if the vector is inside the grid

Exceptions

  OutOfGrid | if the point is outside the grid

Parameters

  r | a point inside the grid
  ll | left lower corner of the rectangle
  lr | right lower corner of the rectangle
  ul | left upper corner of the rectangle
  ur | right upper corner of the rectangle

Exceptions

  Exception::OutOfGrid | if the point is outside the grid boundaries

Definition at line 746 of file regularData2D.h.

## getEnclosingValues()

template<typename ValueType>

BALL_INLINE void BALL::TRegularData2D< ValueType >::getEnclosingValues | ( | const CoordinateType & | r,
|  | ValueType & | ll,
|  | ValueType & | lr,
|  | ValueType & | ul,
|  | ValueType & | ur ) const

Return the data at the grid points of the enclosing box.

Exceptions

  Exception::OutOfGrid | if the point is outside the grid boundaries

See also
  getEnclosingIndices

Definition at line 770 of file regularData2D.h.

## getInterpolatedValue()

template<typename ValueType>

BALL_INLINE ValueType BALL::TRegularData2D< ValueType >::getInterpolatedValue | ( | const CoordinateType & | x | ) | const

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.

Exceptions

  Exception::OutOfGrid | if x is outside the grid boundaries

Definition at line 792 of file regularData2D.h.

## getLowerIndex()

template<typename ValueType>

BALL_INLINE TRegularData2D< ValueType >::IndexType BALL::TRegularData2D< ValueType >::getLowerIndex | ( | const CoordinateType & | v | ) | const

Return the position of the next grid point with coordinates smaller than the given vector.

Exceptions

  Exception::OutOfGrid | if the point is outside the grid

Definition at line 837 of file regularData2D.h.

## getOrigin()

template<typename ValueType>

const CoordinateType & BALL::TRegularData2D< ValueType >::getOrigin | ( |  | ) | const

inline

Return the origin of the data. The origin represents the coordinate of the very first (lower left) element, i.e. data_[0].

Definition at line 283 of file regularData2D.h.

## getSize()

template<typename ValueType>

const IndexType & BALL::TRegularData2D< ValueType >::getSize | ( |  | ) | const

inline

Return the size of the grid. This method yields the number of grid points in x- and y-direction. Use size to obtain the total number of points in the grid.

Definition at line 277 of file regularData2D.h.

## getSpacing()

template<typename ValueType>

const CoordinateType & BALL::TRegularData2D< ValueType >::getSpacing | ( |  | ) | const

inline

Return the spacing of the data. The spacing corresponds to the distance between two adjacent data elements.

Definition at line 289 of file regularData2D.h.

## isInside()

template<typename ValueType>

BALL_INLINE bool BALL::TRegularData2D< ValueType >::isInside | ( | const CoordinateType & | x | ) | const

Test if a given point is inside the grid.

Definition at line 658 of file regularData2D.h.

## max_size()

template<typename ValueType>

BALL_INLINE size_type BALL::TRegularData2D< ValueType >::max_size | ( |  | ) | const

inline

Definition at line 174 of file regularData2D.h.

## operator!=()

template<typename ValueType>

BALL_INLINE bool BALL::TRegularData2D< ValueType >::operator!= | ( | const TRegularData2D< ValueType > & | data | ) | const

inline

Inequality operator.

Definition at line 147 of file regularData2D.h.

## operator()()

template<typename ValueType>

BALL_INLINE ValueType BALL::TRegularData2D< ValueType >::operator() | ( | const CoordinateType & | x | ) | const

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 .

Definition at line 805 of file regularData2D.h.

## operator=()

template<typename ValueType>

BALL_INLINE TRegularData2D< ValueType > & BALL::TRegularData2D< ValueType >::operator= | ( | const TRegularData2D< ValueType > & | data | ) |

Assignment operator. Copy the data, the origin, and the dimension (spacing is copied implicitly as well).

Exceptions

  Exception::OutOfMemory | if the memory for the copy could not be allocated

Definition at line 515 of file regularData2D.h.

## operator==()

template<typename ValueType>

bool BALL::TRegularData2D< ValueType >::operator== | ( | const TRegularData2D< ValueType > & | data | ) | const

Equality operator. Two grids are equal if they have the same number of points in all two dimensions, same origin, spacing and the data fields are equal.

Definition at line 946 of file regularData2D.h.

## operator[]() [1/4]

template<typename ValueType>

ValueType & BALL::TRegularData2D< ValueType >::operator[] | ( | const IndexType & | index | ) |

inline

Mutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 212 of file regularData2D.h.

## operator[]() [2/4]

template<typename ValueType>

const ValueType & BALL::TRegularData2D< ValueType >::operator[] | ( | const IndexType & | index | ) | const

inline

Nonmutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 206 of file regularData2D.h.

## operator[]() [3/4]

template<typename ValueType>

ValueType & BALL::TRegularData2D< ValueType >::operator[] | ( | Position | index | ) |

inline

Mutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 224 of file regularData2D.h.

## operator[]() [4/4]

template<typename ValueType>

const ValueType & BALL::TRegularData2D< ValueType >::operator[] | ( | Position | index | ) | const

inline

Nonmutable random access operator.

Note
  No range checking is done. For a more robust version, please use getData.

Definition at line 218 of file regularData2D.h.

## rescale()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::rescale | ( | const IndexType & | new_size | ) |

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.

Parameters

  new_size | the new data set size

Exceptions

  Exception::OutOfMemory | if the memory for the resized grid could not be allocated

Definition at line 544 of file regularData2D.h.

## resize()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::resize | ( | const IndexType & | new_size | ) |

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.

  The boundaries are adapted and the positions of the retained items fixed, i.e. the dimension is increased or decreased proportionally while the origin remains unchanged.

Parameters

  new_size | the new size

Exceptions

  Exception::OutOfMemory | if the memory for the resized grid could not be allocated

Definition at line 595 of file regularData2D.h.

## setDimension()

template<typename ValueType>

void BALL::TRegularData2D< 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 scling factor and affect the spacing.

Definition at line 307 of file regularData2D.h.

## setOrigin()

template<typename ValueType>

void BALL::TRegularData2D< ValueType >::setOrigin | ( | const CoordinateType & | origin | ) |

Set the origin of the data.

Definition at line 651 of file regularData2D.h.

## size()

template<typename ValueType>

BALL_INLINE size_type BALL::TRegularData2D< ValueType >::size | ( |  | ) | const

inline

Definition at line 173 of file regularData2D.h.

## swap()

template<typename ValueType>

BALL_INLINE void BALL::TRegularData2D< ValueType >::swap | ( | TRegularData2D< ValueType > & | data | ) |

inline

Definition at line 175 of file regularData2D.h.

## Member Data Documentation

## data_

template<typename ValueType>

VectorType BALL::TRegularData2D< ValueType >::data_

protected

The grid data.

Definition at line 394 of file regularData2D.h.

## dimension_

template<typename ValueType>

CoordinateType BALL::TRegularData2D< ValueType >::dimension_

protected

Dimension of the grid.

Definition at line 400 of file regularData2D.h.

## origin_

template<typename ValueType>

CoordinateType BALL::TRegularData2D< ValueType >::origin_

protected

Origin of the grid (offset).

Definition at line 397 of file regularData2D.h.

## size_

template<typename ValueType>

IndexType BALL::TRegularData2D< ValueType >::size_

protected

The dimensions in grid points.

Definition at line 406 of file regularData2D.h.

## spacing_

template<typename ValueType>

CoordinateType BALL::TRegularData2D< ValueType >::spacing_

protected

Grid spacing.

Definition at line 403 of file regularData2D.h.