14 #ifndef __MLPACK_METHODS_GMM_POSITIVE_DEFINITE_CONSTRAINT_HPP 15 #define __MLPACK_METHODS_GMM_POSITIVE_DEFINITE_CONSTRAINT_HPP 46 arma::eig_sym(eigval, eigvec, covariance);
52 if ((eigval[0] < 0.0) || ((eigval[eigval.n_elem - 1] / eigval[0]) > 1e5) ||
53 (eigval[eigval.n_elem - 1] < 1e-50))
58 const double minEigval = std::max(eigval[eigval.n_elem - 1] / 1e5, 1e-50);
59 for (
size_t i = 0; i < eigval.n_elem; ++i)
60 eigval[i] = std::max(eigval[i], minEigval);
63 covariance = eigvec * arma::diagmat(eigval) * eigvec.t();
68 template<
typename Archive>
69 static void Serialize(Archive& ,
const unsigned int ) { }
Linear algebra utility functions, generally performed on matrices or vectors.
static void ApplyConstraint(arma::mat &covariance)
Apply the positive definiteness constraint to the given covariance matrix, and ensure each value on t...
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
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.