david-cortes / isotree

(Python, R, C/C++) Isolation Forest and variations such as SCiForest and EIF, with some additions (outlier detection + similarity + NA imputation)
https://isotree.readthedocs.io
BSD 2-Clause "Simplified" License
186 stars 38 forks source link

Added missing cmath include #40

Closed ankane closed 2 years ago

ankane commented 2 years ago

If you move #include "isotree.hpp" to the top of example/isotree_cpp_ex.cpp and try to compile, it'll error with:

In file included from example/isotree_cpp_ex.cpp:1:
./include/isotree.hpp:133:28: error: use of undeclared identifier 'HUGE_VAL'
    double   range_low  = -HUGE_VAL;
                           ^
./include/isotree.hpp:134:28: error: use of undeclared identifier 'HUGE_VAL'
    double   range_high =  HUGE_VAL;
                           ^
./include/isotree.hpp:155:28: error: use of undeclared identifier 'HUGE_VAL'
    double   range_low  = -HUGE_VAL;
                           ^
./include/isotree.hpp:156:28: error: use of undeclared identifier 'HUGE_VAL'
    double   range_high =  HUGE_VAL;
                           ^
4 errors generated.

This PR adds cmath, where HUGE_VAL is defined: https://en.cppreference.com/w/cpp/numeric/math/HUGE_VAL

david-cortes commented 2 years ago

~Thanks for spotting it. However I'd prefer to include the <cmath> header instead since some users have reported compilation issues when mixing C headers - could you modify it?~ Sorry, had misread math header, now I noticed it already included cmath, merged it.

ankane commented 2 years ago

Great, thanks!