Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Related Functions | List of all members
Teuchos::TwoDArray< T > Class Template Reference

A thin wrapper around the Array class which causes it to be interpreted as a 2D Array. More...

#include <Teuchos_TwoDArray.hpp>

Public Types

typedef Ordinal size_type
 

Public Member Functions

Constructors and Destructors
 TwoDArray (size_type numRows, size_type numCols, T value=T())
 Constructs a TwoDArray with the given number of rows and columns with each entry being populated with the specified value. More...
 
 TwoDArray ()
 Constructs an empty TwoDArray. More...
 
virtual ~TwoDArray ()
 
Getters and Setters
ArrayView< T > operator[] (size_type i)
 Returns an ArrayView containing the contents of row i. More...
 
ArrayView< const T > operator[] (size_type i) const
 Returns a const ArrayView containing the contents of row i. More...
 
size_type getNumRows () const
 returns the number of rows in the TwoDArray. More...
 
size_type getNumCols () const
 returns the number of columns in the TwoDArray. More...
 
const Array< T > & getDataArray () const
 Returns the 1D array that is backing this TwoDArray. More...
 
T & operator() (size_type i, size_type j)
 Returns the element located at i,j. More...
 
const T & operator() (size_type i, size_type j) const
 Returns the element located at i,j. More...
 
void clear ()
 delets all the entries from the TwoDArray More...
 
bool isEmpty ()
 
bool isSymmetrical () const
 A simple flag indicating whether or not this TwoDArray should be interpurted as symmetrical. More...
 
void setSymmetrical (bool symmetrical)
 Sets whether or not the the TwoDArray should be interpurted as symetric. More...
 
Resizing Functions
void resizeRows (size_type numberOfRows)
 Changes the number of rows in the matrix. More...
 
void resizeCols (size_type numberOfCols)
 Changes the number of rows in the matrix. More...
 

Static Public Member Functions

String conversion functions
static const std::string & getMetaSeperator ()
 returns the string used to seperate meta information from actual data information when converting a TwoDArray to a string. More...
 
static const std::string & getDimensionsDelimiter ()
 returns the string used as the dimension dilimeter when convering the TwoDArray to a string. More...
 
static std::string toString (const TwoDArray< T > array)
 Converts a given TwoDArray to a valid string representation. More...
 
static TwoDArray< T > fromString (const std::string &string)
 Converts a valid string to it's corresponding TwoDArray. More...
 

Related Functions

(Note that these are not member functions.)

std::string getTwoDArrayTypeNameTraitsFormat ()
 Get the format that is used for the specialization of the TypeName traits class for TwoDArray. More...
 

Detailed Description

template<class T>
class Teuchos::TwoDArray< T >

A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.

2D Array's can also be "symetric". This means that anyone viewing the Array should only consider the lower half of the array as valid. The

Warning
The TwoDArray will not enforce symetry. However, when two symmetrical TwoDArrays are compared, only the the lower half of the TwoDArray's will be compared.

Definition at line 68 of file Teuchos_TwoDArray.hpp.

Member Typedef Documentation

template<class T>
typedef Ordinal Teuchos::TwoDArray< T >::size_type

Definition at line 73 of file Teuchos_TwoDArray.hpp.

Constructor & Destructor Documentation

template<class T>
Teuchos::TwoDArray< T >::TwoDArray ( size_type  numRows,
size_type  numCols,
value = T() 
)
inline

Constructs a TwoDArray with the given number of rows and columns with each entry being populated with the specified value.

Parameters
numColsThe number of columns in the TwoDArray.
numRowsThe number of rows in the TwoDArray.
valueThe value with which to populate the TwoDArray.

Definition at line 86 of file Teuchos_TwoDArray.hpp.

template<class T>
Teuchos::TwoDArray< T >::TwoDArray ( )
inline

Constructs an empty TwoDArray.

Definition at line 95 of file Teuchos_TwoDArray.hpp.

template<class T>
virtual Teuchos::TwoDArray< T >::~TwoDArray ( )
inlinevirtual

Definition at line 99 of file Teuchos_TwoDArray.hpp.

Member Function Documentation

template<class T >
ArrayView< T > Teuchos::TwoDArray< T >::operator[] ( size_type  i)
inline

Returns an ArrayView containing the contents of row i.

Definition at line 264 of file Teuchos_TwoDArray.hpp.

template<class T >
ArrayView< const T > Teuchos::TwoDArray< T >::operator[] ( size_type  i) const
inline

Returns a const ArrayView containing the contents of row i.

Definition at line 269 of file Teuchos_TwoDArray.hpp.

template<class T>
size_type Teuchos::TwoDArray< T >::getNumRows ( ) const
inline

returns the number of rows in the TwoDArray.

Definition at line 113 of file Teuchos_TwoDArray.hpp.

template<class T>
size_type Teuchos::TwoDArray< T >::getNumCols ( ) const
inline

returns the number of columns in the TwoDArray.

Definition at line 118 of file Teuchos_TwoDArray.hpp.

template<class T>
const Array<T>& Teuchos::TwoDArray< T >::getDataArray ( ) const
inline

Returns the 1D array that is backing this TwoDArray.

Definition at line 123 of file Teuchos_TwoDArray.hpp.

template<class T>
T& Teuchos::TwoDArray< T >::operator() ( size_type  i,
size_type  j 
)
inline

Returns the element located at i,j.

Definition at line 128 of file Teuchos_TwoDArray.hpp.

template<class T>
const T& Teuchos::TwoDArray< T >::operator() ( size_type  i,
size_type  j 
) const
inline

Returns the element located at i,j.

Definition at line 133 of file Teuchos_TwoDArray.hpp.

template<class T>
void Teuchos::TwoDArray< T >::clear ( )
inline

delets all the entries from the TwoDArray

Definition at line 138 of file Teuchos_TwoDArray.hpp.

template<class T>
bool Teuchos::TwoDArray< T >::isSymmetrical ( ) const
inline

A simple flag indicating whether or not this TwoDArray should be interpurted as symmetrical.

Note
A symmetrical TwoDArray is defined as an TwoDArray where entry i,j is the same as entry j,i.
This does not change any of the TwoDArrays behavior. It merely serves as an indicator to any one using a TwoDArray that the TwoDArray can be read as if it were symmetrical. In other words, the TwoDArray class does not enforce the symetry.
Returns
True if the array is "symmetrical", false otherwise.

Definition at line 163 of file Teuchos_TwoDArray.hpp.

template<class T>
void Teuchos::TwoDArray< T >::setSymmetrical ( bool  symmetrical)
inline

Sets whether or not the the TwoDArray should be interpurted as symetric.

Note
A symmetrical TwoDArray is defined as an TwoDArray where entry i,j is the same as entry j,i.
This does not change any of the TwoDArrays behavior. It merely serves as an indicator to any one using a TwoDArray that the TwoDArray can be read as if it were symmetrical. In other words, the TwoDArray class does not enforce the symetry.
Parameters
symmetricalWhether or not the matrix should be interpurted as symetric.

Definition at line 182 of file Teuchos_TwoDArray.hpp.

template<class T >
void Teuchos::TwoDArray< T >::resizeRows ( size_type  numberOfRows)

Changes the number of rows in the matrix.

If the new number of rows is less than the current number, the last rows in the array will be deleted (i.e. if an array has 10 rows and it is resized to have only 5 rows, rows 5-9 are deleted). If the new number of rows is greater than the current number of rows, the rows are appended on to the end of the array and the new entries are initialized to T's default value.

Parameters
numberOfRowsThe new number of rows the TwoDArray should have.

Definition at line 274 of file Teuchos_TwoDArray.hpp.

template<class T >
void Teuchos::TwoDArray< T >::resizeCols ( size_type  numberOfCols)

Changes the number of rows in the matrix.

If the new number of columns is less than the current number, the last columns in the array will be deleted (i.e. if an array has 10 columns and it is resized to have only 5 columns, columns 5-9 are deleted). If the new number of columns is greater than the current number of columns, the columns are appended on to the end of the array and the new entries are initialized to T's default value.

Warning
This operation has the potential to be very expensive as it essentially creates an entirely new 2DArray. Please take this into account when using this function.
Parameters
numberOfColsThe new number of rows the TwoDArray should have.

Definition at line 281 of file Teuchos_TwoDArray.hpp.

template<class T>
static const std::string& Teuchos::TwoDArray< T >::getMetaSeperator ( )
inlinestatic

returns the string used to seperate meta information from actual data information when converting a TwoDArray to a string.

Definition at line 229 of file Teuchos_TwoDArray.hpp.

template<class T>
static const std::string& Teuchos::TwoDArray< T >::getDimensionsDelimiter ( )
inlinestatic

returns the string used as the dimension dilimeter when convering the TwoDArray to a string.

Definition at line 237 of file Teuchos_TwoDArray.hpp.

template<class T >
std::string Teuchos::TwoDArray< T >::toString ( const TwoDArray< T >  array)
static

Converts a given TwoDArray to a valid string representation.

Definition at line 295 of file Teuchos_TwoDArray.hpp.

template<class T >
TwoDArray< T > Teuchos::TwoDArray< T >::fromString ( const std::string &  string)
static

Converts a valid string to it's corresponding TwoDArray.

Definition at line 311 of file Teuchos_TwoDArray.hpp.

Friends And Related Function Documentation

template<class T>
std::string getTwoDArrayTypeNameTraitsFormat ( )
related

Get the format that is used for the specialization of the TypeName traits class for TwoDArray.

The string returned will contain only one "*" character. The "*" character should then be replaced with the actual template type of the array.

Definition at line 442 of file Teuchos_TwoDArray.hpp.


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