<commit_before>/**
 * @file gaussian_distribution.cpp
 * @author <NAME>
 * @author <NAME>
 *
 * Implementation of Gaussian distribution class.
 */
#include "gaussian_distribution.hpp"

using namespace mlpack;
using namespace mlpack::distribution;


GaussianDistribution::GaussianDistribution(const arma::vec& mean,
                                           const arma::mat& covariance)
  : mean(mean)
{
  Covariance(covariance);
}

void GaussianDistribution::Covariance(const arma::mat& covariance)
{
  this->covariance = covariance;
  FactorCovariance();
}

void GaussianDistribution::Covariance(arma::mat&& covariance)
{
  this->covariance = std::move(covariance);
  FactorCovariance();
}

void GaussianDistribution::FactorCovariance()
{
  covLower = arma::chol(covariance, "lower");

  // Comment from rcurtin:
  //
  // I think the use of the word "interpret" in the Armadillo documentation<commit_msg>Properly handle old Armadillo versions. Pre-4.500 doesn't have arguments to chol().<commit_after>/**
 * @file gaussian_distribution.cpp
 * @author <NAME>
 * @author <NAME>
 *
 * Implementation of Gaussian distribution class.
 */
#include "gaussian_distribution.hpp"

using namespace mlpack;
using namespace mlpack::distribution;


GaussianDistribution::GaussianDistribution(const arma::vec& mean,
                                           const arma::mat& covariance)
  : mean(mean)
{
  Covariance(covariance);
}

void GaussianDistribution::Covariance(const arma::mat& covariance)
{
  this->covariance = covariance;
  FactorCovariance();
}

void GaussianDistribution::Covariance(arma::mat&& covariance)
{
  this->covariance = std::move(covariance);
  FactorCovariance();
}

void GaussianDistribution::FactorCovariance()
{
  // On Armadillo < 4.500, the "lower" option isn't available.
  #if (ARMA_VERSION_MAJOR < 4) || \
      ((ARMA_VERSION_MAJOR == 4) && (ARMA_VERSION_MINOR < 500))
    covLower = arma::chol(covariance).t(); // This is less efficient.
  #else
    covLower = arma::chol(covariance, "lower");
  #endif

  // Comment from rcurtin:
  //
  // I think the use of the word "interpret" in the Armadillo documentation
{'fraction_non_alphanumeric': 0.12453183520599251, 'fraction_numerical': 0.006086142322097378, 'mean_word_length': 4.1493975903614455, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5036953', 'n_tokens_mistral': 713, 'n_tokens_neox': 625, 'n_words': 154}