Memosa-FVM  0.2
Array2D< T > Class Template Reference

#include <Array2D.h>

Inheritance diagram for Array2D< T >:
Collaboration diagram for Array2D< T >:

Public Member Functions

 Array2D (const int row_size, const int col_size)
 
 ~Array2D ()
 
int getRow () const
 
int getCol () const
 
T & operator() (const int i, const int j)
 
const T & operator() (const int i, const int j) const
 
void operator= (const T &x)
 
void partialCopyFrom (const Array2D &aij)
 
void partialCopyTo (Array2D &aij)
 
void zeros ()
 
void setIdentity ()
 
void * getData ()
 
int getDataSize () const
 
void print (ostream &os) const
 

Private Member Functions

 Array2D (const Array2D &)
 
void init ()
 

Private Attributes

Array2D_self
 
int _rowSize
 
int _colSize
 
int _length
 
T * _data
 

Detailed Description

template<class T>
class Array2D< T >

Definition at line 14 of file Array2D.h.

Constructor & Destructor Documentation

template<class T>
Array2D< T >::Array2D ( const int  row_size,
const int  col_size 
)
inlineexplicit

Definition at line 20 of file Array2D.h.

20  :
21  _self(*this),
22  _rowSize(row_size),
23  _colSize(col_size),
24  _length(row_size*col_size),
25  _data(new T[_length])
26  {
27  init();
28  }
int _colSize
Definition: Array2D.h:126
int _rowSize
Definition: Array2D.h:125
void init()
Definition: Array2D.h:117
Array2D & _self
Definition: Array2D.h:123
T * _data
Definition: Array2D.h:128
int _length
Definition: Array2D.h:127
template<class T>
Array2D< T >::~Array2D ( )
inline

Definition at line 31 of file Array2D.h.

32  {
33  delete [] _data;
34  }
T * _data
Definition: Array2D.h:128
template<class T>
Array2D< T >::Array2D ( const Array2D< T > &  )
private

Member Function Documentation

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

Definition at line 38 of file Array2D.h.

Referenced by Array2D< Diag >::partialCopyFrom(), and Array2D< Diag >::partialCopyTo().

38 { return _colSize; }
int _colSize
Definition: Array2D.h:126
template<class T>
void* Array2D< T >::getData ( )
inline

Definition at line 97 of file Array2D.h.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::exchangeSpikeMtrx().

97 { return _data;}
T * _data
Definition: Array2D.h:128
template<class T>
int Array2D< T >::getDataSize ( ) const
inline

Definition at line 98 of file Array2D.h.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::exchangeSpikeMtrx().

99  {
101  }
int _length
Definition: Array2D.h:127
template<class T>
int Array2D< T >::getRow ( ) const
inline
template<class T>
void Array2D< T >::init ( )
inlineprivate

Definition at line 117 of file Array2D.h.

Referenced by Array2D< Diag >::Array2D().

118  {
119  for ( int i = 0; i < _length; i++ )
120  _data[i] = NumTypeTraits<T>::getZero();//NumTypeTraits<T>::getNegativeUnity();
121  }
T * _data
Definition: Array2D.h:128
int _length
Definition: Array2D.h:127
template<class T>
T& Array2D< T >::operator() ( const int  i,
const int  j 
)
inline

returns the index of the j'th non zero column for row i

Definition at line 46 of file Array2D.h.

Referenced by Array2D< Diag >::print().

47  {
48  return _data[i*_colSize+j];
49  }
int _colSize
Definition: Array2D.h:126
T * _data
Definition: Array2D.h:128
template<class T>
const T& Array2D< T >::operator() ( const int  i,
const int  j 
) const
inline

Definition at line 51 of file Array2D.h.

52  {
53  return _data[i*_colSize+j];
54  }
int _colSize
Definition: Array2D.h:126
T * _data
Definition: Array2D.h:128
template<class T>
void Array2D< T >::operator= ( const T &  x)
inline

Definition at line 55 of file Array2D.h.

55  {
56  for ( int i = 0; i < _length; i++ )
57  _data[i] = x;
58  }
T * _data
Definition: Array2D.h:128
int _length
Definition: Array2D.h:127
template<class T>
void Array2D< T >::partialCopyFrom ( const Array2D< T > &  aij)
inline

Definition at line 60 of file Array2D.h.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLSpikeMtrx(), and SpikeMatrix< T_Diag, T_OffDiag, X >::setRSpikeMtrxFull().

60  {
61  const int nrow = aij.getRow();
62  const int ncol = aij.getCol();
63  for ( int i = 0; i < nrow; i++ ){
64  for ( int j = 0; j < ncol; j++){
65  _self(i,j) = aij(i,j);
66  }
67  }
68  }
int getRow() const
Definition: Array2D.h:37
Array2D & _self
Definition: Array2D.h:123
int getCol() const
Definition: Array2D.h:38
template<class T>
void Array2D< T >::partialCopyTo ( Array2D< T > &  aij)
inline

Definition at line 70 of file Array2D.h.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setLSpikeMtrx(), and SpikeMatrix< T_Diag, T_OffDiag, X >::setRSpikeMtrxFull().

70  {
71  const int nrow = aij.getRow();
72  const int ncol = aij.getCol();
73  for ( int i = 0; i < nrow; i++ ){
74  for ( int j = 0; j < ncol; j++){
75  aij(i,j) = _self(i,j);
76  }
77  }
78  }
int getRow() const
Definition: Array2D.h:37
Array2D & _self
Definition: Array2D.h:123
int getCol() const
Definition: Array2D.h:38
template<class T>
void Array2D< T >::print ( ostream &  os) const
inline

Definition at line 104 of file Array2D.h.

105  {
106  for ( int i = 0; i < _rowSize; i++){
107  for ( int j = 0; j < _colSize; j++ ){
108  os << std::setprecision(14) << this->operator()(i,j) << " ";
109  }
110  os << "\n";
111  }
112  os << endl;
113  }
int _colSize
Definition: Array2D.h:126
int _rowSize
Definition: Array2D.h:125
T & operator()(const int i, const int j)
Definition: Array2D.h:46
template<class T>
void Array2D< T >::setIdentity ( )
inline

Definition at line 85 of file Array2D.h.

Referenced by SpikeMatrix< T_Diag, T_OffDiag, X >::setReducedMtrx().

86  {
87  for ( int i = 0; i < _rowSize; i++ ){
88  for ( int j = 0; j < _colSize; j++){
89  if ( i == j )
91 
92  }
93  }
94  }
int _colSize
Definition: Array2D.h:126
int _rowSize
Definition: Array2D.h:125
Array2D & _self
Definition: Array2D.h:123
template<class T>
void Array2D< T >::zeros ( )
inline

Member Data Documentation

template<class T>
int Array2D< T >::_colSize
private
template<class T>
int Array2D< T >::_length
private
template<class T>
int Array2D< T >::_rowSize
private
template<class T>
Array2D& Array2D< T >::_self
private

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