tesseract  4.1.1
GENERIC_2D_ARRAY< T > Class Template Reference

#include <matrix.h>

Inheritance diagram for GENERIC_2D_ARRAY< T >:
BandTriMatrix< BLOB_CHOICE_LIST * > BandTriMatrix< T > MATRIX

Public Member Functions

 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 (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
 
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 ()
 

Protected Member Functions

bool SerializeSize (FILE *fp) const
 
bool SerializeSize (tesseract::TFile *fp) const
 
bool DeSerializeSize (bool swap, FILE *fp)
 
bool DeSerializeSize (tesseract::TFile *fp)
 

Protected Attributes

T * array_
 
empty_
 
int dim1_
 
int dim2_
 
int size_allocated_
 

Detailed Description

template<class T>
class GENERIC_2D_ARRAY< T >

Definition at line 50 of file matrix.h.

Constructor & Destructor Documentation

◆ GENERIC_2D_ARRAY() [1/4]

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

Definition at line 56 of file matrix.h.

57  : empty_(empty), dim1_(dim1), dim2_(dim2), array_(array) {
59  }
int dim2() const
Definition: matrix.h:210
int dim1() const
Definition: matrix.h:209
int size_allocated_
Definition: matrix.h:515

◆ GENERIC_2D_ARRAY() [2/4]

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

Definition at line 62 of file matrix.h.

63  : empty_(empty), dim1_(dim1), dim2_(dim2) {
64  int new_size = dim1 * dim2;
65  array_ = new T[new_size];
66  size_allocated_ = new_size;
67  for (int i = 0; i < size_allocated_; ++i)
68  array_[i] = empty_;
69  }

◆ GENERIC_2D_ARRAY() [3/4]

template<class T >
GENERIC_2D_ARRAY< T >::GENERIC_2D_ARRAY ( )
inline

Definition at line 71 of file matrix.h.

72  : array_(nullptr), empty_(static_cast<T>(0)), dim1_(0), dim2_(0),
73  size_allocated_(0) {
74  }

◆ GENERIC_2D_ARRAY() [4/4]

template<class T >
GENERIC_2D_ARRAY< T >::GENERIC_2D_ARRAY ( const GENERIC_2D_ARRAY< T > &  src)
inline

Definition at line 75 of file matrix.h.

76  : array_(nullptr), empty_(static_cast<T>(0)), dim1_(0), dim2_(0),
77  size_allocated_(0) {
78  *this = src;
79  }

◆ ~GENERIC_2D_ARRAY()

template<class T >
virtual GENERIC_2D_ARRAY< T >::~GENERIC_2D_ARRAY ( )
inlinevirtual

Definition at line 80 of file matrix.h.

80 { delete[] array_; }

Member Function Documentation

◆ AdamUpdate()

template<class T >
void GENERIC_2D_ARRAY< T >::AdamUpdate ( const GENERIC_2D_ARRAY< T > &  sum,
const GENERIC_2D_ARRAY< T > &  sqsum,
const T &  epsilon 
)
inline

Definition at line 382 of file matrix.h.

383  {
384  int size = num_elements();
385  for (int i = 0; i < size; ++i) {
386  array_[i] += sum.array_[i] / (sqrt(sqsum.array_[i]) + epsilon);
387  }
388  }
virtual int num_elements() const
Definition: matrix.h:213

◆ AssertFinite()

template<class T >
void GENERIC_2D_ARRAY< T >::AssertFinite ( ) const
inline

Definition at line 390 of file matrix.h.

390  {
391  int size = num_elements();
392  for (int i = 0; i < size; ++i) {
393  ASSERT_HOST(isfinite(array_[i]));
394  }
395  }
#define ASSERT_HOST(x)
Definition: errcode.h:88

◆ Clear()

template<class T >
void GENERIC_2D_ARRAY< T >::Clear ( )
inline

Definition at line 139 of file matrix.h.

139  {
140  int total_size = num_elements();
141  for (int i = 0; i < total_size; ++i)
142  array_[i] = empty_;
143  }

◆ Clip()

template<class T >
void GENERIC_2D_ARRAY< T >::Clip ( const T &  rangemin,
const T &  rangemax 
)
inline

Definition at line 300 of file matrix.h.

300  {
301  int size = num_elements();
302  for (int i = 0; i < size; ++i) {
303  array_[i] = ClipToRange(array_[i], rangemin, rangemax);
304  }
305  }
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:108

◆ delete_matrix_pointers()

template<class T >
void GENERIC_2D_ARRAY< T >::delete_matrix_pointers ( )
inline

Definition at line 458 of file matrix.h.

458  {
459  int size = num_elements();
460  for (int i = 0; i < size; ++i) {
461  T matrix_cell = array_[i];
462  if (matrix_cell != empty_)
463  delete matrix_cell;
464  }
465  }

◆ DeSerialize() [1/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::DeSerialize ( bool  swap,
FILE *  fp 
)
inline

Definition at line 164 of file matrix.h.

164  {
165  if (!DeSerializeSize(swap, fp)) return false;
166  if (!tesseract::DeSerialize(fp, &empty_)) return false;
167  if (swap) ReverseN(&empty_, sizeof(empty_));
168  int size = num_elements();
169  if (!tesseract::DeSerialize(fp, &array_[0], size)) return false;
170  if (swap) {
171  for (int i = 0; i < size; ++i)
172  ReverseN(&array_[i], sizeof(array_[i]));
173  }
174  return true;
175  }
void ReverseN(void *ptr, int num_bytes)
Definition: helpers.h:185
bool DeSerialize(FILE *fp, char *data, size_t n)
Definition: serialis.cpp:28
bool DeSerializeSize(bool swap, FILE *fp)
Definition: matrix.h:483

◆ DeSerialize() [2/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::DeSerialize ( tesseract::TFile fp)
inline

Definition at line 177 of file matrix.h.

177  {
178  return DeSerializeSize(fp) &&
179  fp->DeSerialize(&empty_) &&
180  fp->DeSerialize(&array_[0], num_elements());
181  }
bool DeSerialize(char *data, size_t count=1)
Definition: serialis.cpp:104

◆ DeSerializeClasses()

template<class T >
bool GENERIC_2D_ARRAY< T >::DeSerializeClasses ( bool  swap,
FILE *  fp 
)
inline

Definition at line 198 of file matrix.h.

198  {
199  if (!DeSerializeSize(swap, fp)) return false;
200  if (!empty_.DeSerialize(swap, fp)) return false;
201  int size = num_elements();
202  for (int i = 0; i < size; ++i) {
203  if (!array_[i].DeSerialize(swap, fp)) return false;
204  }
205  return true;
206  }
bool DeSerialize(bool swap, FILE *fp)
Definition: matrix.h:164

◆ DeSerializeSize() [1/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::DeSerializeSize ( bool  swap,
FILE *  fp 
)
inlineprotected

Definition at line 483 of file matrix.h.

483  {
484  uint32_t size1, size2;
485  if (!tesseract::DeSerialize(fp, &size1)) return false;
486  if (!tesseract::DeSerialize(fp, &size2)) return false;
487  if (swap) {
488  ReverseN(&size1, sizeof(size1));
489  ReverseN(&size2, sizeof(size2));
490  }
491  // Arbitrarily limit the number of elements to protect against bad data.
492  if (size1 > UINT16_MAX) return false;
493  if (size2 > UINT16_MAX) return false;
494  Resize(size1, size2, empty_);
495  return true;
496  }
void Resize(int size1, int size2, const T &empty)
Definition: matrix.h:108

◆ DeSerializeSize() [2/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::DeSerializeSize ( tesseract::TFile fp)
inlineprotected

Definition at line 497 of file matrix.h.

497  {
498  int32_t size1, size2;
499  if (!fp->DeSerialize(&size1)) return false;
500  if (!fp->DeSerialize(&size2)) return false;
501  // Arbitrarily limit the number of elements to protect against bad data.
502  if (size1 > UINT16_MAX) return false;
503  if (size2 > UINT16_MAX) return false;
504  Resize(size1, size2, empty_);
505  return true;
506  }

◆ dim1()

template<class T >
int GENERIC_2D_ARRAY< T >::dim1 ( ) const
inline

Definition at line 209 of file matrix.h.

209 { return dim1_; }

◆ dim2()

template<class T >
int GENERIC_2D_ARRAY< T >::dim2 ( ) const
inline

Definition at line 210 of file matrix.h.

210 { return dim2_; }

◆ get() [1/2]

template<class T >
T GENERIC_2D_ARRAY< T >::get ( ICOORD  pos) const
inline

Definition at line 231 of file matrix.h.

231  {
232  return array_[this->index(pos.x(), pos.y())];
233  }
virtual int index(int column, int row) const
Definition: matrix.h:218
int16_t y() const
access_function
Definition: points.h:56
int16_t x() const
access function
Definition: points.h:52

◆ get() [2/2]

template<class T >
T GENERIC_2D_ARRAY< T >::get ( int  column,
int  row 
) const
inline

Definition at line 234 of file matrix.h.

234  {
235  return array_[this->index(column, row)];
236  }

◆ index()

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

Reimplemented in BandTriMatrix< T >, and BandTriMatrix< BLOB_CHOICE_LIST * >.

Definition at line 218 of file matrix.h.

218  {
219  return (column * dim2_ + row);
220  }

◆ Max()

template<class T >
T GENERIC_2D_ARRAY< T >::Max ( ) const
inline

Definition at line 345 of file matrix.h.

345  {
346  int size = num_elements();
347  if (size <= 0) return empty_;
348  // Compute the max.
349  T max_value = array_[0];
350  for (int i = 1; i < size; ++i) {
351  const T& value = array_[i];
352  if (value > max_value) max_value = value;
353  }
354  return max_value;
355  }

◆ MaxAbs()

template<class T >
T GENERIC_2D_ARRAY< T >::MaxAbs ( ) const
inline

Definition at line 358 of file matrix.h.

358  {
359  int size = num_elements();
360  if (size <= 0) return empty_;
361  // Compute the max.
362  T max_abs = static_cast<T>(0);
363  for (int i = 0; i < size; ++i) {
364  T value = static_cast<T>(fabs(array_[i]));
365  if (value > max_abs) max_abs = value;
366  }
367  return max_abs;
368  }

◆ Normalize()

template<class T >
double GENERIC_2D_ARRAY< T >::Normalize ( )
inline

Definition at line 318 of file matrix.h.

318  {
319  int size = num_elements();
320  if (size <= 0) return 0.0;
321  // Compute the mean.
322  double mean = 0.0;
323  for (int i = 0; i < size; ++i) {
324  mean += array_[i];
325  }
326  mean /= size;
327  // Subtract the mean and compute the standard deviation.
328  double sd = 0.0;
329  for (int i = 0; i < size; ++i) {
330  double normed = array_[i] - mean;
331  array_[i] = normed;
332  sd += normed * normed;
333  }
334  sd = sqrt(sd / size);
335  if (sd > 0.0) {
336  // Divide by the sd.
337  for (int i = 0; i < size; ++i) {
338  array_[i] /= sd;
339  }
340  }
341  return sd;
342  }

◆ num_elements()

template<class T >
virtual int GENERIC_2D_ARRAY< T >::num_elements ( ) const
inlinevirtual

Definition at line 213 of file matrix.h.

213 { return dim1_ * dim2_; }

◆ operator()() [1/2]

template<class T >
T& GENERIC_2D_ARRAY< T >::operator() ( int  column,
int  row 
)
inline

Definition at line 241 of file matrix.h.

241  {
242  return array_[this->index(column, row)];
243  }

◆ operator()() [2/2]

template<class T >
const T& GENERIC_2D_ARRAY< T >::operator() ( int  column,
int  row 
) const
inline

Definition at line 238 of file matrix.h.

238  {
239  return array_[this->index(column, row)];
240  }

◆ operator*=()

template<class T >
void GENERIC_2D_ARRAY< T >::operator*= ( const T &  factor)
inline

Definition at line 293 of file matrix.h.

293  {
294  int size = num_elements();
295  for (int i = 0; i < size; ++i) {
296  array_[i] *= factor;
297  }
298  }

◆ operator+=() [1/2]

template<class T >
void GENERIC_2D_ARRAY< T >::operator+= ( const GENERIC_2D_ARRAY< T > &  addend)
inline

Definition at line 254 of file matrix.h.

254  {
255  if (dim2_ == addend.dim2_) {
256  // Faster if equal size in the major dimension.
257  int size = std::min(num_elements(), addend.num_elements());
258  for (int i = 0; i < size; ++i) {
259  array_[i] += addend.array_[i];
260  }
261  } else {
262  for (int x = 0; x < dim1_; x++) {
263  for (int y = 0; y < dim2_; y++) {
264  (*this)(x, y) += addend(x, y);
265  }
266  }
267  }
268  }

◆ operator+=() [2/2]

template<class T >
void GENERIC_2D_ARRAY< T >::operator+= ( const T &  addend)
inline

Definition at line 286 of file matrix.h.

286  {
287  int size = num_elements();
288  for (int i = 0; i < size; ++i) {
289  array_[i] += addend;
290  }
291  }

◆ operator-=()

template<class T >
void GENERIC_2D_ARRAY< T >::operator-= ( const GENERIC_2D_ARRAY< T > &  minuend)
inline

Definition at line 270 of file matrix.h.

270  {
271  if (dim2_ == minuend.dim2_) {
272  // Faster if equal size in the major dimension.
273  int size = std::min(num_elements(), minuend.num_elements());
274  for (int i = 0; i < size; ++i) {
275  array_[i] -= minuend.array_[i];
276  }
277  } else {
278  for (int x = 0; x < dim1_; x++) {
279  for (int y = 0; y < dim2_; y++) {
280  (*this)(x, y) -= minuend(x, y);
281  }
282  }
283  }
284  }

◆ operator=()

template<class T >
void GENERIC_2D_ARRAY< T >::operator= ( const GENERIC_2D_ARRAY< T > &  src)
inline

Definition at line 82 of file matrix.h.

82  {
83  ResizeNoInit(src.dim1(), src.dim2());
84  int size = num_elements();
85  if (size > 0) {
86  memcpy(array_, src.array_, size * sizeof(array_[0]));
87  }
88  }
void ResizeNoInit(int size1, int size2, int pad=0)
Definition: matrix.h:94

◆ operator[]() [1/2]

template<class T >
T* GENERIC_2D_ARRAY< T >::operator[] ( int  column)
inline

Definition at line 246 of file matrix.h.

246  {
247  return &array_[this->index(column, 0)];
248  }

◆ operator[]() [2/2]

template<class T >
const T* GENERIC_2D_ARRAY< T >::operator[] ( int  column) const
inline

Definition at line 249 of file matrix.h.

249  {
250  return &array_[this->index(column, 0)];
251  }

◆ put() [1/2]

template<class T >
void GENERIC_2D_ARRAY< T >::put ( ICOORD  pos,
const T &  thing 
)
inline

Definition at line 223 of file matrix.h.

223  {
224  array_[this->index(pos.x(), pos.y())] = thing;
225  }

◆ put() [2/2]

template<class T >
void GENERIC_2D_ARRAY< T >::put ( int  column,
int  row,
const T &  thing 
)
inline

Definition at line 226 of file matrix.h.

226  {
227  array_[this->index(column, row)] = thing;
228  }

◆ Resize()

template<class T >
void GENERIC_2D_ARRAY< T >::Resize ( int  size1,
int  size2,
const T &  empty 
)
inline

Definition at line 108 of file matrix.h.

108  {
109  empty_ = empty;
110  ResizeNoInit(size1, size2);
111  Clear();
112  }
void Clear()
Definition: matrix.h:139

◆ ResizeNoInit()

template<class T >
void GENERIC_2D_ARRAY< T >::ResizeNoInit ( int  size1,
int  size2,
int  pad = 0 
)
inline

Definition at line 94 of file matrix.h.

94  {
95  int new_size = size1 * size2 + pad;
96  if (new_size > size_allocated_) {
97  delete [] array_;
98  array_ = new T[new_size];
99  size_allocated_ = new_size;
100  }
101  dim1_ = size1;
102  dim2_ = size2;
103  // Fill the padding data so it isn't uninitialized.
104  for (int i = size1 * size2; i < new_size; ++i) array_[i] = empty_;
105  }

◆ ResizeWithCopy()

template<class T >
void GENERIC_2D_ARRAY< T >::ResizeWithCopy ( int  size1,
int  size2 
)
inline

Definition at line 115 of file matrix.h.

115  {
116  if (size1 != dim1_ || size2 != dim2_) {
117  int new_size = size1 * size2;
118  T* new_array = new T[new_size];
119  for (int col = 0; col < size1; ++col) {
120  for (int row = 0; row < size2; ++row) {
121  int old_index = col * dim2() + row;
122  int new_index = col * size2 + row;
123  if (col < dim1_ && row < dim2_) {
124  new_array[new_index] = array_[old_index];
125  } else {
126  new_array[new_index] = empty_;
127  }
128  }
129  }
130  delete[] array_;
131  array_ = new_array;
132  dim1_ = size1;
133  dim2_ = size2;
134  size_allocated_ = new_size;
135  }
136  }

◆ RotatingTranspose()

template<class T >
void GENERIC_2D_ARRAY< T >::RotatingTranspose ( const int *  dims,
int  num_dims,
int  src_dim,
int  dest_dim,
GENERIC_2D_ARRAY< T > *  result 
) const
inline

Definition at line 421 of file matrix.h.

422  {
423  int max_d = std::max(src_dim, dest_dim);
424  int min_d = std::min(src_dim, dest_dim);
425  // In a tensor of shape [d0, d1... min_d, ... max_d, ... dn-2, dn-1], the
426  // ends outside of min_d and max_d are unaffected, with [max_d +1, dn-1]
427  // being contiguous blocks of data that will move together, and
428  // [d0, min_d -1] being replicas of the transpose operation.
429  // num_replicas represents the large dimensions unchanged by the operation.
430  // move_size represents the small dimensions unchanged by the operation.
431  // src_step represents the stride in the src between each adjacent group
432  // in the destination.
433  int num_replicas = 1, move_size = 1, src_step = 1;
434  for (int d = 0; d < min_d; ++d) num_replicas *= dims[d];
435  for (int d = max_d + 1; d < num_dims; ++d) move_size *= dims[d];
436  for (int d = src_dim + 1; d < num_dims; ++d) src_step *= dims[d];
437  if (src_dim > dest_dim) src_step *= dims[src_dim];
438  // wrap_size is the size of a single replica, being the amount that is
439  // handled num_replicas times.
440  int wrap_size = move_size;
441  for (int d = min_d; d <= max_d; ++d) wrap_size *= dims[d];
442  result->ResizeNoInit(dim1_, dim2_);
443  result->empty_ = empty_;
444  const T* src = array_;
445  T* dest = result->array_;
446  for (int replica = 0; replica < num_replicas; ++replica) {
447  for (int start = 0; start < src_step; start += move_size) {
448  for (int pos = start; pos < wrap_size; pos += src_step) {
449  memcpy(dest, src + pos, sizeof(*dest) * move_size);
450  dest += move_size;
451  }
452  }
453  src += wrap_size;
454  }
455  }

◆ Serialize() [1/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::Serialize ( FILE *  fp) const
inline

Definition at line 147 of file matrix.h.

147  {
148  if (!SerializeSize(fp)) return false;
149  if (!tesseract::Serialize(fp, &empty_)) return false;
150  int size = num_elements();
151  return tesseract::Serialize(fp, &array_[0], size);
152  }
bool Serialize(FILE *fp, const char *data, size_t n)
Definition: serialis.cpp:60
bool SerializeSize(FILE *fp) const
Definition: matrix.h:469

◆ Serialize() [2/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::Serialize ( tesseract::TFile fp) const
inline

Definition at line 154 of file matrix.h.

154  {
155  if (!SerializeSize(fp)) return false;
156  if (!fp->Serialize(&empty_)) return false;
157  int size = num_elements();
158  return fp->Serialize(&array_[0], size);
159  }
bool Serialize(const char *data, size_t count=1)
Definition: serialis.cpp:148

◆ SerializeClasses()

template<class T >
bool GENERIC_2D_ARRAY< T >::SerializeClasses ( FILE *  fp) const
inline

Definition at line 185 of file matrix.h.

185  {
186  if (!SerializeSize(fp)) return false;
187  if (!empty_.Serialize(fp)) return false;
188  int size = num_elements();
189  for (int i = 0; i < size; ++i) {
190  if (!array_[i].Serialize(fp)) return false;
191  }
192  return true;
193  }
bool Serialize(FILE *fp) const
Definition: matrix.h:147

◆ SerializeSize() [1/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::SerializeSize ( FILE *  fp) const
inlineprotected

Definition at line 469 of file matrix.h.

469  {
470  uint32_t size = dim1_;
471  if (!tesseract::Serialize(fp, &size)) return false;
472  size = dim2_;
473  return tesseract::Serialize(fp, &size);
474  }

◆ SerializeSize() [2/2]

template<class T >
bool GENERIC_2D_ARRAY< T >::SerializeSize ( tesseract::TFile fp) const
inlineprotected

Definition at line 475 of file matrix.h.

475  {
476  uint32_t size = dim1_;
477  if (!fp->Serialize(&size)) return false;
478  size = dim2_;
479  return fp->Serialize(&size);
480  }

◆ SumSquares()

template<class T >
void GENERIC_2D_ARRAY< T >::SumSquares ( const GENERIC_2D_ARRAY< T > &  src,
const T &  decay_factor 
)
inline

Definition at line 371 of file matrix.h.

371  {
372  T update_factor = 1.0 - decay_factor;
373  int size = num_elements();
374  for (int i = 0; i < size; ++i) {
375  array_[i] = array_[i] * decay_factor +
376  update_factor * src.array_[i] * src.array_[i];
377  }
378  }

◆ WithinBounds()

template<class T >
bool GENERIC_2D_ARRAY< T >::WithinBounds ( const T &  rangemin,
const T &  rangemax 
) const
inline

Definition at line 308 of file matrix.h.

308  {
309  int size = num_elements();
310  for (int i = 0; i < size; ++i) {
311  const T& value = array_[i];
312  if (value < rangemin || rangemax < value)
313  return false;
314  }
315  return true;
316  }

Member Data Documentation

◆ array_

template<class T >
T* GENERIC_2D_ARRAY< T >::array_
protected

Definition at line 508 of file matrix.h.

◆ dim1_

template<class T >
int GENERIC_2D_ARRAY< T >::dim1_
protected

Definition at line 510 of file matrix.h.

◆ dim2_

template<class T >
int GENERIC_2D_ARRAY< T >::dim2_
protected

Definition at line 511 of file matrix.h.

◆ empty_

template<class T >
T GENERIC_2D_ARRAY< T >::empty_
protected

Definition at line 509 of file matrix.h.

◆ size_allocated_

template<class T >
int GENERIC_2D_ARRAY< T >::size_allocated_
protected

Definition at line 515 of file matrix.h.


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