tesseract v5.3.3.20231005
tesseract::BandTriMatrix< T > Class Template Reference

#include <matrix.h>

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

Public Member Functions

 BandTriMatrix (int dim1, int dim2, const T &empty)
 
int dimension () const
 
int bandwidth () const
 
int index (int column, int row) const override
 
void AttachOnCorner (BandTriMatrix< T > *array2)
 
- Public Member Functions inherited from tesseract::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, int pad=0)
 
void Resize (int size1, int size2, const T &empty)
 
void ResizeWithCopy (int size1, int size2)
 
void Clear ()
 
bool Serialize (FILE *fp) const
 
bool Serialize (TFile *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 
bool DeSerialize (TFile *fp)
 
bool SerializeClasses (FILE *fp) const
 
bool DeSerializeClasses (bool swap, FILE *fp)
 
int dim1 () const
 
int dim2 () const
 
virtual int num_elements () const
 
virtual int index (int column, int row) 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, const T &decay_factor)
 
void AdamUpdate (const GENERIC_2D_ARRAY< T > &sum, const GENERIC_2D_ARRAY< T > &sqsum, const T &epsilon)
 
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 tesseract::GENERIC_2D_ARRAY< T >
bool SerializeSize (FILE *fp) const
 
bool SerializeSize (TFile *fp) const
 
bool DeSerializeSize (bool swap, FILE *fp)
 
bool DeSerializeSize (TFile *fp)
 
- Protected Attributes inherited from tesseract::GENERIC_2D_ARRAY< T >
T * array_
 
empty_
 
int dim1_
 
int dim2_
 
int size_allocated_
 

Detailed Description

template<class T>
class tesseract::BandTriMatrix< T >

Definition at line 602 of file matrix.h.

Constructor & Destructor Documentation

◆ BandTriMatrix()

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

Definition at line 607 of file matrix.h.

607: GENERIC_2D_ARRAY<T>(dim1, dim2, empty) {}

Member Function Documentation

◆ AttachOnCorner()

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

Definition at line 633 of file matrix.h.

633 {
634 int new_dim1 = this->dim1_ + array2->dim1_;
635 int new_dim2 = std::max(this->dim2_, array2->dim2_);
636 T *new_array = new T[new_dim1 * new_dim2];
637 for (int col = 0; col < new_dim1; ++col) {
638 for (int j = 0; j < new_dim2; ++j) {
639 int new_index = col * new_dim2 + j;
640 if (col < this->dim1_ && j < this->dim2_) {
641 new_array[new_index] = this->get(col, col + j);
642 } else if (col >= this->dim1_ && j < array2->dim2_) {
643 new_array[new_index] = array2->get(col - this->dim1_, col - this->dim1_ + j);
644 array2->put(col - this->dim1_, col - this->dim1_ + j, nullptr);
645 } else {
646 new_array[new_index] = this->empty_;
647 }
648 }
649 }
650 delete[] this->array_;
651 this->array_ = new_array;
652 this->dim1_ = new_dim1;
653 this->dim2_ = new_dim2;
654 }
T get(ICOORD pos) const
Definition: matrix.h:268

◆ bandwidth()

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

Definition at line 616 of file matrix.h.

616 {
617 return this->dim2_;
618 }

◆ dimension()

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

Definition at line 612 of file matrix.h.

612 {
613 return this->dim1_;
614 }

◆ index()

template<class T >
int tesseract::BandTriMatrix< T >::index ( int  column,
int  row 
) const
inlineoverridevirtual

Reimplemented from tesseract::GENERIC_2D_ARRAY< T >.

Definition at line 623 of file matrix.h.

623 {
624 ASSERT_HOST(row >= column);
625 ASSERT_HOST(row - column < this->dim2_);
626 return column * this->dim2_ + row - column;
627 }
#define ASSERT_HOST(x)
Definition: errcode.h:54

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