<p>I want to set a custom metric to implement periodic boundary condition as</p>
<div class="highlight highlight-source-c++"><pre><span class="pl-k">class</span> <span class="pl-en">PeriodicMetric</span> : <span class="pl-k">public</span> <span class="pl-en">mlpack</span>::metric::LMetric<<span class="pl-c1">2</span>, <span class="pl-c1">true</span>> {
<span class="pl-k">public:</span>
<span class="pl-en">PeriodicMetric</span>() {}
<span class="pl-k">template </span><<span class="pl-k">typename</span> VecTypeA, <span class="pl-k">typename</span> VecTypeB>
<span class="pl-k">static</span> <span class="pl-k">double</span> <span class="pl-en">Evaluate</span>(<span class="pl-k">const</span> VecTypeA &x, <span class="pl-k">const</span> VecTypeB &y) {
arma::vec::fixed<<span class="pl-c1">2</span>> d = x - y;
<span class="pl-c">// Take into account the periodic boundary condition.</span>
<span class="pl-k">double</span> tmp1, tmp2;
<span class="pl-k">for</span> (<span class="pl-k">int</span> i = <span class="pl-c1">0</span>; i < <span class="pl-c1">2</span>; i++) {
tmp1 = <span class="pl-c1">fabs</span>(d[i]);
tmp2 = <span class="pl-c1">1</span> - tmp1; <span class="pl-c">// Axis span is 1 in this case.</span>
<span class="pl-k">if</span> (tmp1 > tmp2) {
d[i] = d[i] > <span class="pl-c1">0</span> ? -tmp2 : tmp2;
}
}
<span class="pl-k">return</span> <span class="pl-c1">sqrt</span>(<span class="pl-c1">dot</span>(d, d));
}
};</pre></div>
<p>When I used it with RangeSearch class, the compiler complains:</p>
<pre><code>.../mlpack/core/tree/hrectbound.hpp:59:3: error: static assertion failed: HRectBound can only be used with the LMetric<> metric type.
static_assert(meta::IsLMetric<MetricType>::Value == true,
^~~~~~~~~~~~~
</code></pre>
<p>I have commented that static_assert in <code>mlpack/core/tree/hrectbound.hpp</code> and everything is fine.</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/issues/744">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJ4bFN-GrjrRPLhQXWi3qsnNw8tymdgNks5qaufrgaJpZM4JYvK8">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFGYbub1vbvYatSRlc_BkjhfMCR0kks5qaufrgaJpZM4JYvK8.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/744"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>