ESYS13  Revision_
Public Types | Public Member Functions | Private Attributes
escript::DataVector Class Reference

DataVector implements an arbitrarily long vector of data values. DataVector is the underlying data container for Data objects. More...

#include <DataVector.h>

List of all members.

Public Types

typedef double ElementType
typedef ElementTypeValueType
typedef const ElementTypeConstValueType
typedef ElementType value_type
typedef long size_type
typedef ElementTypereference
typedef const ElementTypeconst_reference

Public Member Functions

 DataVector ()
 Default constructor for DataVector.
 DataVector (const DataVector &other)
 Copy constructor for DataVector.
 DataVector (const size_type size, const value_type val=0.0, const size_type blockSize=1)
 Constructor for DataVector.
 ~DataVector ()
 Default destructor for DataVector.
void resize (const size_type newSize, const value_type newVal=0.0, const size_type newBlockSize=1)
 Resize the DataVector to the given length "newSize". All current data is lost. All elements in the new DataVector are initialised to "newVal".
void copyFromArray (const escript::WrappedArray &value, size_type copies)
 Populates the vector with the data from value. This method currently throws an exception if the specified number of copies won't fit.
void copyFromArrayToOffset (const WrappedArray &value, size_type offset, size_type copies)
size_type size () const
 Return the number of elements in this DataVector.
DataVectoroperator= (const DataVector &other)
 DataVector assignment operator "=". Assign the given DataVector object to this.
bool operator== (const DataVector &other) const
 DataVector equality comparison operator "==". Return true if the given DataVector is equal to this.
bool operator!= (const DataVector &other) const
 DataVector inequality comparison operator "!=". Return true if the given DataVector is not equal to this.
reference operator[] (const size_type i)
 Return a reference to the element at position i in this DataVector. Will throw an exception if an invalid index "i" is given.
const_reference operator[] (const size_type i) const

Private Attributes

size_type m_size
size_type m_dim
size_type m_N
ValueType m_array_data

Detailed Description

DataVector implements an arbitrarily long vector of data values. DataVector is the underlying data container for Data objects.

Description: DataVector provides an implementation of a vector of data values for use by DataBlocks2D and DataArrayView. Hiding the vector in this container allows different implementations to be swapped in without disrupting the client classes.


Member Typedef Documentation


Constructor & Destructor Documentation

Default constructor for DataVector.

Description: Constructs an empty DataVector object.

Copy constructor for DataVector.

Description: Constructs a DataVector object which is a copy of the given DataVector object.

References escript::arrayManager, m_array_data, m_dim, m_N, m_size, and escript::Taipan::new_array().

escript::DataVector::DataVector ( const size_type  size,
const value_type  val = 0.0,
const size_type  blockSize = 1 
)

Constructor for DataVector.

Description: Constructs a DataVector object of length "size" with all elements initilised to "val".

Parameters:
size- Input - Number of elements in the vector.
val- Input - Initial value for all elements in the vector. Default is 0.0.
blockSize- Input - size of blocks within the vector, overall vector size must be a precise multiple of the block size. Default is 1.

In escript::Data, blocksize corresponds to the number of elements required to hold all the data-points for a sample, ie: the product of the dimensions of a data-point and the number of data-points per sample. Size is the total number of elements required to hold all elements for all data-points in the given object, ie: number of samples * blocksize.

References resize().

Default destructor for DataVector.

Description: Destroys the current DataVector object.

References escript::arrayManager, escript::Taipan::delete_array(), m_array_data, m_dim, m_N, and m_size.


Member Function Documentation

Populates the vector with the data from value. This method currently throws an exception if the specified number of copies won't fit.

Warning:
This function does not attempt to perform shape checking.

References escript::arrayManager, copyFromArrayToOffset(), escript::Taipan::delete_array(), escript::WrappedArray::getShape(), m_array_data, m_dim, m_N, m_size, escript::Taipan::new_array(), and escript::DataTypes::noValues().

Referenced by escript::DataExpanded::copy(), escript::DataConstant::DataConstant(), and escript::Data::setTaggedValue().

void escript::DataVector::copyFromArrayToOffset ( const WrappedArray value,
size_type  offset,
size_type  copies 
)
bool escript::DataVector::operator!= ( const DataVector other) const

DataVector inequality comparison operator "!=". Return true if the given DataVector is not equal to this.

DataVector & escript::DataVector::operator= ( const DataVector other)

DataVector assignment operator "=". Assign the given DataVector object to this.

References escript::arrayManager, escript::Taipan::delete_array(), m_array_data, m_dim, m_N, m_size, and escript::Taipan::new_array().

bool escript::DataVector::operator== ( const DataVector other) const

DataVector equality comparison operator "==". Return true if the given DataVector is equal to this.

References m_array_data, m_dim, m_N, and m_size.

DataVector::reference escript::DataVector::operator[] ( const size_type  i) [inline]

Return a reference to the element at position i in this DataVector. Will throw an exception if an invalid index "i" is given.

NB: access to the element one past the end of the vector is permitted in order to provide a facility equivalent to an end() pointer.

References EsysAssert, m_array_data, and size().

DataVector::const_reference escript::DataVector::operator[] ( const size_type  i) const [inline]

References EsysAssert, m_array_data, and size().

void escript::DataVector::resize ( const size_type  newSize,
const value_type  newVal = 0.0,
const size_type  newBlockSize = 1 
)

Resize the DataVector to the given length "newSize". All current data is lost. All elements in the new DataVector are initialised to "newVal".

Parameters:
newSize- Input - New size for the vector.
newVal- Input - New initial value for all elements in the vector.
newBlockSize- Input - New block size for the vector.

References escript::arrayManager, escript::Taipan::delete_array(), m_array_data, m_dim, m_N, m_size, and escript::Taipan::new_array().

Referenced by escript::DataTagged::addTag(), escript::DataTagged::addTaggedValue(), escript::DataConstant::DataConstant(), escript::DataTagged::DataTagged(), DataVector(), and escript::DataBlocks2D::resize().


Member Data Documentation


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