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

Marcus Edel notifications at github.com
Sun Aug 14 11:48:32 EDT 2016


> +void StructuredForests<MatType, CubeType>::
> +DistanceTransform1D(const arma::vec& f, const size_t n, const double inf,
> +                    arma::vec& d)
> +{
> +  arma::vec v(n), z(n + 1);
> +  d = arma::vec(n);
> +  size_t k = 0;
> +  v[0] = 0.0;
> +  z[0] = -inf;
> +  z[1] = inf;
> +  for (size_t q = 1; q <= n - 1; ++q)
> +  {
> +    float s  = ( (f[q] + q * q)-( f[v[k]] + v[k] * v[k]) ) / (2 * q - 2 * v[k]);
> +    while (s <= z[k])
> +    {
> +      --k;

I'm not sure, but if we set k = 0 at the beginning, how can we decrease k (``size_t``), and still get the right index?

-- 
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/72eb1ef22c7db1ea33af3de1cd043cdb277ec562#r74704105
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160814/9322d43e/attachment.html>


More information about the mlpack-git mailing list