tesseract v5.3.3.20231005
tesseract::TransposedArray Class Reference

#include <weightmatrix.h>

Inheritance diagram for tesseract::TransposedArray:
tesseract::GENERIC_2D_ARRAY< TFloat >

Public Member Functions

void Transpose (const GENERIC_2D_ARRAY< TFloat > &input)
 
 ~TransposedArray () override
 
void WriteStrided (int t, const float *data)
 
void WriteStrided (int t, const double *data)
 
void PrintUnTransposed (int num)
 
- Public Member Functions inherited from tesseract::GENERIC_2D_ARRAY< TFloat >
 GENERIC_2D_ARRAY (int dim1, int dim2, const TFloat &empty, TFloat *array)
 
 GENERIC_2D_ARRAY (int dim1, int dim2, const TFloat &empty)
 
 GENERIC_2D_ARRAY ()
 
 GENERIC_2D_ARRAY (const GENERIC_2D_ARRAY< TFloat > &src)
 
virtual ~GENERIC_2D_ARRAY ()
 
void operator= (const GENERIC_2D_ARRAY< TFloat > &src)
 
void ResizeNoInit (int size1, int size2, int pad=0)
 
void Resize (int size1, int size2, const TFloat &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 TFloat &thing)
 
void put (int column, int row, const TFloat &thing)
 
TFloat get (ICOORD pos) const
 
TFloat get (int column, int row) const
 
const TFloatoperator() (int column, int row) const
 
TFloatoperator() (int column, int row)
 
TFloatoperator[] (int column)
 
const TFloatoperator[] (int column) const
 
void operator+= (const GENERIC_2D_ARRAY< TFloat > &addend)
 
void operator+= (const TFloat &addend)
 
void operator-= (const GENERIC_2D_ARRAY< TFloat > &minuend)
 
void operator*= (const TFloat &factor)
 
void Clip (const TFloat &rangemin, const TFloat &rangemax)
 
bool WithinBounds (const TFloat &rangemin, const TFloat &rangemax) const
 
double Normalize ()
 
TFloat Max () const
 
TFloat MaxAbs () const
 
void SumSquares (const GENERIC_2D_ARRAY< TFloat > &src, const TFloat &decay_factor)
 
void AdamUpdate (const GENERIC_2D_ARRAY< TFloat > &sum, const GENERIC_2D_ARRAY< TFloat > &sqsum, const TFloat &epsilon)
 
void AssertFinite () const
 
void RotatingTranspose (const int *dims, int num_dims, int src_dim, int dest_dim, GENERIC_2D_ARRAY< TFloat > *result) const
 
void delete_matrix_pointers ()
 

Additional Inherited Members

- Protected Member Functions inherited from tesseract::GENERIC_2D_ARRAY< TFloat >
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< TFloat >
TFloatarray_
 
TFloat empty_
 
int dim1_
 
int dim2_
 
int size_allocated_
 

Detailed Description

Definition at line 33 of file weightmatrix.h.

Constructor & Destructor Documentation

◆ ~TransposedArray()

tesseract::TransposedArray::~TransposedArray ( )
overridedefault

Member Function Documentation

◆ PrintUnTransposed()

void tesseract::TransposedArray::PrintUnTransposed ( int  num)
inline

Definition at line 53 of file weightmatrix.h.

53 {
54 int num_features = dim1();
55 int width = dim2();
56 for (int y = 0; y < num_features; ++y) {
57 for (int t = 0; t < width; ++t) {
58 if (num == 0 || t < num || t + num >= width) {
59 tprintf(" %g", static_cast<double>((*this)(y, t)));
60 }
61 }
62 tprintf("\n");
63 }
64 }
const double y
void tprintf(const char *format,...)
Definition: tprintf.cpp:41

◆ Transpose()

void tesseract::TransposedArray::Transpose ( const GENERIC_2D_ARRAY< TFloat > &  input)

Definition at line 114 of file weightmatrix.cpp.

114 {
115 int width = input.dim1();
116 int num_features = input.dim2();
117 ResizeNoInit(num_features, width);
118 for (int t = 0; t < width; ++t) {
119 WriteStrided(t, input[t]);
120 }
121}
void ResizeNoInit(int size1, int size2, int pad=0)
Definition: matrix.h:94
void WriteStrided(int t, const float *data)
Definition: weightmatrix.h:40

◆ WriteStrided() [1/2]

void tesseract::TransposedArray::WriteStrided ( int  t,
const double *  data 
)
inline

Definition at line 46 of file weightmatrix.h.

46 {
47 int size1 = dim1();
48 for (int i = 0; i < size1; ++i) {
49 put(i, t, data[i]);
50 }
51 }
void put(ICOORD pos, const TFloat &thing)
Definition: matrix.h:260

◆ WriteStrided() [2/2]

void tesseract::TransposedArray::WriteStrided ( int  t,
const float *  data 
)
inline

Definition at line 40 of file weightmatrix.h.

40 {
41 int size1 = dim1();
42 for (int i = 0; i < size1; ++i) {
43 put(i, t, data[i]);
44 }
45 }

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