12 #ifndef MLPACK_METHODS_GMM_POSITIVE_DEFINITE_CONSTRAINT_HPP 13 #define MLPACK_METHODS_GMM_POSITIVE_DEFINITE_CONSTRAINT_HPP 44 arma::eig_sym(eigval, eigvec, covariance);
50 if ((eigval[0] < 0.0) || ((eigval[eigval.n_elem - 1] / eigval[0]) > 1e5) ||
51 (eigval[eigval.n_elem - 1] < 1e-50))
56 const double minEigval = std::max(eigval[eigval.n_elem - 1] / 1e5, 1e-50);
57 for (
size_t i = 0; i < eigval.n_elem; ++i)
58 eigval[i] = std::max(eigval[i], minEigval);
61 covariance = eigvec * arma::diagmat(eigval) * eigvec.t();
66 template<
typename Archive>
67 static void Serialize(Archive& ,
const unsigned int ) { }
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void ApplyConstraint(arma::mat &covariance)
Apply the positive definiteness constraint to the given covariance matrix, and ensure each value on t...
static void Serialize(Archive &, const unsigned int)
Serialize the constraint (which stores nothing, so, nothing to do).
Given a covariance matrix, force the matrix to be positive definite.