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

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

#include <Array1D.h>

Public Member Functions

 Array1D ()
 Default constructor, which does not allocate any memory.
 
 Array1D (const int &nx)
 Constructor that allocates the memory.
 
 Array1D (const int &nx, const T &t)
 Constructor that allocates and initializes the data to a value t.
 
Array1Doperator= (const Array1D &obj)
 Assignment operator copies the data structure by value.
 
 Array1D (const Array1D &obj)
 Copy constructor.
 
 ~Array1D ()
 Destructor that frees up the memory.
 
void Clear ()
 Function to clear the memory.
 
int XSize () const
 Returns size in the x-direction.
 
int Length () const
 Returns length (i.e. size in the x-direction)
 
void Resize (const int &nx)
 Resizes the array.
 
void Resize (const int &nx, 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.
 
void PushBack (const T &t)
 Add element to the end of the vector.
 
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 const 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)
 
const T & operator() (int ix) const
 
void insert (Array1D< T > &insarr, int ix)
 Insert a given array to the position ix.
 
void insert (const T &insval, int ix)
 Insert a given value to the position ix.
 
void erase (int ix)
 Erase the value from the position ix.
 
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.
 
T & operator[] (int i)
 
vector< int > shape ()
 
void assign (const int x, const T val)
 
void DumpBinary (char *filename)
 Dump contents of the array to a file in binary format.
 
void ReadBinary (char *filename)
 
void DumpBinary4py (char *filename)
 
void ReadBinary4py (char *filename, int n)
 
void setArray (vector< T > inarray)
 
vector< T > flatten ()
 
string type ()
 

Public Attributes

int xsize_
 
vector< T > data_
 

Detailed Description

template<typename T>
class Array1D< T >

Stores data of any type T in a 1D 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
Apr 2005 - Nov 2007
Note
Inspired by Helgi Adalsteinsson's Array class implementation
Todo
double check copy constructor

Constructor & Destructor Documentation

◆ Array1D() [1/4]

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

Default constructor, which does not allocate any memory.

◆ Array1D() [2/4]

template<typename T >
Array1D< T >::Array1D ( const int & nx)
inline

Constructor that allocates the memory.

◆ Array1D() [3/4]

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

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

◆ Array1D() [4/4]

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

Copy constructor.

◆ ~Array1D()

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

Destructor that frees up the memory.

Member Function Documentation

◆ assign()

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

◆ Clear()

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

Function to clear the memory.

◆ DumpBinary() [1/2]

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

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

◆ DumpBinary() [2/2]

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

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

◆ DumpBinary4py()

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

◆ erase()

template<typename T >
void Array1D< T >::erase ( int ix)
inline

Erase the value from the position ix.

◆ flatten()

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

◆ GetArrayPointer()

template<typename T >
T * Array1D< 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 * Array1D< T >::GetConstArrayPointer ( ) const
inline

Return a const 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).

◆ insert() [1/2]

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

Insert a given array to the position ix.

Note
ix=0 means insert at the beginning, ix=xsize_ means insert at the end

◆ insert() [2/2]

template<typename T >
void Array1D< T >::insert ( const T & insval,
int ix )
inline

Insert a given value to the position ix.

Note
ix=0 means insert at the beginning, ix=xsize_ means insert at the end

◆ Length()

template<typename T >
int Array1D< T >::Length ( ) const
inline

Returns length (i.e. size in the x-direction)

◆ operator()() [1/2]

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

◆ operator()() [2/2]

template<typename T >
const T & Array1D< T >::operator() ( int ix) const
inline

◆ operator=()

template<typename T >
Array1D & Array1D< T >::operator= ( const Array1D< T > & obj)
inline

Assignment operator copies the data structure by value.

◆ operator[]()

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

◆ PushBack()

template<typename T >
void Array1D< T >::PushBack ( const T & t)
inline

Add element to the end of the vector.

◆ ReadBinary() [1/2]

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

◆ ReadBinary() [2/2]

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

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

◆ ReadBinary4py()

template<typename T >
void Array1D< T >::ReadBinary4py ( char * filename,
int n )
inline

◆ Resize() [1/2]

template<typename T >
void Array1D< T >::Resize ( const int & nx)
inline

Resizes the array.

◆ Resize() [2/2]

template<typename T >
void Array1D< T >::Resize ( const int & nx,
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 Array1D< T >::setArray ( vector< T > inarray)
inline

◆ SetValue()

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

Set all values in the array to the given value.

◆ shape()

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

◆ type()

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

◆ XSize()

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

Returns size in the x-direction.

Member Data Documentation

◆ data_

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

◆ xsize_

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

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