[mlpack-git] [mlpack/mlpack] Universal B tree implementation (#746)

Ryan Curtin notifications at github.com
Wed Aug 17 20:49:41 EDT 2016


> +  ElemType lower, higher;
> +
> +  for (size_t i = 0; i < numBounds; i++)
> +  {
> +    ElemType sum = 0;
> +
> +    for (size_t d = 0; d < dim; d++)
> +    {
> +      lower = loBound(d, i) - point[d];
> +      higher = point[d] - hiBound(d, i);
> +
> +      // Since only one of 'lower' or 'higher' is negative, if we add each's
> +      // absolute value to itself and then sum those two, our result is the
> +      // nonnegative half of the equation times two; then we raise to power Power.
> +      sum += pow((lower + fabs(lower)) + (higher + fabs(higher)),
> +          (ElemType) MetricType::Power);

You can save a little bit of computation here if you terminate early:

```
if (sum >= minSum)
  continue;
```

-- 
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/pull/746/files/8c5a97dcb1641ae6c98edc70426fb19f5cd7cb79#r75233467
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160817/288c92d1/attachment.html>


More information about the mlpack-git mailing list