22 #ifndef __MLPACK_METHODS_GMM_EIGENVALUE_RATIO_CONSTRAINT_HPP
23 #define __MLPACK_METHODS_GMM_EIGENVALUE_RATIO_CONSTRAINT_HPP
49 if (std::abs(ratios[0] - 1.0) > 1e-20)
50 Log::Fatal <<
"EigenvalueRatioConstraint::EigenvalueRatioConstraint(): "
51 <<
"first element of ratio vector is not 1.0!" << std::endl;
53 for (
size_t i = 1; i < ratios.n_elem; ++i)
56 Log::Fatal <<
"EigenvalueRatioConstraint::EigenvalueRatioConstraint(): "
57 <<
"element " << i <<
" of ratio vector is greater than 1.0!"
60 Log::Warn <<
"EigenvalueRatioConstraint::EigenvalueRatioConstraint(): "
61 <<
"element " << i <<
" of ratio vectors is negative and will "
62 <<
"probably cause the covariance to be non-invertible..."
73 arma::vec eigenvalues;
74 arma::mat eigenvectors;
75 arma::eig_sym(eigenvalues, eigenvectors, covariance);
81 eigenvalues = (eigenvalues[0] *
ratios);
84 covariance = eigenvectors * arma::diagmat(eigenvalues) * eigenvectors.t();
void ApplyConstraint(arma::mat &covariance) const
Apply the eigenvalue ratio constraint to the given covariance matrix.
static util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
const arma::vec & ratios
Ratios for eigenvalues.
EigenvalueRatioConstraint(const arma::vec &ratios)
Create the EigenvalueRatioConstraint object with the given vector of eigenvalue ratios.
static util::PrefixedOutStream Warn
Prints warning messages prefixed with [WARN ].
Given a vector of eigenvalue ratios, ensure that the covariance matrix always has those eigenvalue ra...