<p>In <a href="https://github.com/mlpack/mlpack/pull/684#discussion_r66616668">src/mlpack/tests/test_tools.hpp</a>:</p>
<pre style='color:#555'>&gt; @@ -35,4 +34,9 @@
&gt;  
&gt;  #endif
&gt;  
&gt; +// Require the approximation L to be within a relative error of E respect to the
&gt; +// actual value R.
&gt; +#define REQUIRE_RELATIVE_ERR( L, R, E ) \
&gt; +    BOOST_REQUIRE_LE( abs((R) - (L)), (E) * (R))
</pre>
<p>This will fail if R is negative.  I think maybe a better choice here is to use the Boost test tools implementation... by default <code>BOOST_REQUIRE_CLOSE()</code> checks both the condition above and also | R - L | &lt;= E * |L|, which works for nearest neighbor search, but not furthest neighbor search (unless you, as an argument, set <code>E = e(1 + e)</code>).  So you could do that, or you could look at <code>boost/test/test_tools.hpp</code> and see how <code>BOOST_REQUIRE_CLOSE</code> is defined, and you can develop a new macro that uses <code>boost::test_tools::check_is_close</code> with the <code>FPC_WEAK</code> comparison type, and I think that would work for what you are doing.</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/pull/684/files/07879a2cc79b35b10d7fae687d6e27ad90a9f2d7#r66616668">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFGRpotI-nkuEkL7D7oEbqU7g2_7tks5qKW0bgaJpZM4IvhJu">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFEk2s0YVi4kXtygBUWiAbFb682ttks5qKW0bgaJpZM4IvhJu.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/684/files/07879a2cc79b35b10d7fae687d6e27ad90a9f2d7#r66616668"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>