tesseract  3.03
MATRIX Class Reference

#include <matrix.h>

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

List of all members.

Public Member Functions

 MATRIX (int dimension, int bandwidth)
bool Classified (int col, int row, int wildcard_id) const
void IncreaseBandSize (int bandwidth)
MATRIXConsumeAndMakeBigger (int ind)
MATRIXDeepCopy () const
void print (const UNICHARSET &unicharset) const

Detailed Description

Definition at line 289 of file matrix.h.


Constructor & Destructor Documentation

MATRIX::MATRIX ( int  dimension,
int  bandwidth 
) [inline]

Member Function Documentation

bool MATRIX::Classified ( int  col,
int  row,
int  wildcard_id 
) const

Definition at line 36 of file matrix.cpp.

                                                               {
  if (get(col, row) == NOT_CLASSIFIED) return false;
  BLOB_CHOICE_IT b_it(get(col, row));
  for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
    BLOB_CHOICE* choice = b_it.data();
    if (choice->IsClassified())
      return true;
  }
  return false;
}

Definition at line 58 of file matrix.cpp.

                                            {
  int dim = dimension();
  int band_width = bandwidth();
  // Check to see if bandwidth needs expanding.
  for (int col = ind; col >= 0 && col > ind - band_width; --col) {
    if (array_[col * band_width + band_width - 1] != empty_) {
      ++band_width;
      break;
    }
  }
  MATRIX* result = new MATRIX(dim + 1, band_width);

  for (int col = 0; col < dim; ++col) {
    for (int row = col; row < dim && row < col + bandwidth(); ++row) {
      MATRIX_COORD coord(col, row);
      coord.MapForSplit(ind);
      BLOB_CHOICE_LIST* choices = get(col, row);
      if (choices != NULL) {
        // Correct matrix location on each choice.
        BLOB_CHOICE_IT bc_it(choices);
        for (bc_it.mark_cycle_pt(); !bc_it.cycled_list(); bc_it.forward()) {
          BLOB_CHOICE* choice = bc_it.data();
          choice->set_matrix_cell(coord.col, coord.row);
        }
        ASSERT_HOST(coord.Valid(*result));
        result->put(coord.col, coord.row, choices);
      }
    }
  }
  delete this;
  return result;
}
MATRIX * MATRIX::DeepCopy ( ) const

Definition at line 94 of file matrix.cpp.

                               {
  int dim = dimension();
  int band_width = bandwidth();
  MATRIX* result = new MATRIX(dim, band_width);
  for (int col = 0; col < dim; ++col) {
    for (int row = col; row < col + band_width; ++row) {
      BLOB_CHOICE_LIST* choices = get(col, row);
      if (choices != NULL) {
        BLOB_CHOICE_LIST* copy_choices = new BLOB_CHOICE_LIST;
        choices->deep_copy(copy_choices, &BLOB_CHOICE::deep_copy);
        result->put(col, row, copy_choices);
      }
    }
  }
  return result;
}
void MATRIX::IncreaseBandSize ( int  bandwidth)

Definition at line 49 of file matrix.cpp.

void MATRIX::print ( const UNICHARSET unicharset) const

Definition at line 112 of file matrix.cpp.

                                                     {
  tprintf("Ratings Matrix (top 3 choices)\n");
  int dim = dimension();
  int band_width = bandwidth();
  int row, col;
  for (col = 0; col < dim; ++col) {
    for (row = col; row < dim && row < col + band_width; ++row) {
      BLOB_CHOICE_LIST *rating = this->get(col, row);
      if (rating == NOT_CLASSIFIED) continue;
      BLOB_CHOICE_IT b_it(rating);
      tprintf("col=%d row=%d ", col, row);
      for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
        tprintf("%s rat=%g cert=%g " ,
                unicharset.id_to_unichar(b_it.data()->unichar_id()),
                b_it.data()->rating(), b_it.data()->certainty());
      }
      tprintf("\n");
    }
    tprintf("\n");
  }
  tprintf("\n");
  for (col = 0; col < dim; ++col) tprintf("\t%d", col);
  tprintf("\n");
  for (row = 0; row < dim; ++row) {
    for (col = 0; col <= row; ++col) {
      if (col == 0) tprintf("%d\t", row);
      if (row >= col + band_width) {
        tprintf(" \t");
        continue;
      }
      BLOB_CHOICE_LIST *rating = this->get(col, row);
      if (rating != NOT_CLASSIFIED) {
        BLOB_CHOICE_IT b_it(rating);
        int counter = 0;
        for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
          tprintf("%s ",
                  unicharset.id_to_unichar(b_it.data()->unichar_id()));
          ++counter;
          if (counter == 3) break;
        }
        tprintf("\t");
      } else {
        tprintf(" \t");
      }
    }
    tprintf("\n");
  }
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines