[mlpack-git] [mlpack/mlpack] backported ind2sub and sub2ind. (#683)

stereomatchingkiss notifications at github.com
Thu Jun 9 11:06:21 EDT 2016


> @@ -0,0 +1,85 @@
> +/**
> + * @file feature_extraction.hpp
> + * @author Nilay Jain 
> + *
> + * Feature Extraction for the edge_boxes algorithm.
> + */
> +#ifndef MLPACK_METHODS_EDGE_BOXES_STRUCTURED_TREE_HPP
> +#define MLPACK_METHODS_EDGE_BOXES_STRUCTURED_TREE_HPP
> +#define INF 999999.9999
> +#define EPS 1E-20
> +#include <mlpack/core.hpp>

a : If possible, please do not use macro/pre-processor, they have many defects.

1 : they do not respect scope. 
2 : debug message is hard to read
3 : Not type safe

So, do we have a better choice?Yes, we have
it is constexpr, this keyword tell the compiler, I know this const value at compile time
so you could declare it as 

```
constexpr double inf = 999999.9999;
constexpr double eps = 1e-20;
```
constexpr respect scope, compiler will give you better error message rather than show you "1e-20" or "99999.99999"

b : If possible, could you place the eps in your class rather than put it in global namespace?

c : c++11 provide [standard infinity value f](http://en.cppreference.com/w/cpp/types/numeric_limits/infinity)or us

`double inf = std::numeric_limits<double>::infinity();`

Very cool, right?

---
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/683/files/9d85b64c6c6bdff608331195351d09abf56cfc96#r66458858
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160609/bcaad458/attachment.html>


More information about the mlpack-git mailing list