[mlpack-git] [mlpack/mlpack] Added the discretize function. Design changes as discussed. (#703)

Marcus Edel notifications at github.com
Sat Jun 25 18:43:05 EDT 2016


> +// also stores the locations of max values in Location
> +template<typename MatType, typename CubeType>
> +void StructuredForests<MatType, CubeType>::
> +MaxAndLoc(CubeType& mag, arma::umat& Location, MatType& MaxVal) const
> +{
> +  /*Vectorize this function after prototype works*/
> +  MaxVal = MatType(Location.n_rows, Location.n_cols);
> +  for(size_t i = 0; i < mag.n_rows; ++i)
> +  {
> +    for(size_t j = 0; j < mag.n_cols; ++j)
> +    {
> +      /*can use -infinity here*/
> +      double max =  std::numeric_limits<double>::min();
> +      for(size_t k = 0; k < mag.n_slices; ++k)
> +      {
> +        if(mag(i, j, k) > max)

I figured out why it doesn't work on my machine. The check: 

``if(mag(i, j, k) > max)``

doesn't work if mag is [0 0 0] because 0 < double max =  std::numeric_limits<double>::min();.  Since the the location is undefined, we could probably run into an index out of bounds error.

As pointed out here: https://github.com/mlpack/mlpack/pull/696#discussion_r67073948 we should use -DBL_MAX or just use the first value of mag as starting point.

---
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/703/files/987f0790f745314a2117a87f28a346b05a8a2a2d#r68494923
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160625/cfffa943/attachment.html>


More information about the mlpack-git mailing list