<p>In <a href="https://github.com/mlpack/mlpack/pull/650#discussion_r65364427">src/mlpack/tests/split_data_test.cpp</a>:</p>
<pre style='color:#555'>> @@ -41,6 +41,22 @@ void CompareData(const mat& inputData,
> }
> }
>
> +void CheckMatEqual(const mat& inputData,
> + const mat& compareData)
> +{
> + const mat& sortedInput = arma::sort(inputData, "ascend", 1);
> + const mat& sortedCompare = arma::sort(compareData, "ascend", 1);
> + for (size_t i = 0; i < sortedInput.n_cols; ++i)
> + {
> + const mat& lhsCol = sortedInput.col(i);
> + const mat& rhsCol = sortedCompare.col(i);
> + for (size_t j = 0; j < lhsCol.n_rows; ++j)
> + {
> + BOOST_REQUIRE_CLOSE(lhsCol(j), rhsCol(j), 1e-5);
</pre>
<p>This can fail for very small values, I like to use</p>
<pre><code>if (std::abs(rhsCol(j)) < 1e-5)
BOOST_REQUIRE_SMALL(lhsCol(j), 1e-5);
else
BOOST_REQUIRE_CLOSE(lhsCol(j), rhsCol(j), 1e-5);
</code></pre>
<p>This is a nice utility function that we could probably use, though. Actually now that I am thinking about it more... I wonder what would be necessary for us to be able to write <code>BOOST_REQUIRE_CLOSE(lhs, rhs, 1e-5)</code> and get the comparison here? I dunno if that is worth taking the time to figure out though :)</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<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/pull/650/files/8ad3b900bba6c8535ad94b5af31aaab1de0c64d1#r65364427">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFIo1vxgdNEP4oDQc2QDB2ycWedHCks5qHY-_gaJpZM4IneDD">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFMDnrQzrWQGmZqzSiIA13tCDW-VBks5qHY-_gaJpZM4IneDD.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/pull/650/files/8ad3b900bba6c8535ad94b5af31aaab1de0c64d1#r65364427"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>