diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1661636 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +CMakeLists.txt.user + diff --git a/CMakeLists.txt b/CMakeLists.txt index 577503a..840802f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,20 @@ else() message("doxygen not found") endif() +############################################################################## +# C++11 support +############################################################################## +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +if(COMPILER_SUPPORTS_CXX11) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +elseif(COMPILER_SUPPORTS_CXX0X) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +else() + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Some functionality will not be available.") +endif() + ############################################################################## # MSVC-specific settings ############################################################################## diff --git a/include/andres/marray.hxx b/include/andres/marray.hxx index 229ec3d..44ef0b1 100644 --- a/include/andres/marray.hxx +++ b/include/andres/marray.hxx @@ -79,6 +79,7 @@ #define MARRAY_HXX #include +#include #include // runtime_error #include #include diff --git a/include/andres/ml/decision-trees.hxx b/include/andres/ml/decision-trees.hxx index 7c8d8d9..eb6b94c 100644 --- a/include/andres/ml/decision-trees.hxx +++ b/include/andres/ml/decision-trees.hxx @@ -786,7 +786,8 @@ DecisionForest::learn( const size_t numberOfDecisionTrees ) { typedef std::default_random_engine RandomEngine; - learn(features, labels, numberOfDecisionTrees, RandomEngine()); + RandomEngine randomEngine; + learn(features, labels, numberOfDecisionTrees, randomEngine); } /// Learns a decision forest from labeled samples as described by Breiman (2001). diff --git a/src/unittest/ml/test-decision-trees.cxx b/src/unittest/ml/test-decision-trees.cxx index 4157583..8363a4c 100644 --- a/src/unittest/ml/test-decision-trees.cxx +++ b/src/unittest/ml/test-decision-trees.cxx @@ -16,7 +16,7 @@ int main() { // define random feature matrix std::default_random_engine RandomNumberGenerator; typedef double Feature; - std::uniform_int_distribution randomDistribution(0.0, 1.0); + std::uniform_real_distribution randomDistribution(0.0, 1.0); const size_t shape[] = {numberOfSamples, numberOfFeatures}; andres::Marray features(shape, shape + 2); for(size_t sample = 0; sample < numberOfSamples; ++sample)