[mlpack-git] [mlpack/mlpack] Vantage point tree and HRectBound improvements (#760)

Ryan Curtin notifications at github.com
Sat Aug 13 10:09:49 EDT 2016


>    }
>  
>    // Now take the Power'th root (but make sure our result is squared if it needs
>    // to be); then cancel out the constant of 2 (which may have been squared now)
>    // that was introduced earlier.  The compiler should optimize out the if
>    // statement entirely.
> -  if (MetricType::TakeRoot)
> -    return (ElemType) pow((double) sum, 1.0 / (double) MetricType::Power) / 2.0;
> +  if (MetricType::Power == 1)
> +    return sum * 0.5;
> +  else if (MetricType::Power == 2)
> +  {
> +    if (MetricType::TakeRoot)
> +      return std::sqrt(sum) * 0.5;

I believe the casts to double were done because `std::pow(double, int)` was not available on all systems. It looks like an overload of `std::sqrt()` is available that takes any integral type as input, but returns `double`, so you would have to cast the result back to `ElemType`. It appears that the same comments now apply about `std::pow` since C++11.

-- 
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/760/files/8e6223ce9cbc05b5cb68e6f4e7a96d8cb41bf5ff..55e15792e4dc2135c6e3421c5dae1322d07b0dcc#r74687398
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160813/dd2bc600/attachment.html>


More information about the mlpack-git mailing list