[mlpack-git] [mlpack/mlpack] static_assert about IsLMetric is too restrictive (#744)
Li Dong
notifications at github.com
Sat Jul 30 01:58:03 EDT 2016
I want to set a custom metric to implement periodic boundary condition as
```c++
class PeriodicMetric : public mlpack::metric::LMetric<2, true> {
public:
PeriodicMetric() {}
template <typename VecTypeA, typename VecTypeB>
static double Evaluate(const VecTypeA &x, const VecTypeB &y) {
arma::vec::fixed<2> d = x - y;
// Take into account the periodic boundary condition.
double tmp1, tmp2;
for (int i = 0; i < 2; i++) {
tmp1 = fabs(d[i]);
tmp2 = 1 - tmp1; // Axis span is 1 in this case.
if (tmp1 > tmp2) {
d[i] = d[i] > 0 ? -tmp2 : tmp2;
}
}
return sqrt(dot(d, d));
}
};
```
When I used it with RangeSearch class, the compiler complains:
```
.../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,
^~~~~~~~~~~~~
```
I have commented that static_assert in `mlpack/core/tree/hrectbound.hpp` and everything is fine.
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/744
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160729/67230670/attachment.html>
More information about the mlpack-git
mailing list