MFEM  v4.6.0
Finite element discretization library
Public Member Functions | Friends | List of all members
mfem::Array2D< T > Class Template Reference

Dynamic 2D array using row-major layout. More...

#include <array.hpp>

Public Member Functions

 Array2D ()
 
 Array2D (int m, int n)
 
 Array2D (const Array2D &)=default
 
void SetSize (int m, int n)
 
int NumRows () const
 
int NumCols () const
 
const T & operator() (int i, int j) const
 
T & operator() (int i, int j)
 
const T * operator[] (int i) const
 
T * operator[] (int i)
 
const T * operator() (int i) const
 
T * operator() (int i)
 
const T * GetRow (int i) const
 
T * GetRow (int i)
 
void GetRow (int i, Array< T > &sa) const
 Extract a copy of the i-th row into the Array sa. More...
 
void Save (std::ostream &os, int fmt=0) const
 Save the Array2D to the stream out using the format fmt. The format fmt can be: More...
 
void Load (std::istream &in, int fmt=0)
 Read an Array2D from the stream in using format fmt. The format fmt can be: More...
 
void Load (const char *filename, int fmt=0)
 Read an Array2D from a file. More...
 
void Load (int new_size0, int new_size1, std::istream &in)
 Set the Array2D dimensions to new_size0 x new_size1 and read that many entries from the stream in. More...
 
void Copy (Array2D &copy) const
 
void operator= (const T &a)
 
Array2Doperator= (const Array2D &a)=default
 
void MakeRef (const Array2D &master)
 Make this Array a reference to 'master'. More...
 
void DeleteAll ()
 Delete all dynamically allocated memory, resetting all dimensions to zero. More...
 
void Print (std::ostream &out=mfem::out, int width=4)
 Prints array to stream with width elements per row. More...
 

Friends

void Swap (Array2D< T > &, Array2D< T > &)
 

Detailed Description

template<class T>
class mfem::Array2D< T >

Dynamic 2D array using row-major layout.

Definition at line 354 of file array.hpp.

Constructor & Destructor Documentation

◆ Array2D() [1/3]

template<class T>
mfem::Array2D< T >::Array2D ( )
inline

Definition at line 370 of file array.hpp.

◆ Array2D() [2/3]

template<class T>
mfem::Array2D< T >::Array2D ( int  m,
int  n 
)
inline

Definition at line 371 of file array.hpp.

◆ Array2D() [3/3]

template<class T>
mfem::Array2D< T >::Array2D ( const Array2D< T > &  )
default

Member Function Documentation

◆ Copy()

template<class T>
void mfem::Array2D< T >::Copy ( Array2D< T > &  copy) const
inline

Definition at line 431 of file array.hpp.

◆ DeleteAll()

template<class T>
void mfem::Array2D< T >::DeleteAll ( )
inline

Delete all dynamically allocated memory, resetting all dimensions to zero.

Definition at line 444 of file array.hpp.

◆ GetRow() [1/3]

template<class T>
const T* mfem::Array2D< T >::GetRow ( int  i) const
inline

Definition at line 389 of file array.hpp.

◆ GetRow() [2/3]

template<class T>
T* mfem::Array2D< T >::GetRow ( int  i)
inline

Definition at line 390 of file array.hpp.

◆ GetRow() [3/3]

template<class T>
void mfem::Array2D< T >::GetRow ( int  i,
Array< T > &  sa 
) const
inline

Extract a copy of the i-th row into the Array sa.

Definition at line 393 of file array.hpp.

◆ Load() [1/3]

template<class T>
void mfem::Array2D< T >::Load ( std::istream &  in,
int  fmt = 0 
)
inline

Read an Array2D from the stream in using format fmt. The format fmt can be:

0 - read the number of rows and columns, then the entries 1 - read NumRows() x NumCols() entries, using row-major layout

Definition at line 417 of file array.hpp.

◆ Load() [2/3]

template<class T >
void mfem::Array2D< T >::Load ( const char *  filename,
int  fmt = 0 
)

Read an Array2D from a file.

Definition at line 145 of file array.cpp.

◆ Load() [3/3]

template<class T>
void mfem::Array2D< T >::Load ( int  new_size0,
int  new_size1,
std::istream &  in 
)
inline

Set the Array2D dimensions to new_size0 x new_size1 and read that many entries from the stream in.

Definition at line 428 of file array.hpp.

◆ MakeRef()

template<class T>
void mfem::Array2D< T >::MakeRef ( const Array2D< T > &  master)
inline

Make this Array a reference to 'master'.

Definition at line 440 of file array.hpp.

◆ NumCols()

template<class T>
int mfem::Array2D< T >::NumCols ( ) const
inline

Definition at line 378 of file array.hpp.

◆ NumRows()

template<class T>
int mfem::Array2D< T >::NumRows ( ) const
inline

Definition at line 377 of file array.hpp.

◆ operator()() [1/4]

template<class T >
const T & mfem::Array2D< T >::operator() ( int  i,
int  j 
) const
inline

Definition at line 914 of file array.hpp.

◆ operator()() [2/4]

template<class T >
T & mfem::Array2D< T >::operator() ( int  i,
int  j 
)
inline

Definition at line 924 of file array.hpp.

◆ operator()() [3/4]

template<class T>
const T* mfem::Array2D< T >::operator() ( int  i) const
inline

Definition at line 386 of file array.hpp.

◆ operator()() [4/4]

template<class T>
T* mfem::Array2D< T >::operator() ( int  i)
inline

Definition at line 387 of file array.hpp.

◆ operator=() [1/2]

template<class T>
void mfem::Array2D< T >::operator= ( const T &  a)
inline

Definition at line 434 of file array.hpp.

◆ operator=() [2/2]

template<class T>
Array2D& mfem::Array2D< T >::operator= ( const Array2D< T > &  a)
inlinedefault

◆ operator[]() [1/2]

template<class T >
const T * mfem::Array2D< T >::operator[] ( int  i) const
inline

Definition at line 934 of file array.hpp.

◆ operator[]() [2/2]

template<class T >
T * mfem::Array2D< T >::operator[] ( int  i)
inline

Definition at line 943 of file array.hpp.

◆ Print()

template<class T >
void mfem::Array2D< T >::Print ( std::ostream &  out = mfem::out,
int  width = 4 
)

Prints array to stream with width elements per row.

Definition at line 155 of file array.cpp.

◆ Save()

template<class T>
void mfem::Array2D< T >::Save ( std::ostream &  os,
int  fmt = 0 
) const
inline

Save the Array2D to the stream out using the format fmt. The format fmt can be:

0 - write the number of rows and columns, followed by all entries 1 - write only the entries, using row-major layout

Definition at line 405 of file array.hpp.

◆ SetSize()

template<class T>
void mfem::Array2D< T >::SetSize ( int  m,
int  n 
)
inline

Definition at line 375 of file array.hpp.

Friends And Related Function Documentation

◆ Swap

template<class T>
void Swap ( Array2D< T > &  a,
Array2D< T > &  b 
)
friend

Definition at line 953 of file array.hpp.


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