tesseract  4.00.00dev
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)
 
 GENERIC_2D_ARRAY ()
 
 GENERIC_2D_ARRAY (const GENERIC_2D_ARRAY< T > &src)
 
virtual ~GENERIC_2D_ARRAY ()
 
void operator= (const GENERIC_2D_ARRAY< T > &src)
 
void ResizeNoInit (int size1, int size2)
 
void Resize (int size1, int size2, const T &empty)
 
void ResizeWithCopy (int size1, int size2)
 
void Clear ()
 
bool Serialize (FILE *fp) const
 
bool Serialize (tesseract::TFile *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 
bool DeSerialize (tesseract::TFile *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 (ICOORD pos, const T &thing)
 
void put (int column, int row, const T &thing)
 
get (ICOORD pos) const
 
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 operator+= (const GENERIC_2D_ARRAY< T > &addend)
 
void operator-= (const GENERIC_2D_ARRAY< T > &minuend)
 
void operator+= (const T &addend)
 
void operator*= (const T &factor)
 
void Clip (const T &rangemin, const T &rangemax)
 
bool WithinBounds (const T &rangemin, const T &rangemax) const
 
double Normalize ()
 
Max () const
 
MaxAbs () const
 
void SumSquares (const GENERIC_2D_ARRAY< T > &src)
 
void AdaGradScaling (const GENERIC_2D_ARRAY< T > &sqsum, int num_samples)
 
void AssertFinite () const
 
void RotatingTranspose (const int *dims, int num_dims, int src_dim, int dest_dim, GENERIC_2D_ARRAY< T > *result) const
 
void delete_matrix_pointers ()
 

Additional Inherited Members

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

Detailed Description

template<class T>
class BandTriMatrix< T >

Definition at line 509 of file matrix.h.

Constructor & Destructor Documentation

◆ BandTriMatrix()

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

Definition at line 514 of file matrix.h.

515  : GENERIC_2D_ARRAY<T>(dim1, dim2, empty) {
516  }
int dim1() const
Definition: matrix.h:201
int dim2() const
Definition: matrix.h:202

Member Function Documentation

◆ AttachOnCorner()

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

Definition at line 538 of file matrix.h.

538  {
539  int new_dim1 = this->dim1_ + array2->dim1_;
540  int new_dim2 = MAX(this->dim2_, array2->dim2_);
541  T* new_array = new T[new_dim1 * new_dim2];
542  for (int col = 0; col < new_dim1; ++col) {
543  for (int j = 0; j < new_dim2; ++j) {
544  int new_index = col * new_dim2 + j;
545  if (col < this->dim1_ && j < this->dim2_) {
546  new_array[new_index] = this->get(col, col + j);
547  } else if (col >= this->dim1_ && j < array2->dim2_) {
548  new_array[new_index] = array2->get(col - this->dim1_,
549  col - this->dim1_ + j);
550  array2->put(col - this->dim1_, col - this->dim1_ + j, NULL);
551  } else {
552  new_array[new_index] = this->empty_;
553  }
554  }
555  }
556  delete[] this->array_;
557  this->array_ = new_array;
558  this->dim1_ = new_dim1;
559  this->dim2_ = new_dim2;
560  }
T get(ICOORD pos) const
Definition: matrix.h:223
#define MAX(x, y)
Definition: ndminx.h:24
void put(ICOORD pos, const T &thing)
Definition: matrix.h:215

◆ bandwidth()

template<class T>
int BandTriMatrix< T >::bandwidth ( ) const
inline

Definition at line 523 of file matrix.h.

523 { return this->dim2_; }

◆ dimension()

template<class T>
int BandTriMatrix< T >::dimension ( ) const
inline

Definition at line 521 of file matrix.h.

521 { return this->dim1_; }

◆ index()

template<class T>
virtual int BandTriMatrix< T >::index ( int  column,
int  row 
) const
inlinevirtual

Reimplemented from GENERIC_2D_ARRAY< T >.

Definition at line 528 of file matrix.h.

528  {
529  ASSERT_HOST(row >= column);
530  ASSERT_HOST(row - column < this->dim2_);
531  return column * this->dim2_ + row - column;
532  }
#define ASSERT_HOST(x)
Definition: errcode.h:84

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