mlpack  master
diagonal_constraint.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_GMM_DIAGONAL_CONSTRAINT_HPP
13 #define MLPACK_METHODS_GMM_DIAGONAL_CONSTRAINT_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace gmm {
19 
24 {
25  public:
27  static void ApplyConstraint(arma::mat& covariance)
28  {
29  // Save the diagonal only.
30  arma::vec diagonal = covariance.diag();
31  covariance = arma::diagmat(diagonal);
32  }
33 
35  template<typename Archive>
36  static void Serialize(Archive& /* ar */, const unsigned int /* version */) { }
37 };
38 
39 } // namespace gmm
40 } // namespace mlpack
41 
42 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: binarize.hpp:18
Force a covariance matrix to be diagonal.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void ApplyConstraint(arma::mat &covariance)
Force a covariance matrix to be diagonal.
static void Serialize(Archive &, const unsigned int)
Serialize the constraint (which holds nothing, so, nothing to do).