UQTk: Uncertainty Quantification Toolkit 3.1.5
Array2D< T > Class Template Reference

Stores data of any type T in a 2D array. More...

#include <Array2D.h>

Public Member Functions

 Array2D ()
 Default constructor, which does not allocate any memory.
 
 Array2D (const int &nx, const int &ny)
 Constructor that allocates the memory.
 
 Array2D (const int &nx, const int &ny, const T &t)
 Constructor that allocates and initializes the data to a constant t.
 
 Array2D (const Array2D &obj)
 Copy constructor.
 
 ~Array2D ()
 Destructor that frees up the memory.
 
void Clear ()
 Function to clear the memory.
 
int XSize () const
 Returns size in the x-direction.
 
int YSize () const
 Returns size in the y-direction.
 
void Resize (const int &nx, const int &ny)
 Resizes the array.
 
void Resize (const int &nx, const int &ny, const T &t)
 Resizes the array and sets ALL entries to the specified value.
 
void SetValue (const T &t)
 Set all values in the array to the given value.
 
T * GetArrayPointer ()
 Return a pointer to the first element of the data in the vector so we can use it access the data in array format (e.g. for passing it to a Fortran program).
 
const T * GetConstArrayPointer () const
 Return a cont point to the first element of the data in the vector so we can use it access the data in array format (e.g. for passing it to a Fortran program).
 
T & operator() (int ix, int iy)
 C-like () operator to access values in the 2D data array.
 
const T & operator() (int ix, int iy) const
 
void insertRow (Array1D< T > &insarr, int ix)
 Insert array insarr as a row into position ix.
 
void insertRow (Array2D< T > &insarr, int ix)
 Insert a 2d-array insarr into a row position ix.
 
void eraseRow (int ix)
 Erase the row ix.
 
void insertCol (Array1D< T > &insarr, int iy)
 
void insertCol (Array2D< T > &insarr, int iy)
 Insert a 2d-array insarr into a column position iy.
 
void eraseCol (int iy)
 Erase the column iy.
 
void DumpBinary (FILE *f_out) const
 Dump contents of the array to a file in binary format.
 
void ReadBinary (FILE *f_in)
 Read contents of the array from a file in binary format.
 
Array1D< T > & operator[] (int ix)
 
vector< int > shape ()
 
void getRow (int row)
 
void DumpBinary (char *filename)
 
void ReadBinary (char *filename)
 
void DumpBinary4py (char *filename)
 
void ReadBinary4py (char *filename, int n1, int n2)
 
void setArray (vector< T > inarray)
 
void setnpdblArray (double *inarray, int n1, int n2)
 
void getnpdblArray (double *outarray)
 
void setnpintArray (long *inarray, int n1, int n2)
 
void getnpintArray (long *outarray)
 
T & at (int ix, int iy)
 
vector< T > flatten ()
 
string type ()
 
void assign (const int x, const int y, const T val)
 

Public Attributes

int xsize_
 
int ysize_
 
vector< T > data_
 
Array1D< T > arraycopy
 
Array1D< T > rowvec
 

Detailed Description

template<typename T>
class Array2D< T >

Stores data of any type T in a 2D array.

This class also provides a Fortran-like access operator () as well as a function to access the data in the array through a pointer that can be passed to F77 or C routines.

Author
Bert Debusschere bjdeb.nosp@m.us@s.nosp@m.andia.nosp@m..gov
Date
Jan 2005
Note
Inspired by Helgi Adalsteinsson's Array class implementation
Todo
Define copy constructor

Constructor & Destructor Documentation

◆ Array2D() [1/4]

template<typename T >
Array2D< T >::Array2D ( )
inline

Default constructor, which does not allocate any memory.

◆ Array2D() [2/4]

template<typename T >
Array2D< T >::Array2D ( const int & nx,
const int & ny )
inline

Constructor that allocates the memory.

◆ Array2D() [3/4]

template<typename T >
Array2D< T >::Array2D ( const int & nx,
const int & ny,
const T & t )
inline

Constructor that allocates and initializes the data to a constant t.

◆ Array2D() [4/4]

template<typename T >
Array2D< T >::Array2D ( const Array2D< T > & obj)
inline

Copy constructor.

◆ ~Array2D()

template<typename T >
Array2D< T >::~Array2D ( )
inline

Destructor that frees up the memory.

Member Function Documentation

◆ assign()

template<typename T >
void Array2D< T >::assign ( const int x,
const int y,
const T val )
inline

◆ at()

template<typename T >
T & Array2D< T >::at ( int ix,
int iy )
inline

◆ Clear()

template<typename T >
void Array2D< T >::Clear ( )
inline

Function to clear the memory.

◆ DumpBinary() [1/2]

template<typename T >
void Array2D< T >::DumpBinary ( char * filename)
inline

◆ DumpBinary() [2/2]

template<typename T >
void Array2D< T >::DumpBinary ( FILE * f_out) const
inline

Dump contents of the array to a file in binary format.

◆ DumpBinary4py()

template<typename T >
void Array2D< T >::DumpBinary4py ( char * filename)
inline

◆ eraseCol()

template<typename T >
void Array2D< T >::eraseCol ( int iy)
inline

Erase the column iy.

◆ eraseRow()

template<typename T >
void Array2D< T >::eraseRow ( int ix)
inline

Erase the row ix.

◆ flatten()

template<typename T >
vector< T > Array2D< T >::flatten ( )
inline

◆ GetArrayPointer()

template<typename T >
T * Array2D< T >::GetArrayPointer ( )
inline

Return a pointer to the first element of the data in the vector so we can use it access the data in array format (e.g. for passing it to a Fortran program).

◆ GetConstArrayPointer()

template<typename T >
const T * Array2D< T >::GetConstArrayPointer ( ) const
inline

Return a cont point to the first element of the data in the vector so we can use it access the data in array format (e.g. for passing it to a Fortran program).

◆ getnpdblArray()

template<typename T >
void Array2D< T >::getnpdblArray ( double * outarray)
inline

◆ getnpintArray()

template<typename T >
void Array2D< T >::getnpintArray ( long * outarray)
inline

◆ getRow()

template<typename T >
void Array2D< T >::getRow ( int row)
inline

◆ insertCol() [1/2]

template<typename T >
void Array2D< T >::insertCol ( Array1D< T > & insarr,
int iy )
inline

◆ insertCol() [2/2]

template<typename T >
void Array2D< T >::insertCol ( Array2D< T > & insarr,
int iy )
inline

Insert a 2d-array insarr into a column position iy.

◆ insertRow() [1/2]

template<typename T >
void Array2D< T >::insertRow ( Array1D< T > & insarr,
int ix )
inline

Insert array insarr as a row into position ix.

◆ insertRow() [2/2]

template<typename T >
void Array2D< T >::insertRow ( Array2D< T > & insarr,
int ix )
inline

Insert a 2d-array insarr into a row position ix.

◆ operator()() [1/2]

template<typename T >
T & Array2D< T >::operator() ( int ix,
int iy )
inline

C-like () operator to access values in the 2D data array.

◆ operator()() [2/2]

template<typename T >
const T & Array2D< T >::operator() ( int ix,
int iy ) const
inline

◆ operator[]()

template<typename T >
Array1D< T > & Array2D< T >::operator[] ( int ix)
inline

◆ ReadBinary() [1/2]

template<typename T >
void Array2D< T >::ReadBinary ( char * filename)
inline

◆ ReadBinary() [2/2]

template<typename T >
void Array2D< T >::ReadBinary ( FILE * f_in)
inline

Read contents of the array from a file in binary format.

◆ ReadBinary4py()

template<typename T >
void Array2D< T >::ReadBinary4py ( char * filename,
int n1,
int n2 )
inline

◆ Resize() [1/2]

template<typename T >
void Array2D< T >::Resize ( const int & nx,
const int & ny )
inline

Resizes the array.

Warning
In its current implementation, most of the original data

◆ Resize() [2/2]

template<typename T >
void Array2D< T >::Resize ( const int & nx,
const int & ny,
const T & t )
inline

Resizes the array and sets ALL entries to the specified value.

Warning
All original data will get lost if this function is used!

◆ setArray()

template<typename T >
void Array2D< T >::setArray ( vector< T > inarray)
inline

◆ setnpdblArray()

template<typename T >
void Array2D< T >::setnpdblArray ( double * inarray,
int n1,
int n2 )
inline

◆ setnpintArray()

template<typename T >
void Array2D< T >::setnpintArray ( long * inarray,
int n1,
int n2 )
inline

◆ SetValue()

template<typename T >
void Array2D< T >::SetValue ( const T & t)
inline

Set all values in the array to the given value.

◆ shape()

template<typename T >
vector< int > Array2D< T >::shape ( )
inline

◆ type()

template<typename T >
string Array2D< T >::type ( )
inline

◆ XSize()

template<typename T >
int Array2D< T >::XSize ( ) const
inline

Returns size in the x-direction.

◆ YSize()

template<typename T >
int Array2D< T >::YSize ( ) const
inline

Returns size in the y-direction.

Member Data Documentation

◆ arraycopy

template<typename T >
Array1D<T> Array2D< T >::arraycopy

◆ data_

template<typename T >
vector<T> Array2D< T >::data_

◆ rowvec

template<typename T >
Array1D<T> Array2D< T >::rowvec

◆ xsize_

template<typename T >
int Array2D< T >::xsize_

◆ ysize_

template<typename T >
int Array2D< T >::ysize_

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