Diana  0.8.3
Public Types | Public Member Functions | Private Member Functions | Private Attributes
array< _T > Class Template Reference

Basic class definition for the dense arrays. More...

#include <DianaArray.hpp>

List of all members.

Public Types

typedef _T tvalue
 Type of the array value.
typedef
Common::Types::CapeArrayLong 
tindices
 Type of the array indices.
typedef std::vector< tvaluetvalues
 Type of the values internal container.
typedef size_t size_type
 Array size type.

Public Member Functions

 array ()
 Default constructor creates no array.
 array (const tindices &_dims)
 Constructor creates array with predefined dimensions.
 array (int nelems, tvalue *vals)
 Constructor creates a vector.
 array (std::vector< tvalue > vals)
 Constructor creates a vector.
 array (int nrows, int ncols)
 Constructor creates two dimensional array.
 array (const array &ar)
 Array copy constructor.
arrayoperator= (const array &ar)
 Array assignment operator.
virtual ~array ()
 Empty virtual dtor.
int rank () const
 Returns number of dimensions.
size_type size () const
 Returns the number of elements in the array.
const tindicesdimensions () const
 Returns the dimensions of the array.
Common::Types::CapeBoolean empty () const
 Returns true if the array is empty.
tvalueat (size_type __n)
 Provides access to the data contained in the array.
const tvalueat (size_type __n) const
 Provides access to the data contained in the array.
tvalueoperator[] (size_type __n)
 Subscript access to the data contained in the array.
const tvalueoperator[] (size_type __n) const
 Subscript access to the data contained in the array.
tvalue front () const
 Returns a value of the first element in the array.
tvalue back () const
 Returns a value of the last element in the array.
int find (const tindices &idx) const
 Returns a position of the element in the array.
void set_value (const tindices &idx, tvalue value)
 Assigns a value to array entry by its indices.
void set_value (tvalue value)
 Assigns a value to the whole array.
void set_values (const tvalues &_values)
 Assigns a vector with values to the whole array.
void add_value (const tindices &idx, tvalue value)
 Adds a value to array entry by its indices.
tvalue get_value (const tindices &idx) const
 Returns a value of the array entry by its indices.
tvalue get_value (...) const
 Returns a value of the array entry by its indices.
const tvaluesget_values () const
 Returns a vector with values of the whole array .

Private Member Functions

void check_range (size_type __n, const char *func_name=NULL) const
 Updates a value of the array entry by its indices.

Private Attributes

tvalues values
 Array data internal container.
tindices dims
 Array dimensions.

Detailed Description

template<typename _T>
class Diana::array< _T >

Basic class definition for the dense arrays.

Author:
Michael Krasnyk miha@mpi-magdeburg.mpg.de
Date:
5 October 2005

Constructor & Destructor Documentation

array ( const tindices _dims) [inline]

Constructor creates array with predefined dimensions.

Parameters:
indicesVector with dimensions sizes. Dimensions can not be changed during array object life time.

Dimensions sizes are elements of the indices array, so the first dimension is indices[0], the second is indices[1], the last is indices.back() and the rank of the array is the indices.size() (here term rank used in the sense of tensors),

array ( int  nelems,
tvalue vals 
) [inline]

Constructor creates a vector.

Parameters:
nelemsNumber of elements in the vector.
array ( std::vector< tvalue vals) [inline]

Constructor creates a vector.

Parameters:
nelemsNumber of elements in the vector.
array ( int  nrows,
int  ncols 
) [inline]

Constructor creates two dimensional array.

Parameters:
nrowsNumber of rows.
ncolsNumber of columns.
array ( const array< _T > &  ar) [inline]

Array copy constructor.

Parameters:
arAn array of identical element.

Member Function Documentation

void add_value ( const tindices idx,
tvalue  value 
) [inline]

Adds a value to array entry by its indices.

Parameters:
idxEntry indices.
valueArray entry increment.
tvalue& at ( size_type  __n) [inline]

Provides access to the data contained in the array.

Parameters:
__nThe row major index of the element for which data should be accessed.
Returns:
Read/write reference to data.
Exceptions:
std::stringIf __n is an invalid index.

This function provides for safer data access. The parameter is first checked that it is in the range of the array. The function throws std::string if the check fails.

const tvalue& at ( size_type  __n) const [inline]

Provides access to the data contained in the array.

Parameters:
__nThe row major index of the element for which data should be accessed.
Returns:
Read-only reference to data.
Exceptions:
std::stringIf __n is an invalid index.

This function provides for safer data access. The parameter is first checked that it is in the range of the array. The function throws std::string if the check fails.

void check_range ( size_type  __n,
const char *  func_name = NULL 
) const [inline, private]

Updates a value of the array entry by its indices.

Parameters:
idxEntry indices.
valueUpdate value.
additionType of the update. For addition is true update will be addition, otherwise update will be assignment. Checks index in the range of the array.
__nThe row major index of the element.
func_nameName of the testing function.
Exceptions:
std::stringIf __n is an invalid index.

Referenced by array< Common::Parameter::ICapeParameter * >::at().

int find ( const tindices idx) const [inline]

Returns a position of the element in the array.

Parameters:
idxElement indices.
Returns:
Row major position of the element in the array.

Referenced by array< Common::Parameter::ICapeParameter * >::add_value(), array< Common::Parameter::ICapeParameter * >::get_value(), and array< Common::Parameter::ICapeParameter * >::set_value().

tvalue get_value ( const tindices idx) const [inline]

Returns a value of the array entry by its indices.

Parameters:
idxEntry indices.

Referenced by array< Common::Parameter::ICapeParameter * >::get_value().

tvalue get_value (   ...) const [inline]

Returns a value of the array entry by its indices.

Number of arguments should be equal to the rank of the array. Type of arguments is int. This method is experimental, so it should be used very carefully.

array& operator= ( const array< _T > &  ar) [inline]

Array assignment operator.

Parameters:
arAn array of identical element.
tvalue& operator[] ( size_type  __n) [inline]

Subscript access to the data contained in the array.

Parameters:
__nThe row major index of the element for which data should be accessed.
Returns:
Read/write reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

const tvalue& operator[] ( size_type  __n) const [inline]

Subscript access to the data contained in the array.

Parameters:
__nThe row major index of the element for which data should be accessed.
Returns:
Read-only (constant) reference to data.

This operator allows for easy, array-style, data access. Note that data access with this operator is unchecked and out_of_range lookups are not defined. (For checked lookups see at().)

int rank ( ) const [inline]

Returns number of dimensions.

Here term rank is used in the sense of tensors and it is not a rank of the linear operator.

Referenced by array< Common::Parameter::ICapeParameter * >::get_value().

void set_value ( const tindices idx,
tvalue  value 
) [inline]

Assigns a value to array entry by its indices.

Parameters:
idxEntry indices.
valueNew element value.
void set_value ( tvalue  value) [inline]

Assigns a value to the whole array.

Parameters:
valueNew array value.
void set_values ( const tvalues _values) [inline]

Assigns a vector with values to the whole array.

Parameters:
_valuesNew array values.

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