<p>I thought about this, but I would just have made a setter method. How often do you change covariance?Would this be ok?</p>

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

// Recalculate covariance.
arma::mat newCovariance(g.Covariance().n_rows, g.Covariance().n_cols);
newCovariance.zeros();
for (size_t i = 0; i &lt; numPoints; ++i)
  newCovariance += x.col(i) * x.col(i).t(); // Or something like that.

// Set and factorize newCovariance
g.Covariance(std::move(newCovariance));
</code></pre>

<p>No un-necessary copy, but needs un-necessary storage.  Forcing the user to call <code>InvertCovariance()</code> is too error prone IMO. </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-70345147">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFFgI5qMapJQOw2KFi_sG0RNL79Vfks5niaaOgaJpZM4DTh9A.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-70345147"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>