<p>I noticed that the test <code>RandomizedSVDTest/RandomizedSVDReconstructionError</code> is sometimes failing.  It's straightforward to reproduce:</p>

<ol>
<li>Add <code>math::RandomSeed(std::time(NULL))</code> to the top of the test in <code>randomized_svd_test.cpp</code>.</li>
<li>Rebuild <code>mlpack_test</code> and run as <code>while(true); do bin/mlpack_test -t RandomizedSVDTest; sleep 1; done</code>
</li>
<li>Wait a few trials and it will probably fail.  On my system it fails maybe 10% of the time.</li>
</ol>

<p>I see that the first several lines of the test appear to be written in order to carefully generate a positive definite non-square matrix, with singular values [1 0.1 0.01].  But it seems as though the singular values are not preserved when the matrix is centered.  If I add the following code:</p>

<pre><code>std::cout &lt;&lt; "data: " &lt;&lt; arma::svd(data).t();
std::cout &lt;&lt; "centered data: " &lt;&lt; arma::svd(centeredData).t();
</code></pre>

<p>Then I get output like this when I run the test:</p>

<pre><code>Running 1 test case...
data:    1.0000   0.1000   0.0100
centered data:    2.5269e-01   3.5332e-02   5.7466e-17

warning: lu(): decomposition failed

error: matrix multiplication: incompatible matrix dimensions: 10x3 and 0x0
unknown location(0): fatal error in "RandomizedSVDReconstructionError": std::logic_error: matrix multiplication: incompatible matrix dimensions: 10x3 and 0x0

*** 1 failure detected in test suite "mlpackTest"
</code></pre>

<p>It doesn't look much different when it's not failing:</p>

<pre><code>Running 1 test case...
data:    1.0000   0.1000   0.0100
centered data:    9.7937e-01   9.7828e-02   5.3800e-17
</code></pre>

<p>Is it possible the data centering operation needs to be changed or ignored altogether?  I haven't thought about it in much detail since it is late right now... <a href="https://github.com/zoq" class="user-mention">@zoq</a>, any ideas here?  You originally wrote this code so maybe you have a quick fix. :)</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/issues/783">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFPfnjJQyS647B4-4pWG9IiP1GWglks5qp2qGgaJpZM4J8XbC">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFA-8KYdeainVL0-nmQyFJEUIPHJyks5qp2qGgaJpZM4J8XbC.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/783"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/mlpack/mlpack","title":"mlpack/mlpack","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/mlpack/mlpack"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"RandomizedSVD tests sometimes have failing LU decomposition (#783)"}],"action":{"name":"View Issue","url":"https://github.com/mlpack/mlpack/issues/783"}}}</script>