USML
seq_vector Class Referenceabstract

Detailed Description

A read-only, monotonic sequence of values.

Designed to be used as an interpolation axis for a multi-dimensional data sets. Fast interpolation algorithms require an ability to quickly lookup an axis index appropriate given a floating point axis value.

This class caches data values and increments in ublas::vector<> objects. This allow frequently used operations (ex: operator[] and increment()) access to inlined methods and cached values instead of computed results. Sub-classes often store an additional representation of this data that is used to implement fast versions of the find_index() method.

This design uses zero_vector<T> as a model of how to implement a read-only uBLAS vector. Implements subclass methods as virtual functions, instead of traits, so that they can be resolved at run-time. Run-time resolution is critical to reading sequences from netCDF data files.

Member Typedef Documentation

typedef vector<value_type>::array_type array_type
typedef vector_reference<self_type> closure_type
typedef const vector_reference<const self_type> const_closure_type
typedef reverse_iterator_base<const_iterator> const_reverse_iterator
typedef seq_vector self_type
private
typedef vector<value_type>::size_type size_type
typedef double value_type

Constructor & Destructor Documentation

seq_vector ( size_type  size)
inlineprotected

Initialize data caches.

seq_vector ( const seq_vector copy)
inlineprotected

Copies data from another seq_vector object.

Parameters
copyThe object to be copied.
virtual ~seq_vector ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

const_iterator begin ( ) const
inline

Create iterator for the beginning of sequence.

Required for inheritance from vector_container.

virtual seq_vector* clone ( ) const
pure virtual

Create a copy using a reference to the base class.

Implemented in seq_data, seq_log, and seq_linear.

const array_type& data ( ) const
inline

Convert seqence into a normal C++ array,.

const_iterator end ( ) const
inline

Create iterator for the end of sequence.

Required for inheritance from vector_container.

const_iterator find ( size_type  index) const
inline

Create iterator for a random position in the sequence.

Required for inheritance from vector_container.

virtual size_type find_index ( value_type  value)
pure virtual

Search for a value in this sequence.

If the value is outside of the legal range, the index for the nearest endpoint will be returned.

This reverse lookup is the principle feature that distinguishes seq_vector objects from ordinary vectors.

Parameters
valueValue of the element to find.
Returns
Index of the largest value that is not greater than the argument.

Implemented in seq_data, seq_log, and seq_linear.

value_type increment ( size_type  index) const
inline

Retrieves the increment between two elements in this sequence.

If the index is outside of the range [0,size-1), the value for the nearest endpoint will be returned.

Parameters
indexThe element number to retrieve (zero indexed).
Returns
The difference between the element at "index" and the element at "index+1".
virtual value_type operator() ( size_type  index) const
inlinevirtual

Retrieves the value at a specified index in the sequence in the safest way possible.

If the index is outside of the range [0,size), the value for the nearest endpoint will be returned.

Parameters
indexThe index of element to retrieve (zero indexed).
Returns
The value at the indexed element.
value_type operator[] ( size_type  index) const
inline

Retrieves the value at a specified index in the sequence in the fastest way possible.

Problems will occur if the index is outside of the range [0,size-1),

Parameters
indexThe element number to retrieve (zero indexed).
Returns
The value between the "index" element.
const_reverse_iterator rbegin ( ) const
inline

Create iterator for the beginning of reverse sequence.

Required for inheritance from vector_container.

const_reverse_iterator rend ( ) const
inline

Create iterator for the end of reverse sequence.

Required for inheritance from vector_container.

size_type size ( ) const
inline

Returns the number of elements in this sequence.

Member Data Documentation

vector<value_type> _data
protected

Cache of sequence values.

vector<value_type> _increment
protected

Cache of increment values.

const size_type _max_index
protected

Largest valid index number (one less than _size).

const size_type _size
protected

Number of elements in the sequence.