#include <compressed-matrix.h>

Classes | |
| struct | GlobalHeader | 
| struct | PerColHeader | 
Public Member Functions | |
| CompressedMatrix () | |
| ~CompressedMatrix () | |
| template<typename Real > | |
| CompressedMatrix (const MatrixBase< Real > &mat, CompressionMethod method=kAutomaticMethod) | |
| CompressedMatrix (const CompressedMatrix &mat, const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols, bool allow_padding=false) | |
| Initializer that can be used to select part of an existing CompressedMatrix without un-compressing and re-compressing (note: unlike similar initializers for class Matrix, it doesn't point to the same memory location).  More... | |
| void * | Data () const | 
| template<typename Real > | |
| void | CopyFromMat (const MatrixBase< Real > &mat, CompressionMethod method=kAutomaticMethod) | 
| This will resize *this and copy the contents of mat to *this.  More... | |
| CompressedMatrix (const CompressedMatrix &mat) | |
| CompressedMatrix & | operator= (const CompressedMatrix &mat) | 
| template<typename Real > | |
| CompressedMatrix & | operator= (const MatrixBase< Real > &mat) | 
| template<typename Real > | |
| void | CopyToMat (MatrixBase< Real > *mat, MatrixTransposeType trans=kNoTrans) const | 
| Copies contents to matrix.  More... | |
| void | Write (std::ostream &os, bool binary) const | 
| void | Read (std::istream &is, bool binary) | 
| MatrixIndexT | NumRows () const | 
| Returns number of rows (or zero for emtpy matrix).  More... | |
| MatrixIndexT | NumCols () const | 
| Returns number of columns (or zero for emtpy matrix).  More... | |
| template<typename Real > | |
| void | CopyRowToVec (MatrixIndexT row, VectorBase< Real > *v) const | 
| Copies row #row of the matrix into vector v.  More... | |
| template<typename Real > | |
| void | CopyColToVec (MatrixIndexT col, VectorBase< Real > *v) const | 
| Copies column #col of the matrix into vector v.  More... | |
| template<typename Real > | |
| void | CopyToMat (int32 row_offset, int32 column_offset, MatrixBase< Real > *dest) const | 
| Copies submatrix of compressed matrix into matrix dest.  More... | |
| void | Swap (CompressedMatrix *other) | 
| void | Clear () | 
| void | Scale (float alpha) | 
| scales all elements of matrix by alpha.  More... | |
Private Types | |
| enum | DataFormat { kOneByteWithColHeaders = 1, kTwoByte = 2, kOneByte = 3 } | 
Static Private Member Functions | |
| static void * | AllocateData (int32 num_bytes) | 
| template<typename Real > | |
| static void | ComputeGlobalHeader (const MatrixBase< Real > &mat, CompressionMethod method, GlobalHeader *header) | 
| static MatrixIndexT | DataSize (const GlobalHeader &header) | 
| template<typename Real > | |
| static void | CompressColumn (const GlobalHeader &global_header, const Real *data, MatrixIndexT stride, int32 num_rows, PerColHeader *header, uint8 *byte_data) | 
| template<typename Real > | |
| static void | ComputeColHeader (const GlobalHeader &global_header, const Real *data, MatrixIndexT stride, int32 num_rows, PerColHeader *header) | 
| static uint16 | FloatToUint16 (const GlobalHeader &global_header, float value) | 
| static uint8 | FloatToUint8 (const GlobalHeader &global_header, float value) | 
| static float | Uint16ToFloat (const GlobalHeader &global_header, uint16 value) | 
| static uint8 | FloatToChar (float p0, float p25, float p75, float p100, float value) | 
| static float | CharToFloat (float p0, float p25, float p75, float p100, uint8 value) | 
Private Attributes | |
| void * | data_ | 
Friends | |
| class | Matrix< float > | 
| class | Matrix< double > | 
Definition at line 91 of file compressed-matrix.h.
      
  | 
  private | 
| Enumerator | |
|---|---|
| kOneByteWithColHeaders | |
| kTwoByte | |
| kOneByte | |
Definition at line 201 of file compressed-matrix.h.
      
  | 
  inline | 
Definition at line 93 of file compressed-matrix.h.
Referenced by CompressedMatrix::CompressedMatrix(), and CompressedMatrix::Data().
      
  | 
  inline | 
      
  | 
  inlineexplicit | 
Definition at line 98 of file compressed-matrix.h.
References CompressedMatrix::CompressedMatrix(), and CompressedMatrix::CopyFromMat().
| CompressedMatrix | ( | const CompressedMatrix & | mat, | 
| const MatrixIndexT | row_offset, | ||
| const MatrixIndexT | num_rows, | ||
| const MatrixIndexT | col_offset, | ||
| const MatrixIndexT | num_cols, | ||
| bool | allow_padding = false  | 
        ||
| ) | 
Initializer that can be used to select part of an existing CompressedMatrix without un-compressing and re-compressing (note: unlike similar initializers for class Matrix, it doesn't point to the same memory location).
This creates a CompressedMatrix with the size (num_rows, num_cols) starting at (row_offset, col_offset).
If you specify allow_padding = true, it is permitted to have row_offset < 0 and row_offset + num_rows > mat.NumRows(), and the result will contain repeats of the first and last rows of 'mat' as necessary.
Definition at line 199 of file compressed-matrix.cc.
References CompressedMatrix::AllocateData(), CompressedMatrix::CopyToMat(), CompressedMatrix::Data(), CompressedMatrix::data_, CompressedMatrix::DataSize(), CompressedMatrix::GlobalHeader::format, rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_COMPILE_TIME_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, kaldi::kTwoByteAuto, kaldi::kUndefined, CompressedMatrix::GlobalHeader::num_cols, CompressedMatrix::GlobalHeader::num_rows, CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), and CompressedMatrix::Swap().
| CompressedMatrix | ( | const CompressedMatrix & | mat | ) | 
Definition at line 859 of file compressed-matrix.cc.
      
  | 
  staticprivate | 
Definition at line 524 of file compressed-matrix.cc.
References KALDI_ASSERT, and KALDI_COMPILE_TIME_ASSERT.
Referenced by CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyFromMat(), CompressedMatrix::operator=(), and CompressedMatrix::Read().
Definition at line 490 of file compressed-matrix.cc.
Referenced by CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyRowToVec(), and CompressedMatrix::CopyToMat().
| void Clear | ( | ) | 
Definition at line 852 of file compressed-matrix.cc.
References CompressedMatrix::data_.
Referenced by CompressedMatrix::operator=(), CompressedMatrix::Swap(), and CompressedMatrix::~CompressedMatrix().
      
  | 
  staticprivate | 
Definition at line 504 of file compressed-matrix.cc.
References CompressedMatrix::ComputeColHeader(), CompressedMatrix::FloatToChar(), rnnlm::i, CompressedMatrix::PerColHeader::percentile_0, CompressedMatrix::PerColHeader::percentile_100, CompressedMatrix::PerColHeader::percentile_25, CompressedMatrix::PerColHeader::percentile_75, and CompressedMatrix::Uint16ToFloat().
Referenced by CompressedMatrix::CopyFromMat().
      
  | 
  staticprivate | 
Definition at line 380 of file compressed-matrix.cc.
References CompressedMatrix::FloatToUint16(), rnnlm::i, KALDI_ASSERT, CompressedMatrix::PerColHeader::percentile_0, CompressedMatrix::PerColHeader::percentile_100, CompressedMatrix::PerColHeader::percentile_25, and CompressedMatrix::PerColHeader::percentile_75.
Referenced by CompressedMatrix::CompressColumn().
      
  | 
  inlinestaticprivate | 
Definition at line 57 of file compressed-matrix.cc.
References CompressedMatrix::GlobalHeader::format, KALDI_ASSERT, KALDI_COMPILE_TIME_ASSERT, KALDI_ERR, kaldi::kAutomaticMethod, CompressedMatrix::kOneByte, kaldi::kOneByteAuto, kaldi::kOneByteUnsignedInteger, CompressedMatrix::kOneByteWithColHeaders, kaldi::kOneByteZeroOne, kaldi::kSpeechFeature, CompressedMatrix::kTwoByte, kaldi::kTwoByteAuto, kaldi::kTwoByteSignedInteger, MatrixBase< Real >::Max(), MatrixBase< Real >::Min(), CompressedMatrix::GlobalHeader::min_value, CompressedMatrix::GlobalHeader::num_cols, CompressedMatrix::GlobalHeader::num_rows, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), and CompressedMatrix::GlobalHeader::range.
Referenced by CompressedMatrix::CopyFromMat().
| template void CopyColToVec | ( | MatrixIndexT | col, | 
| VectorBase< Real > * | v | ||
| ) | const | 
Copies column #col of the matrix into vector v.
Note: v must have same size as #rows.
Definition at line 724 of file compressed-matrix.cc.
References CompressedMatrix::CharToFloat(), CompressedMatrix::CopyRowToVec(), VectorBase< Real >::Data(), CompressedMatrix::data_, VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), CompressedMatrix::PerColHeader::percentile_0, CompressedMatrix::PerColHeader::percentile_100, CompressedMatrix::PerColHeader::percentile_25, CompressedMatrix::PerColHeader::percentile_75, and CompressedMatrix::Uint16ToFloat().
Referenced by CompressedMatrix::NumCols(), and kaldi::UnitTestCompressedMatrix().
| template void CopyFromMat | ( | const MatrixBase< Real > & | mat, | 
| CompressionMethod | method = kAutomaticMethod  | 
        ||
| ) | 
This will resize *this and copy the contents of mat to *this.
Definition at line 129 of file compressed-matrix.cc.
References CompressedMatrix::AllocateData(), CompressedMatrix::CompressColumn(), CompressedMatrix::ComputeGlobalHeader(), MatrixBase< Real >::Data(), CompressedMatrix::data_, CompressedMatrix::DataSize(), CompressedMatrix::FloatToUint16(), CompressedMatrix::FloatToUint8(), CompressedMatrix::GlobalHeader::format, KALDI_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, CompressedMatrix::GlobalHeader::num_cols, CompressedMatrix::GlobalHeader::num_rows, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), MatrixBase< Real >::RowData(), and MatrixBase< Real >::Stride().
Referenced by CompressedMatrix::CompressedMatrix(), CompressedAffineXformStats::CopyFromAffineXformStats(), CompressedMatrix::Data(), CompressedMatrix::operator=(), and CompressedMatrix::Read().
| template void CopyRowToVec | ( | MatrixIndexT | row, | 
| VectorBase< Real > * | v | ||
| ) | const | 
Copies row #row of the matrix into vector v.
Note: v must have same size as #cols.
Definition at line 681 of file compressed-matrix.cc.
References CompressedMatrix::CharToFloat(), VectorBase< Real >::Data(), CompressedMatrix::data_, VectorBase< Real >::Dim(), rnnlm::i, KALDI_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), and CompressedMatrix::Uint16ToFloat().
Referenced by CompressedMatrix::CopyColToVec(), kaldi::FilterCompressedMatrixRows(), CompressedMatrix::NumCols(), and kaldi::UnitTestCompressedMatrix().
| void CopyToMat | ( | MatrixBase< Real > * | mat, | 
| MatrixTransposeType | trans = kNoTrans  | 
        ||
| ) | const | 
Copies contents to matrix.
Note: mat must have the correct size. The kTrans case uses a temporary.
Definition at line 614 of file compressed-matrix.cc.
References CompressedMatrix::CharToFloat(), MatrixBase< Real >::CopyFromMat(), CompressedMatrix::data_, CompressedMatrix::GlobalHeader::format, rnnlm::i, rnnlm::j, KALDI_ASSERT, kaldi::kNoTrans, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, kaldi::kTrans, CompressedMatrix::kTwoByte, CompressedMatrix::GlobalHeader::min_value, CompressedMatrix::GlobalHeader::num_cols, CompressedMatrix::GlobalHeader::num_rows, MatrixBase< Real >::NumCols(), CompressedMatrix::NumCols(), MatrixBase< Real >::NumRows(), CompressedMatrix::NumRows(), CompressedMatrix::PerColHeader::percentile_0, CompressedMatrix::PerColHeader::percentile_100, CompressedMatrix::PerColHeader::percentile_25, CompressedMatrix::PerColHeader::percentile_75, CompressedMatrix::GlobalHeader::range, MatrixBase< Real >::RowData(), and CompressedMatrix::Uint16ToFloat().
Referenced by CompressedMatrix::CompressedMatrix(), MatrixBase< float >::CopyFromMat(), CompressedAffineXformStats::CopyToAffineXformStats(), CompressedMatrix::CopyToMat(), CompressedMatrix::Data(), kaldi::ExtractObjectRange(), kaldi::FilterCompressedMatrixRows(), Matrix< BaseFloat >::Matrix(), CompressedMatrix::NumCols(), Matrix< BaseFloat >::Read(), kaldi::UnitTestCompressedMatrix(), kaldi::UnitTestExtractCompressedMatrix(), and CompressedMatrix::Write().
| void CopyToMat | ( | int32 | row_offset, | 
| int32 | column_offset, | ||
| MatrixBase< Real > * | dest | ||
| ) | const | 
Copies submatrix of compressed matrix into matrix dest.
Submatrix starts at row row_offset and column column_offset and its size is defined by size of provided matrix dest
Definition at line 778 of file compressed-matrix.cc.
References CompressedMatrix::CharToFloat(), CompressedMatrix::CopyToMat(), CompressedMatrix::data_, rnnlm::i, rnnlm::j, KALDI_ASSERT, KALDI_PARANOID_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, CompressedMatrix::GlobalHeader::num_rows, MatrixBase< Real >::NumCols(), CompressedMatrix::NumCols(), MatrixBase< Real >::NumRows(), CompressedMatrix::NumRows(), MatrixBase< Real >::RowData(), and CompressedMatrix::Uint16ToFloat().
      
  | 
  inline | 
Definition at line 121 of file compressed-matrix.h.
References CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyFromMat(), CompressedMatrix::CopyToMat(), CompressedMatrix::data_, kaldi::kAutomaticMethod, kaldi::kNoTrans, CompressedMatrix::operator=(), CompressedMatrix::Read(), and CompressedMatrix::Write().
Referenced by CompressedMatrix::CompressedMatrix().
      
  | 
  staticprivate | 
Definition at line 28 of file compressed-matrix.cc.
References CompressedMatrix::GlobalHeader::format, KALDI_ASSERT, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, CompressedMatrix::GlobalHeader::num_cols, and CompressedMatrix::GlobalHeader::num_rows.
Referenced by CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyFromMat(), CompressedMatrix::operator=(), CompressedMatrix::Read(), and CompressedMatrix::Write().
Definition at line 457 of file compressed-matrix.cc.
Referenced by CompressedMatrix::CompressColumn().
      
  | 
  inlinestaticprivate | 
Definition at line 347 of file compressed-matrix.cc.
References CompressedMatrix::GlobalHeader::min_value, and CompressedMatrix::GlobalHeader::range.
Referenced by CompressedMatrix::ComputeColHeader(), and CompressedMatrix::CopyFromMat().
      
  | 
  inlinestaticprivate | 
Definition at line 359 of file compressed-matrix.cc.
References CompressedMatrix::GlobalHeader::min_value, and CompressedMatrix::GlobalHeader::range.
Referenced by CompressedMatrix::CopyFromMat().
      
  | 
  inline | 
Returns number of columns (or zero for emtpy matrix).
Definition at line 150 of file compressed-matrix.h.
References CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyRowToVec(), CompressedMatrix::CopyToMat(), and CompressedMatrix::data_.
Referenced by CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyRowToVec(), CompressedAffineXformStats::CopyToAffineXformStats(), CompressedMatrix::CopyToMat(), kaldi::ExtractObjectRange(), kaldi::ExtractRowRangeWithPadding(), kaldi::FilterCompressedMatrixRows(), main(), Matrix< BaseFloat >::Matrix(), NnetExample::NnetExample(), Matrix< BaseFloat >::Read(), kaldi::UnitTestCompressedMatrix(), and CompressedMatrix::Write().
      
  | 
  inline | 
Returns number of rows (or zero for emtpy matrix).
Definition at line 146 of file compressed-matrix.h.
References CompressedMatrix::data_.
Referenced by DiscriminativeNnetExample::Check(), CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyRowToVec(), CompressedAffineXformStats::CopyToAffineXformStats(), CompressedMatrix::CopyToMat(), kaldi::ExtractObjectRange(), kaldi::FilterCompressedMatrixRows(), Matrix< BaseFloat >::Matrix(), NnetExample::NnetExample(), Matrix< BaseFloat >::Read(), kaldi::UnitTestCompressedMatrix(), and CompressedMatrix::Write().
| CompressedMatrix & operator= | ( | const CompressedMatrix & | mat | ) | 
Definition at line 863 of file compressed-matrix.cc.
References CompressedMatrix::AllocateData(), CompressedMatrix::Clear(), CompressedMatrix::data_, and CompressedMatrix::DataSize().
Referenced by CompressedMatrix::Data(), and CompressedMatrix::operator=().
| CompressedMatrix & operator= | ( | const MatrixBase< Real > & | mat | ) | 
Definition at line 335 of file compressed-matrix.cc.
References CompressedMatrix::CopyFromMat(), and CompressedMatrix::operator=().
| void Read | ( | std::istream & | is, | 
| bool | binary | ||
| ) | 
Definition at line 566 of file compressed-matrix.cc.
References CompressedMatrix::AllocateData(), CompressedMatrix::CopyFromMat(), CompressedMatrix::data_, CompressedMatrix::DataSize(), CompressedMatrix::GlobalHeader::format, KALDI_ERR, CompressedMatrix::GlobalHeader::num_cols, kaldi::Peek(), Matrix< Real >::Read(), and kaldi::ReadToken().
Referenced by CompressedMatrix::Data(), CompressedAffineXformStats::Read(), NnetExample::Read(), DiscriminativeNnetExample::Read(), Matrix< BaseFloat >::Read(), and kaldi::UnitTestCompressedMatrix().
| void Scale | ( | float | alpha | ) | 
scales all elements of matrix by alpha.
It scales the floating point values in GlobalHeader by alpha.
Definition at line 46 of file compressed-matrix.cc.
References CompressedMatrix::data_, CompressedMatrix::GlobalHeader::min_value, and CompressedMatrix::GlobalHeader::range.
Referenced by CompressedMatrix::Swap(), and kaldi::UnitTestCompressedMatrix().
      
  | 
  inline | 
Definition at line 171 of file compressed-matrix.h.
References CompressedMatrix::Clear(), CompressedMatrix::data_, CompressedMatrix::Scale(), and kaldi::swap().
Referenced by CompressedMatrix::CompressedMatrix(), NnetExample::NnetExample(), and GeneralMatrix::SwapCompressedMatrix().
      
  | 
  inlinestaticprivate | 
Definition at line 371 of file compressed-matrix.cc.
References CompressedMatrix::GlobalHeader::min_value, and CompressedMatrix::GlobalHeader::range.
Referenced by CompressedMatrix::CompressColumn(), CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyRowToVec(), and CompressedMatrix::CopyToMat().
| void Write | ( | std::ostream & | os, | 
| bool | binary | ||
| ) | const | 
Definition at line 531 of file compressed-matrix.cc.
References CompressedMatrix::CopyToMat(), CompressedMatrix::data_, CompressedMatrix::DataSize(), CompressedMatrix::GlobalHeader::format, KALDI_ERR, CompressedMatrix::kOneByte, CompressedMatrix::kOneByteWithColHeaders, CompressedMatrix::kTwoByte, kaldi::kUndefined, CompressedMatrix::GlobalHeader::min_value, CompressedMatrix::GlobalHeader::num_cols, CompressedMatrix::GlobalHeader::num_rows, CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), CompressedMatrix::GlobalHeader::range, MatrixBase< Real >::Write(), and kaldi::WriteToken().
Referenced by CompressedMatrix::Data(), kaldi::UnitTestCompressedMatrix(), CompressedAffineXformStats::Write(), NnetExample::Write(), and DiscriminativeNnetExample::Write().
      
  | 
  friend | 
Definition at line 180 of file compressed-matrix.h.
Definition at line 179 of file compressed-matrix.h.
      
  | 
  private | 
Definition at line 271 of file compressed-matrix.h.
Referenced by CompressedMatrix::Clear(), CompressedMatrix::CompressedMatrix(), CompressedMatrix::CopyColToVec(), CompressedMatrix::CopyFromMat(), CompressedMatrix::CopyRowToVec(), CompressedMatrix::CopyToMat(), CompressedMatrix::Data(), CompressedMatrix::NumCols(), CompressedMatrix::NumRows(), CompressedMatrix::operator=(), CompressedMatrix::Read(), CompressedMatrix::Scale(), CompressedMatrix::Swap(), and CompressedMatrix::Write().