All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BandTriMatrix< T > Class Template Reference

#include <matrix.h>

Inheritance diagram for BandTriMatrix< T >:
GENERIC_2D_ARRAY< T >

Public Member Functions

 BandTriMatrix (int dim1, int dim2, const T &empty)
 
int dimension () const
 
int bandwidth () const
 
virtual int index (int column, int row) const
 
void AttachOnCorner (BandTriMatrix< T > *array2)
 
- Public Member Functions inherited from GENERIC_2D_ARRAY< T >
 GENERIC_2D_ARRAY (int dim1, int dim2, const T &empty, T *array)
 
 GENERIC_2D_ARRAY (int dim1, int dim2, const T &empty)
 
virtual ~GENERIC_2D_ARRAY ()
 
void Resize (int size1, int size2, const T &empty)
 
void ResizeWithCopy (int size1, int size2)
 
void Clear ()
 
bool Serialize (FILE *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 
bool SerializeClasses (FILE *fp) const
 
bool DeSerializeClasses (bool swap, FILE *fp)
 
int dim1 () const
 
int dim2 () const
 
virtual int num_elements () const
 
void put (int column, int row, const T &thing)
 
get (int column, int row) const
 
const T & operator() (int column, int row) const
 
T & operator() (int column, int row)
 
T * operator[] (int column)
 
const T * operator[] (int column) const
 
void delete_matrix_pointers ()
 

Additional Inherited Members

- Protected Member Functions inherited from GENERIC_2D_ARRAY< T >
bool SerializeSize (FILE *fp) const
 
bool DeSerializeSize (bool swap, FILE *fp)
 
- Protected Attributes inherited from GENERIC_2D_ARRAY< T >
T * array_
 
empty_
 
int dim1_
 
int dim2_
 

Detailed Description

template<class T>
class BandTriMatrix< T >

Definition at line 235 of file matrix.h.

Constructor & Destructor Documentation

template<class T>
BandTriMatrix< T >::BandTriMatrix ( int  dim1,
int  dim2,
const T &  empty 
)
inline

Definition at line 240 of file matrix.h.

241  : GENERIC_2D_ARRAY<T>(dim1, dim2, empty) {
242  }
int dim2() const
Definition: matrix.h:153
int dim1() const
Definition: matrix.h:152

Member Function Documentation

template<class T>
void BandTriMatrix< T >::AttachOnCorner ( BandTriMatrix< T > *  array2)
inline

Definition at line 264 of file matrix.h.

264  {
265  int new_dim1 = this->dim1_ + array2->dim1_;
266  int new_dim2 = MAX(this->dim2_, array2->dim2_);
267  T* new_array = new T[new_dim1 * new_dim2];
268  for (int col = 0; col < new_dim1; ++col) {
269  for (int j = 0; j < new_dim2; ++j) {
270  int new_index = col * new_dim2 + j;
271  if (col < this->dim1_ && j < this->dim2_) {
272  new_array[new_index] = this->get(col, col + j);
273  } else if (col >= this->dim1_ && j < array2->dim2_) {
274  new_array[new_index] = array2->get(col - this->dim1_,
275  col - this->dim1_ + j);
276  array2->put(col - this->dim1_, col - this->dim1_ + j, NULL);
277  } else {
278  new_array[new_index] = this->empty_;
279  }
280  }
281  }
282  delete[] this->array_;
283  this->array_ = new_array;
284  this->dim1_ = new_dim1;
285  this->dim2_ = new_dim2;
286  }
#define MAX(x, y)
Definition: ndminx.h:24
T get(int column, int row) const
Definition: matrix.h:171
void put(int column, int row, const T &thing)
Definition: matrix.h:166
#define NULL
Definition: host.h:144
template<class T>
int BandTriMatrix< T >::bandwidth ( ) const
inline

Definition at line 249 of file matrix.h.

249 { return this->dim2_; }
template<class T>
int BandTriMatrix< T >::dimension ( ) const
inline

Definition at line 247 of file matrix.h.

247 { return this->dim1_; }
template<class T>
virtual int BandTriMatrix< T >::index ( int  column,
int  row 
) const
inlinevirtual

Reimplemented from GENERIC_2D_ARRAY< T >.

Definition at line 254 of file matrix.h.

254  {
255  ASSERT_HOST(row >= column);
256  ASSERT_HOST(row - column < this->dim2_);
257  return column * this->dim2_ + row - column;
258  }
#define ASSERT_HOST(x)
Definition: errcode.h:84

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