A class for storing matrices. More...
#include <kaldi-matrix.h>
Public Member Functions | |
Matrix () | |
Empty constructor. More... | |
Matrix (const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride) | |
Basic constructor. More... | |
template<typename OtherReal > | |
Matrix (const CuMatrixBase< OtherReal > &cu, MatrixTransposeType trans=kNoTrans) | |
Copy constructor from CUDA matrix This is defined in ../cudamatrix/cu-matrix.h. More... | |
void | Swap (Matrix< Real > *other) |
Swaps the contents of *this and *other. Shallow swap. More... | |
void | Swap (CuMatrix< Real > *mat) |
Defined in ../cudamatrix/cu-matrix.cc. More... | |
Matrix (const MatrixBase< Real > &M, MatrixTransposeType trans=kNoTrans) | |
Constructor from any MatrixBase. More... | |
Matrix (const Matrix< Real > &M) | |
Same as above, but need to avoid default copy constructor. More... | |
template<typename OtherReal > | |
Matrix (const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans) | |
Copy constructor: as above, but from another type. More... | |
template<typename OtherReal > | |
Matrix (const SpMatrix< OtherReal > &M) | |
Copy constructor taking SpMatrix... More... | |
Matrix (const CompressedMatrix &C) | |
Constructor from CompressedMatrix. More... | |
template<typename OtherReal > | |
Matrix (const TpMatrix< OtherReal > &M, MatrixTransposeType trans=kNoTrans) | |
Copy constructor taking TpMatrix... More... | |
void | Read (std::istream &in, bool binary, bool add=false) |
read from stream. More... | |
void | RemoveRow (MatrixIndexT i) |
Remove a specified row. More... | |
void | Transpose () |
Transpose the matrix. More... | |
~Matrix () | |
Distructor to free matrices. More... | |
void | Resize (const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride) |
Sets matrix to a specified size (zero is OK as long as both r and c are zero). More... | |
Matrix< Real > & | operator= (const MatrixBase< Real > &other) |
Assignment operator that takes MatrixBase. More... | |
Matrix< Real > & | operator= (const Matrix< Real > &other) |
Assignment operator. Needed for inclusion in std::vector. More... | |
Public Member Functions inherited from MatrixBase< Real > | |
MatrixIndexT | NumRows () const |
Returns number of rows (or zero for empty matrix). More... | |
MatrixIndexT | NumCols () const |
Returns number of columns (or zero for empty matrix). More... | |
MatrixIndexT | Stride () const |
Stride (distance in memory between each row). Will be >= NumCols. More... | |
size_t | SizeInBytes () const |
Returns size in bytes of the data held by the matrix. More... | |
const Real * | Data () const |
Gives pointer to raw data (const). More... | |
Real * | Data () |
Gives pointer to raw data (non-const). More... | |
Real * | RowData (MatrixIndexT i) |
Returns pointer to data for one row (non-const) More... | |
const Real * | RowData (MatrixIndexT i) const |
Returns pointer to data for one row (const) More... | |
Real & | operator() (MatrixIndexT r, MatrixIndexT c) |
Indexing operator, non-const (only checks sizes if compiled with -DKALDI_PARANOID) More... | |
Real & | Index (MatrixIndexT r, MatrixIndexT c) |
Indexing operator, provided for ease of debugging (gdb doesn't work with parenthesis operator). More... | |
const Real | operator() (MatrixIndexT r, MatrixIndexT c) const |
Indexing operator, const (only checks sizes if compiled with -DKALDI_PARANOID) More... | |
void | SetZero () |
Sets matrix to zero. More... | |
void | Set (Real) |
Sets all elements to a specific value. More... | |
void | SetUnit () |
Sets to zero, except ones along diagonal [for non-square matrices too]. More... | |
void | SetRandn () |
Sets to random values of a normal distribution. More... | |
void | SetRandUniform () |
Sets to numbers uniformly distributed on (0, 1) More... | |
template<typename OtherReal > | |
void | CopyFromMat (const MatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans) |
Copy given matrix. (no resize is done). More... | |
void | CopyFromMat (const CompressedMatrix &M) |
Copy from compressed matrix. More... | |
template<typename OtherReal > | |
void | CopyFromSp (const SpMatrix< OtherReal > &M) |
Copy given spmatrix. (no resize is done). More... | |
template<typename OtherReal > | |
void | CopyFromTp (const TpMatrix< OtherReal > &M, MatrixTransposeType trans=kNoTrans) |
Copy given tpmatrix. (no resize is done). More... | |
template<typename OtherReal > | |
void | CopyFromMat (const CuMatrixBase< OtherReal > &M, MatrixTransposeType trans=kNoTrans) |
Copy from CUDA matrix. Implemented in ../cudamatrix/cu-matrix.h. More... | |
void | CopyRowsFromVec (const VectorBase< Real > &v) |
This function has two modes of operation. More... | |
void | CopyRowsFromVec (const CuVectorBase< Real > &v) |
This version of CopyRowsFromVec is implemented in ../cudamatrix/cu-vector.cc. More... | |
template<typename OtherReal > | |
void | CopyRowsFromVec (const VectorBase< OtherReal > &v) |
void | CopyColsFromVec (const VectorBase< Real > &v) |
Copies vector into matrix, column-by-column. More... | |
void | CopyColFromVec (const VectorBase< Real > &v, const MatrixIndexT col) |
Copy vector into specific column of matrix. More... | |
void | CopyRowFromVec (const VectorBase< Real > &v, const MatrixIndexT row) |
Copy vector into specific row of matrix. More... | |
void | CopyDiagFromVec (const VectorBase< Real > &v) |
Copy vector into diagonal of matrix. More... | |
const SubVector< Real > | Row (MatrixIndexT i) const |
Return specific row of matrix [const]. More... | |
SubVector< Real > | Row (MatrixIndexT i) |
Return specific row of matrix. More... | |
SubMatrix< Real > | Range (const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const |
Return a sub-part of matrix. More... | |
SubMatrix< Real > | RowRange (const MatrixIndexT row_offset, const MatrixIndexT num_rows) const |
SubMatrix< Real > | ColRange (const MatrixIndexT col_offset, const MatrixIndexT num_cols) const |
Real | Sum () const |
Returns sum of all elements in matrix. More... | |
Real | Trace (bool check_square=true) const |
Returns trace of matrix. More... | |
Real | Max () const |
Returns maximum element of matrix. More... | |
Real | Min () const |
Returns minimum element of matrix. More... | |
void | MulElements (const MatrixBase< Real > &A) |
Element by element multiplication with a given matrix. More... | |
void | DivElements (const MatrixBase< Real > &A) |
Divide each element by the corresponding element of a given matrix. More... | |
void | Scale (Real alpha) |
Multiply each element with a scalar value. More... | |
void | Max (const MatrixBase< Real > &A) |
Set, element-by-element, *this = max(*this, A) More... | |
void | Min (const MatrixBase< Real > &A) |
Set, element-by-element, *this = min(*this, A) More... | |
void | MulColsVec (const VectorBase< Real > &scale) |
Equivalent to (*this) = (*this) * diag(scale). More... | |
void | MulRowsVec (const VectorBase< Real > &scale) |
Equivalent to (*this) = diag(scale) * (*this). More... | |
void | MulRowsGroupMat (const MatrixBase< Real > &src) |
Divide each row into src.NumCols() equal groups, and then scale i'th row's j'th group of elements by src(i, j). More... | |
Real | LogDet (Real *det_sign=NULL) const |
Returns logdet of matrix. More... | |
void | Invert (Real *log_det=NULL, Real *det_sign=NULL, bool inverse_needed=true) |
matrix inverse. More... | |
void | InvertDouble (Real *LogDet=NULL, Real *det_sign=NULL, bool inverse_needed=true) |
matrix inverse [double]. More... | |
void | InvertElements () |
Inverts all the elements of the matrix. More... | |
void | Transpose () |
Transpose the matrix. More... | |
void | CopyCols (const MatrixBase< Real > &src, const MatrixIndexT *indices) |
Copies column r from column indices[r] of src. More... | |
void | CopyRows (const MatrixBase< Real > &src, const MatrixIndexT *indices) |
Copies row r from row indices[r] of src (does nothing As a special case, if indexes[i] == -1, sets row i to zero. More... | |
void | AddCols (const MatrixBase< Real > &src, const MatrixIndexT *indices) |
Add column indices[r] of src to column r. More... | |
void | CopyRows (const Real *const *src) |
Copies row r of this matrix from an array of floats at the location given by src[r]. More... | |
void | CopyToRows (Real *const *dst) const |
Copies row r of this matrix to the array of floats at the location given by dst[r]. More... | |
void | AddRows (Real alpha, const MatrixBase< Real > &src, const MatrixIndexT *indexes) |
Does for each row r, this.Row(r) += alpha * src.row(indexes[r]). More... | |
void | AddRows (Real alpha, const Real *const *src) |
Does for each row r, this.Row(r) += alpha * src[r], treating src[r] as the beginning of a region of memory representing a vector of floats, of the same length as this.NumCols(). More... | |
void | AddToRows (Real alpha, Real *const *dst) const |
For each row r of this matrix, adds it (times alpha) to the array of floats at the location given by dst[r]. More... | |
void | AddToRows (Real alpha, const MatrixIndexT *indexes, MatrixBase< Real > *dst) const |
For each row i of *this, adds this->Row(i) to dst->Row(indexes(i)) if indexes(i) >= 0, else do nothing. More... | |
void | ApplyPow (Real power) |
void | ApplyPowAbs (Real power, bool include_sign=false) |
void | ApplyHeaviside () |
void | ApplyFloor (Real floor_val) |
void | ApplyCeiling (Real ceiling_val) |
void | ApplyExp () |
void | ApplyExpSpecial () |
void | ApplyExpLimited (Real lower_limit, Real upper_limit) |
void | ApplyLog () |
void | Eig (MatrixBase< Real > *P, VectorBase< Real > *eigs_real, VectorBase< Real > *eigs_imag) const |
Eigenvalue Decomposition of a square NxN matrix into the form (*this) = P D P^{-1}. More... | |
bool | Power (Real pow) |
The Power method attempts to take the matrix to a power using a method that works in general for fractional and negative powers. More... | |
void | DestructiveSvd (VectorBase< Real > *s, MatrixBase< Real > *U, MatrixBase< Real > *Vt) |
Singular value decomposition Major limitations: For nonsquare matrices, we assume m>=n (NumRows >= NumCols), and we return the "skinny" Svd, i.e. More... | |
void | Svd (VectorBase< Real > *s, MatrixBase< Real > *U, MatrixBase< Real > *Vt) const |
Compute SVD (*this) = U diag(s) Vt. More... | |
void | Svd (VectorBase< Real > *s) const |
Compute SVD but only retain the singular values. More... | |
Real | MinSingularValue () const |
Returns smallest singular value. More... | |
void | TestUninitialized () const |
Real | Cond () const |
Returns condition number by computing Svd. More... | |
bool | IsSymmetric (Real cutoff=1.0e-05) const |
Returns true if matrix is Symmetric. More... | |
bool | IsDiagonal (Real cutoff=1.0e-05) const |
Returns true if matrix is Diagonal. More... | |
bool | IsUnit (Real cutoff=1.0e-05) const |
Returns true if the matrix is all zeros, except for ones on diagonal. More... | |
bool | IsZero (Real cutoff=1.0e-05) const |
Returns true if matrix is all zeros. More... | |
Real | FrobeniusNorm () const |
Frobenius norm, which is the sqrt of sum of square elements. More... | |
bool | ApproxEqual (const MatrixBase< Real > &other, float tol=0.01) const |
Returns true if ((*this)-other).FrobeniusNorm() <= tol * (*this).FrobeniusNorm(). More... | |
bool | Equal (const MatrixBase< Real > &other) const |
Tests for exact equality. It's usually preferable to use ApproxEqual. More... | |
Real | LargestAbsElem () const |
largest absolute value. More... | |
Real | LogSumExp (Real prune=-1.0) const |
Returns log(sum(exp())) without exp overflow If prune > 0.0, it uses a pruning beam, discarding terms less than (max - prune). More... | |
Real | ApplySoftMax () |
Apply soft-max to the collection of all elements of the matrix and return normalizer (log sum of exponentials). More... | |
void | Sigmoid (const MatrixBase< Real > &src) |
Set each element to the sigmoid of the corresponding element of "src". More... | |
void | Heaviside (const MatrixBase< Real > &src) |
Sets each element to the Heaviside step function (x > 0 ? 1 : 0) of the corresponding element in "src". More... | |
void | Exp (const MatrixBase< Real > &src) |
void | Pow (const MatrixBase< Real > &src, Real power) |
void | Log (const MatrixBase< Real > &src) |
void | PowAbs (const MatrixBase< Real > &src, Real power, bool include_sign=false) |
Apply power to the absolute value of each element. More... | |
void | Floor (const MatrixBase< Real > &src, Real floor_val) |
void | Ceiling (const MatrixBase< Real > &src, Real ceiling_val) |
void | ExpSpecial (const MatrixBase< Real > &src) |
For each element x of the matrix, set it to (x < 0 ? exp(x) : x + 1). More... | |
void | ExpLimited (const MatrixBase< Real > &src, Real lower_limit, Real upper_limit) |
This is equivalent to running: Floor(src, lower_limit); Ceiling(src, upper_limit); Exp(src) More... | |
void | SoftHinge (const MatrixBase< Real > &src) |
Set each element to y = log(1 + exp(x)) More... | |
void | GroupPnorm (const MatrixBase< Real > &src, Real power) |
Apply the function y(i) = (sum_{j = i*G}^{(i+1)*G-1} x_j^(power))^(1 / p). More... | |
void | GroupPnormDeriv (const MatrixBase< Real > &input, const MatrixBase< Real > &output, Real power) |
Calculate derivatives for the GroupPnorm function above... More... | |
void | GroupMax (const MatrixBase< Real > &src) |
Apply the function y(i) = (max_{j = i*G}^{(i+1)*G-1} x_j Requires src.NumRows() == this->NumRows() and src.NumCols() % this->NumCols() == 0. More... | |
void | GroupMaxDeriv (const MatrixBase< Real > &input, const MatrixBase< Real > &output) |
Calculate derivatives for the GroupMax function above, where "input" is the input to the GroupMax function above (i.e. More... | |
void | Tanh (const MatrixBase< Real > &src) |
Set each element to the tanh of the corresponding element of "src". More... | |
void | DiffSigmoid (const MatrixBase< Real > &value, const MatrixBase< Real > &diff) |
void | DiffTanh (const MatrixBase< Real > &value, const MatrixBase< Real > &diff) |
void | SymPosSemiDefEig (VectorBase< Real > *s, MatrixBase< Real > *P, Real check_thresh=0.001) |
Uses Svd to compute the eigenvalue decomposition of a symmetric positive semi-definite matrix: (*this) = rP * diag(rS) * rP^T, with rP an orthogonal matrix so rP^{-1} = rP^T. More... | |
void | Add (const Real alpha) |
Add a scalar to each element. More... | |
void | AddToDiag (const Real alpha) |
Add a scalar to each diagonal element. More... | |
template<typename OtherReal > | |
void | AddVecVec (const Real alpha, const VectorBase< OtherReal > &a, const VectorBase< OtherReal > &b) |
*this += alpha * a * b^T More... | |
template<typename OtherReal > | |
void | AddVecToRows (const Real alpha, const VectorBase< OtherReal > &v) |
[each row of *this] += alpha * v More... | |
template<typename OtherReal > | |
void | AddVecToCols (const Real alpha, const VectorBase< OtherReal > &v) |
[each col of *this] += alpha * v More... | |
void | AddMat (const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transA=kNoTrans) |
*this += alpha * M [or M^T] More... | |
void | AddSmat (Real alpha, const SparseMatrix< Real > &A, MatrixTransposeType trans=kNoTrans) |
*this += alpha * A [or A^T]. More... | |
void | AddSmatMat (Real alpha, const SparseMatrix< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, Real beta) |
(*this) = alpha * op(A) * B + beta * (*this), where A is sparse. More... | |
void | AddMatSmat (Real alpha, const MatrixBase< Real > &A, const SparseMatrix< Real > &B, MatrixTransposeType transB, Real beta) |
(*this) = alpha * A * op(B) + beta * (*this), where B is sparse and op(B) is either B or trans(B) depending on the 'transB' argument. More... | |
void | SymAddMat2 (const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transA, Real beta) |
*this = beta * *this + alpha * M M^T, for symmetric matrices. More... | |
void | AddDiagVecMat (const Real alpha, const VectorBase< Real > &v, const MatrixBase< Real > &M, MatrixTransposeType transM, Real beta=1.0) |
*this = beta * *this + alpha * diag(v) * M [or M^T]. More... | |
void | AddMatDiagVec (const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, VectorBase< Real > &v, Real beta=1.0) |
*this = beta * *this + alpha * M [or M^T] * diag(v) The same as adding M but scaling each column M_j by v(j). More... | |
void | AddMatMatElements (const Real alpha, const MatrixBase< Real > &A, const MatrixBase< Real > &B, const Real beta) |
*this = beta * *this + alpha * A .* B (.* element by element multiplication) More... | |
template<typename OtherReal > | |
void | AddSp (const Real alpha, const SpMatrix< OtherReal > &S) |
*this += alpha * S More... | |
void | AddMatMat (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta) |
void | SetMatMatDivMat (const MatrixBase< Real > &A, const MatrixBase< Real > &B, const MatrixBase< Real > &C) |
*this = a * b / c (by element; when c = 0, *this = a) More... | |
void | AddMatSmat (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta) |
A version of AddMatMat specialized for when the second argument contains a lot of zeroes. More... | |
void | AddSmatMat (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta) |
A version of AddMatMat specialized for when the first argument contains a lot of zeroes. More... | |
void | AddMatMatMat (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const MatrixBase< Real > &C, MatrixTransposeType transC, const Real beta) |
this <– beta*this + alpha*A*B*C. More... | |
void | AddSpMat (const Real alpha, const SpMatrix< Real > &A, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta) |
this <– beta*this + alpha*SpA*B. More... | |
void | AddTpMat (const Real alpha, const TpMatrix< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta) |
this <– beta*this + alpha*A*B. More... | |
void | AddMatSp (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const SpMatrix< Real > &B, const Real beta) |
this <– beta*this + alpha*A*B. More... | |
void | AddSpMatSp (const Real alpha, const SpMatrix< Real > &A, const MatrixBase< Real > &B, MatrixTransposeType transB, const SpMatrix< Real > &C, const Real beta) |
this <– beta*this + alpha*A*B*C. More... | |
void | AddMatTp (const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const TpMatrix< Real > &B, MatrixTransposeType transB, const Real beta) |
this <– beta*this + alpha*A*B. More... | |
void | AddTpTp (const Real alpha, const TpMatrix< Real > &A, MatrixTransposeType transA, const TpMatrix< Real > &B, MatrixTransposeType transB, const Real beta) |
this <– beta*this + alpha*A*B. More... | |
void | AddSpSp (const Real alpha, const SpMatrix< Real > &A, const SpMatrix< Real > &B, const Real beta) |
this <– beta*this + alpha*A*B. More... | |
void | CopyLowerToUpper () |
Copy lower triangle to upper triangle (symmetrize) More... | |
void | CopyUpperToLower () |
Copy upper triangle to lower triangle (symmetrize) More... | |
void | OrthogonalizeRows () |
This function orthogonalizes the rows of a matrix using the Gram-Schmidt process. More... | |
void | Read (std::istream &in, bool binary, bool add=false) |
stream read. More... | |
void | Write (std::ostream &out, bool binary) const |
write to stream. More... | |
void | LapackGesvd (VectorBase< Real > *s, MatrixBase< Real > *U, MatrixBase< Real > *Vt) |
template<> | |
void | AddVecVec (const float alpha, const VectorBase< float > &ra, const VectorBase< float > &rb) |
template<> | |
void | AddVecVec (const double alpha, const VectorBase< double > &ra, const VectorBase< double > &rb) |
template<> | |
void | AddVecVec (const float alpha, const VectorBase< float > &a, const VectorBase< float > &rb) |
template<> | |
void | AddVecVec (const double alpha, const VectorBase< double > &a, const VectorBase< double > &rb) |
template<> | |
void | CopyFromSp (const SpMatrix< float > &M) |
template<> | |
void | CopyFromSp (const SpMatrix< double > &M) |
Private Member Functions | |
void | Destroy () |
Deallocates memory and sets to empty matrix (dimension 0, 0). More... | |
void | Init (const MatrixIndexT r, const MatrixIndexT c, const MatrixStrideType stride_type) |
Init assumes the current class contents are invalid (i.e. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from MatrixBase< Real > | |
MatrixBase (Real *data, MatrixIndexT cols, MatrixIndexT rows, MatrixIndexT stride) | |
Initializer, callable only from child. More... | |
MatrixBase () | |
Initializer, callable only from child. More... | |
~MatrixBase () | |
Real * | Data_workaround () const |
A workaround that allows SubMatrix to get a pointer to non-const data for const Matrix. More... | |
Protected Attributes inherited from MatrixBase< Real > | |
Real * | data_ |
data memory area More... | |
MatrixIndexT | num_cols_ |
these attributes store the real matrix size as it is stored in memory including memalignment More... | |
MatrixIndexT | num_rows_ |
< Number of columns More... | |
MatrixIndexT | stride_ |
< Number of rows More... | |
A class for storing matrices.
Definition at line 823 of file kaldi-matrix.h.
Matrix | ( | ) |
Empty constructor.
Definition at line 29 of file kaldi-matrix-inl.h.
|
inline |
Basic constructor.
Definition at line 830 of file kaldi-matrix.h.
|
explicit |
Copy constructor from CUDA matrix This is defined in ../cudamatrix/cu-matrix.h.
Definition at line 966 of file cu-matrix.h.
|
explicit |
Constructor from any MatrixBase.
Can also copy with transpose. Allocates new memory.
Definition at line 740 of file kaldi-matrix.cc.
Same as above, but need to avoid default copy constructor.
Definition at line 754 of file kaldi-matrix.cc.
|
explicit |
Copy constructor: as above, but from another type.
Copy constructor from another type.
Definition at line 763 of file kaldi-matrix.cc.
Copy constructor taking SpMatrix...
It is symmetric, so no option for transpose, and NumRows == Cols
Definition at line 864 of file kaldi-matrix.h.
|
explicit |
Constructor from CompressedMatrix.
Definition at line 2062 of file kaldi-matrix.cc.
|
inlineexplicit |
Copy constructor taking TpMatrix...
Definition at line 874 of file kaldi-matrix.h.
|
inline |
Distructor to free matrices.
Definition at line 897 of file kaldi-matrix.h.
|
private |
Deallocates memory and sets to empty matrix (dimension 0, 0).
Definition at line 1128 of file kaldi-matrix.cc.
|
inlineprivate |
Init assumes the current class contents are invalid (i.e.
junk or have already been freed), and it sets the matrix to newly allocated memory with the specified number of rows and columns. r == c == 0 is acceptable. The data memory contents will be undefined.
Definition at line 783 of file kaldi-matrix.cc.
|
inline |
Assignment operator that takes MatrixBase.
Definition at line 917 of file kaldi-matrix.h.
Assignment operator. Needed for inclusion in std::vector.
Definition at line 926 of file kaldi-matrix.h.
read from stream.
Definition at line 1450 of file kaldi-matrix.cc.
Referenced by OnlineUdpInput::Compute(), main(), kaldi::operator>>(), AffineXformStats::Read(), CompressedAffineXformStats::Read(), LogisticRegression::Read(), AccumFullGmm::Read(), LdaEstimate::Read(), Sgmm2FmllrGlobalParams::Read(), AccumDiagGmm::Read(), MleAmSgmm2Accs::Read(), FullGmm::Read(), Plda::Read(), CompressedMatrix::Read(), DiagGmm::Read(), Fmpe::Read(), OnlineGmmAdaptationState::Read(), OnlineCmvnState::Read(), IvectorExtractorStats::Read(), MatrixBase< float >::Read(), CuMatrix< float >::Read(), Matrix< BaseFloat >::Read(), KlHmm::ReadData(), kaldi::ReadKaldiObject(), kaldi::UnitTestCompressedMatrix(), kaldi::UnitTestComputeGPE(), UnitTestEndless1(), UnitTestEndless2(), kaldi::UnitTestIo(), kaldi::UnitTestIoCross(), UnitTestMono22K(), and UnitTestStereo8K().
void RemoveRow | ( | MatrixIndexT | i | ) |
Remove a specified row.
Definition at line 1118 of file kaldi-matrix.cc.
Referenced by FullGmm::Merge(), DiagGmm::Merge(), DiagGmm::RemoveComponent(), FullGmm::RemoveComponent(), and kaldi::UnitTestRemoveRow().
void Resize | ( | const MatrixIndexT | r, |
const MatrixIndexT | c, | ||
MatrixResizeType | resize_type = kSetZero , |
||
MatrixStrideType | stride_type = kDefaultStride |
||
) |
Sets matrix to a specified size (zero is OK as long as both r and c are zero).
The value of the new data depends on resize_type: -if kSetZero, the new data will be zero -if kUndefined, the new data will be undefined -if kCopyData, the new data will be the same as the old data in any shared positions, and zero elsewhere.
You can set stride_type to kStrideEqualNumCols to force the stride to equal the number of columns; by default it is set so that the stride in bytes is a multiple of 16.
This function takes time proportional to the number of data elements.
Definition at line 819 of file kaldi-matrix.cc.
Referenced by DecodableMatrixMappedOffset::AcceptLoglikes(), OnlinePitchFeatureImpl::AcceptWaveform(), LdaEstimate::AddMeanOffset(), kaldi::AddToConfusionMatrix(), DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetSimpleLooped::AdvanceChunk(), kaldi::nnet2::AppendDiscriminativeExamples(), kaldi::AppendFeats(), OnlineDeltaInput::AppendFrames(), kaldi::AppendPostToFeats(), kaldi::AppendVectorToFeats(), kaldi::ApplyPca(), Sgmm2Project::ApplyProjection(), Plda::ApplyTransform(), BatchedXvectorComputer::BatchedXvectorComputer(), AmSgmm2::ComponentLogLikes(), kaldi::ComposeTransforms(), OnlineMatrixInput::Compute(), NnetComputerFromEg::Compute(), OnlineCmnInput::Compute(), DecodableAmNnetParallel::Compute(), OfflineFeatureTpl< F >::Compute(), OnlineUdpInput::Compute(), OnlineLdaInput::Compute(), OnlineDeltaInput::Compute(), OnlineFeInput< E >::Compute(), kaldi::ComputeAmGmmFeatureDeriv(), kaldi::ComputeAndProcessKaldiPitch(), kaldi::ComputeDeltas(), IvectorExtractor::ComputeDerivedVars(), kaldi::ComputeFeatureNormalizingTransform(), Fmpe::ComputeFeatures(), AmSgmm2::ComputeFmllrPreXform(), DecodableNnet2Online::ComputeForFrame(), OnlineCmnInput::ComputeInternal(), kaldi::ComputeKaldiPitch(), kaldi::ComputeKaldiPitchFirstPass(), Sgmm2Project::ComputeLdaTransform(), OnlineLdaInput::ComputeNextRemainder(), kaldi::ComputePca(), AmSgmm2::ComputePerSpkDerivedVars(), Sgmm2Project::ComputeProjection(), kaldi::ComputeShiftedDeltas(), Fmpe::ComputeStddevs(), BasisFmllrEstimate::ComputeTransform(), kaldi::ConcatFeats(), FmllrRawAccs::ConvertToPerRowStats(), CompressedAffineXformStats::CopyFromAffineXformStats(), SvdApplier::DecomposeComponent(), OnlineDeltaInput::DeltaComputation(), DiscriminativeExampleSplitter::DoExcise(), LdaEstimate::Estimate(), FeatureTransformEstimateMulti::Estimate(), FeatureTransformEstimate::EstimateInternal(), kaldi::EstimateIvectorsOnline(), FeatureTransformEstimateMulti::EstimateTransformPart(), kaldi::EstPca(), kaldi::ExtractObjectRange(), kaldi::FilterCompressedMatrixRows(), kaldi::FilterMatrixRows(), FmllrRawAccs::FmllrRawAccs(), Fmpe::Fmpe(), kaldi::nnet2::FormatNnetInput(), NnetBatchComputer::FormatOutputs(), OnlineFeaturePipeline::GetAsMatrix(), OnlineCacheInput::GetCachedData(), FullGmm::GetCovarsAndMeans(), kaldi::GetFeatDeriv(), OnlineCmvn::GetFrame(), LogisticRegression::GetLogPosteriors(), GeneralMatrix::GetMatrix(), FullGmm::GetMeans(), DiagGmm::GetMeans(), IvectorExtractorStats::GetOrthogonalIvectorTransform(), kaldi::GetOutput(), PldaEstimator::GetOutput(), OnlineCmvn::GetState(), DiagGmm::GetVars(), RegtreeFmllrDiagGmm::GetXformMatrix(), AmSgmm2::IncreasePhoneSpaceDim(), kaldi::IncreaseTransformDimension(), AffineXformStats::Init(), LdaEstimate::Init(), OnlineFeaturePipeline::Init(), kaldi::InitCmvnStats(), OnlinePreconditionerSimple::InitDefault(), OnlineNaturalGradientSimple::InitDefault(), kaldi::InitFmllr(), AmSgmm2::InitializeMw(), kaldi::InitIdftBases(), IvectorExtractor::IvectorExtractor(), IvectorExtractorStats::IvectorExtractorStats(), MatrixBase< float >::LapackGesvd(), kaldi::nnet2::LatticeToDiscriminativeExample(), AffineComponent::LimitRank(), DiagGmm::LogLikelihoods(), main(), FullGmm::Merge(), DiagGmm::Merge(), FullGmm::MergePreselect(), kaldi::nnet3::MergeTaskOutput(), MfccComputer::MfccComputer(), LogisticRegression::MixUp(), OnlineLdaInput::OnlineLdaInput(), LimitRankClass::operator()(), kaldi::PosteriorToMatrix(), kaldi::PosteriorToPdfMatrix(), kaldi::ProcessPitch(), AffineXformStats::Read(), kaldi::ReadData(), NnetExampleBackgroundReader::ReadExamples(), kaldi::ReadHtk(), kaldi::nnet3::ReduceRankOfComponents(), DiagGmmNormal::Resize(), FullGmm::Resize(), FullGmmNormal::Resize(), DiagGmm::Resize(), AccumFullGmm::Resize(), AccumDiagGmm::Resize(), Sgmm2PerFrameDerivedVars::Resize(), MleAmSgmm2Accs::ResizeAccumulators(), kaldi::ReverseFrames(), SingleUtteranceNnet2DecoderThreaded::RunNnetEvaluationInternal(), KlHmm::SetStats(), LogisticRegression::SetWeights(), kaldi::SpliceFrames(), OnlineLdaInput::SpliceFrames(), FullGmm::Split(), DiagGmm::Split(), CuMatrix< float >::Swap(), TestSgmm2Fmllr(), LogisticRegression::Train(), kaldi::TransformIvectors(), OnlineLdaInput::TransformToOutput(), kaldi::TypeThreeUsage(), kaldi::UnitTestAddMat2(), kaldi::UnitTestDelay(), UnitTestEstimateSgmm2(), kaldi::UnitTestIo(), UnitTestMleAmDiagGmm(), kaldi::UnitTestPieces(), kaldi::UnitTestResize(), kaldi::UnitTestResizeCopyDataDifferentStrideType(), kaldi::UnitTestTransposeScatter(), and kaldi::nnet2::UpdateHash().
void Swap | ( | Matrix< Real > * | other | ) |
Swaps the contents of *this and *other. Shallow swap.
Definition at line 2255 of file kaldi-matrix.cc.
Referenced by DecodableNnetLoopedOnlineBase::AdvanceChunk(), DecodableNnetSimpleLooped::AdvanceChunk(), OnlineCmnInput::ComputeInternal(), DecodableAmNnet::DecodableAmNnet(), NnetExampleBackgroundReader::GetNextMinibatch(), Matrix< BaseFloat >::Resize(), SingleUtteranceNnet2DecoderThreaded::RunNnetEvaluationInternal(), CuMatrix< float >::Swap(), GeneralMatrix::SwapFullMatrix(), and kaldi::UnitTestIvectorExtractor().
void Swap | ( | CuMatrix< Real > * | mat | ) |
Defined in ../cudamatrix/cu-matrix.cc.
Definition at line 3160 of file cu-matrix.cc.
void Transpose | ( | ) |
Transpose the matrix.
Works for non-square matrices as well as square ones.
Definition at line 2091 of file kaldi-matrix.cc.
Referenced by kaldi::ComputePca(), BasisFmllrEstimate::ComputeTransform(), kaldi::CuVectorUnitTestCopyDiagFromMat(), BasisFmllrEstimate::EstimateFmllrBasis(), kaldi::UnitTestAddDiagVecMat(), kaldi::UnitTestAddMat2Sp(), kaldi::UnitTestAddMatSmat(), kaldi::UnitTestCuMatrixTranspose(), kaldi::UnitTestSymAddMat2(), kaldi::UnitTestTranspose(), kaldi::UnitTestVecmul(), and MlltAccs::Update().