<p>This is related to <a href="https://github.com/mlpack/mlpack/issues/215" class="issue-link" title="GMM::Classify() is slow">#215</a>.</p>

<p>There is a slight issue with making this change: what happens to this code?</p>

<pre><code>GaussianDistribution g(mean, covariance); // This factorizes 'covariance'.
g.Covariance() = newCovariance; // The new covariance isn't factorized.
</code></pre>

<p>It's easy enough to change the signature...</p>

<pre><code>GaussianDistribution g(mean, covariance); // This factorizes 'covariance'.
g.Covariance(newCovariance); // This re-factorizes 'covariance'.
</code></pre>

<p>but now I can't make simple changes to the covariance while avoiding matrix copies.  So this code becomes impossible:</p>

<pre><code>GaussianDistribution g(mean, covariance); // This factorizes 'covariance'.
// Recalculate covariance.
g.Covariance().zeros();
for (size_t i = 0; i &lt; numPoints; ++i)
  g.Covariance() += x.col(i) * x.col(i).t(); // Or something like that.
</code></pre>

<p>Maybe the better API solution is to leave <code>GaussianDistribution::Covariance()</code> intact, allowing direct access to the covariance matrix, but make a note that if the covariance matrix is modified, the user <em>must</em> call something like <code>GaussianDistribution::InvertCovariance()</code> or whatever after the modification is done, or <code>Probability()</code> will return incorrect results.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/issues/385#issuecomment-70336533">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFMOpPOpuskKLN5gEvxnbHyeeTBchks5niY8wgaJpZM4DTh9A.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/mlpack/mlpack/issues/385#issuecomment-70336533"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>