#include <sparse-matrix.h>

Public Member Functions | |
| MatrixIndexT | Dim () const | 
| Real | Sum () const | 
| template<class OtherReal > | |
| void | CopyElementsToVec (VectorBase< OtherReal > *vec) const | 
| template<class OtherReal > | |
| void | AddToVec (Real alpha, VectorBase< OtherReal > *vec) const | 
| template<class OtherReal > | |
| void | CopyFromSvec (const SparseVector< OtherReal > &other) | 
| SparseVector< Real > & | operator= (const SparseVector< Real > &other) | 
| SparseVector (const SparseVector< Real > &other) | |
| void | Swap (SparseVector< Real > *other) | 
| Real | Max (int32 *index) const | 
| MatrixIndexT | NumElements () const | 
| Returns the number of nonzero elements.  More... | |
| const std::pair< MatrixIndexT, Real > & | GetElement (MatrixIndexT i) const | 
| get an indexed element (0 <= i < NumElements()).  More... | |
| std::pair< MatrixIndexT, Real > * | Data () | 
| const std::pair< MatrixIndexT, Real > * | Data () const | 
| void | SetRandn (BaseFloat zero_prob) | 
| Sets elements to zero with probability zero_prob, else normally distributed.  More... | |
| SparseVector () | |
| SparseVector (MatrixIndexT dim) | |
| SparseVector (MatrixIndexT dim, const std::vector< std::pair< MatrixIndexT, Real > > &pairs) | |
| SparseVector (const VectorBase< Real > &vec) | |
| void | Resize (MatrixIndexT dim, MatrixResizeType resize_type=kSetZero) | 
| Resizes to this dimension.  More... | |
| void | Write (std::ostream &os, bool binary) const | 
| void | Read (std::istream &os, bool binary) | 
| void | Scale (Real alpha) | 
| Scale all elements of sparse vector.  More... | |
Private Attributes | |
| MatrixIndexT | dim_ | 
| std::vector< std::pair< MatrixIndexT, Real > > | pairs_ | 
Definition at line 41 of file sparse-matrix.h.
      
  | 
  inline | 
Definition at line 60 of file sparse-matrix.h.
References SparseVector< Real >::Max(), and SparseVector< Real >::Swap().
      
  | 
  inline | 
      
  | 
  inlineexplicit | 
Definition at line 94 of file sparse-matrix.h.
References KALDI_ASSERT, kaldi::kSetZero, SparseVector< Real >::Read(), SparseVector< Real >::Resize(), SparseVector< Real >::Scale(), SparseVector< Real >::SparseVector(), and SparseVector< Real >::Write().
| SparseVector | ( | MatrixIndexT | dim, | 
| const std::vector< std::pair< MatrixIndexT, Real > > & | pairs | ||
| ) | 
Definition at line 237 of file sparse-matrix.cc.
References SparseVector< Real >::dim_, KALDI_ASSERT, and SparseVector< Real >::pairs_.
      
  | 
  explicit | 
Definition at line 1213 of file sparse-matrix.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), and rnnlm::i.
| template void AddToVec | ( | Real | alpha, | 
| VectorBase< OtherReal > * | vec | ||
| ) | const | 
Definition at line 84 of file sparse-matrix.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), and KALDI_ASSERT.
Referenced by SparseVector< Real >::Dim(), and kaldi::UnitTestSparseVectorAddToVec().
| template void CopyElementsToVec | ( | VectorBase< OtherReal > * | vec | ) | const | 
Definition at line 64 of file sparse-matrix.cc.
References VectorBase< Real >::Data(), VectorBase< Real >::Dim(), KALDI_ASSERT, and VectorBase< Real >::SetZero().
Referenced by SparseVector< Real >::Dim(), kaldi::UnitTestSparseVectorAddToVec(), kaldi::UnitTestSparseVectorMax(), kaldi::UnitTestSparseVectorSum(), and kaldi::UnitTestSparseVectorVecSvec().
| template void CopyFromSvec | ( | const SparseVector< OtherReal > & | other | ) | 
Definition at line 111 of file sparse-matrix.cc.
References SparseVector< Real >::Dim(), SparseVector< Real >::GetElement(), rnnlm::i, and SparseVector< Real >::NumElements().
Referenced by SparseVector< Real >::Dim().
| std::pair< MatrixIndexT, Real > * Data | ( | ) | 
Definition at line 32 of file sparse-matrix.cc.
Referenced by NnetLdaStatsAccumulator::AccStatsFromOutput(), SparseMatrix< float >::AddToMat(), SparseMatrix< float >::CopyToMat(), SparseVector< Real >::GetElement(), SparseMatrix< float >::SparseMatrix(), kaldi::TraceMatSmat(), and kaldi::VecSvec().
| const std::pair< MatrixIndexT, Real > * Data | ( | ) | const | 
Definition at line 40 of file sparse-matrix.cc.
      
  | 
  inline | 
Definition at line 43 of file sparse-matrix.h.
References SparseVector< Real >::AddToVec(), SparseVector< Real >::CopyElementsToVec(), SparseVector< Real >::CopyFromSvec(), SparseVector< Real >::dim_, SparseVector< Real >::operator=(), and SparseVector< Real >::Sum().
Referenced by SparseVector< Real >::CopyFromSvec(), SparseMatrix< float >::SetRow(), and kaldi::VecSvec().
      
  | 
  inline | 
get an indexed element (0 <= i < NumElements()).
Definition at line 77 of file sparse-matrix.h.
References SparseVector< Real >::Data(), rnnlm::i, SparseVector< Real >::pairs_, and SparseVector< Real >::SetRandn().
Referenced by MatrixBase< float >::AddMatSmat(), MatrixBase< float >::AddSmat(), MatrixBase< float >::AddSmatMat(), and SparseVector< Real >::CopyFromSvec().
| Real Max | ( | int32 * | index | ) | const | 
Definition at line 1167 of file sparse-matrix.cc.
References KALDI_ASSERT.
Referenced by kaldi::nnet3::ComputeAccuracy(), SparseVector< Real >::SparseVector(), and kaldi::UnitTestSparseVectorMax().
      
  | 
  inline | 
Returns the number of nonzero elements.
Definition at line 74 of file sparse-matrix.h.
References SparseVector< Real >::pairs_.
Referenced by NnetLdaStatsAccumulator::AccStatsFromOutput(), MatrixBase< float >::AddMatSmat(), MatrixBase< float >::AddSmat(), MatrixBase< float >::AddSmatMat(), SparseMatrix< float >::AddToMat(), SparseMatrix< float >::CopyElementsToVec(), SparseVector< Real >::CopyFromSvec(), SparseMatrix< float >::CopyToMat(), kaldi::TraceMatSmat(), and kaldi::VecSvec().
| SparseVector< Real > & operator= | ( | const SparseVector< Real > & | other | ) | 
Definition at line 132 of file sparse-matrix.cc.
References SparseVector< Real >::dim_, and SparseVector< Real >::pairs_.
Referenced by SparseVector< Real >::Dim(), and GeneralMatrix::GeneralMatrix().
| void Read | ( | std::istream & | os, | 
| bool | binary | ||
| ) | 
Definition at line 173 of file sparse-matrix.cc.
References kaldi::ExpectToken(), rnnlm::i, KALDI_ASSERT, KALDI_ERR, and kaldi::ReadBasicType().
Referenced by SparseMatrix< float >::Read(), SparseMatrix< float >::SparseMatrix(), and SparseVector< Real >::SparseVector().
| void Resize | ( | MatrixIndexT | dim, | 
| MatrixResizeType | resize_type = kSetZero  | 
        ||
| ) | 
Resizes to this dimension.
resize_type == kUndefined behaves the same as kSetZero.
Definition at line 280 of file sparse-matrix.cc.
References SparseVector< Real >::dim_, KALDI_ASSERT, kaldi::kCopyData, and SparseVector< Real >::pairs_.
Referenced by SparseMatrix< float >::SelectRows(), SparseMatrix< float >::SparseMatrix(), and SparseVector< Real >::SparseVector().
| void Scale | ( | Real | alpha | ) | 
Scale all elements of sparse vector.
Definition at line 57 of file sparse-matrix.cc.
References rnnlm::i.
Referenced by SparseMatrix< float >::SparseMatrix(), and SparseVector< Real >::SparseVector().
| void SetRandn | ( | BaseFloat | zero_prob | ) | 
Sets elements to zero with probability zero_prob, else normally distributed.
Useful in testing.
Definition at line 271 of file sparse-matrix.cc.
References SparseVector< Real >::dim_, rnnlm::i, KALDI_ASSERT, SparseVector< Real >::pairs_, kaldi::RandGauss(), and kaldi::WithProb().
Referenced by SparseVector< Real >::GetElement(), SparseMatrix< float >::SparseMatrix(), kaldi::UnitTestSparseVectorAddToVec(), kaldi::UnitTestSparseVectorMax(), kaldi::UnitTestSparseVectorSum(), and kaldi::UnitTestSparseVectorVecSvec().
| Real Sum | ( | ) | const | 
Definition at line 48 of file sparse-matrix.cc.
References rnnlm::i.
Referenced by kaldi::nnet3::ComputeAccuracy(), SparseVector< Real >::Dim(), and kaldi::UnitTestSparseVectorSum().
| void Swap | ( | SparseVector< Real > * | other | ) | 
Definition at line 141 of file sparse-matrix.cc.
References SparseVector< Real >::dim_, SparseVector< Real >::pairs_, and kaldi::swap().
Referenced by SparseMatrix< float >::CopyFromSmat(), GeneralMatrix::GeneralMatrix(), SparseMatrix< float >::SparseMatrix(), and SparseVector< Real >::SparseVector().
| void Write | ( | std::ostream & | os, | 
| bool | binary | ||
| ) | const | 
Definition at line 147 of file sparse-matrix.cc.
References kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by SparseMatrix< float >::SparseMatrix(), SparseVector< Real >::SparseVector(), and SparseMatrix< float >::Write().
      
  | 
  private | 
Definition at line 115 of file sparse-matrix.h.
Referenced by SparseVector< Real >::Dim(), SparseVector< Real >::operator=(), SparseVector< Real >::Resize(), SparseVector< Real >::SetRandn(), SparseVector< Real >::SparseVector(), and SparseVector< Real >::Swap().
      
  | 
  private | 
Definition at line 118 of file sparse-matrix.h.
Referenced by SparseVector< Real >::GetElement(), SparseVector< Real >::NumElements(), SparseVector< Real >::operator=(), SparseVector< Real >::Resize(), SparseVector< Real >::SetRandn(), SparseVector< Real >::SparseVector(), and SparseVector< Real >::Swap().