diff --git a/CMakeLists.txt b/CMakeLists.txt index 9041051..f25a296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,26 +2,9 @@ cmake_minimum_required(VERSION 2.8) project(discreture) option(BUILD_TESTS "Build test programs" ON) # Probably should leave it like this - -# Set to ON in order to compile with clang instead of GCC. According to tests, -# Clang is faster for: -# Combinations, -# Partitions, -# Dyck Paths -# Motzkin Paths. -# -# GCC is faster for: -# subsets -# permutations. -# Set Partitions -# -# See readme for more details and actual benchmarks. If you really want speed, though, -# you probably want to test on your own, since usually the bottleneck will be your own code, -# as iterating through 600 million combinations and doing nothing takes a couple of seconds, -# but what you actually do with each of those could take a LOT more. - option(USE_CLANG "Use CLANG to build" OFF) + set(CMAKE_LIBRARY_DIR ${CMAKE_SOURCE_DIR}/lib) set(CMAKE_BINARY_DIR ${CMAKE_LIBRARY_DIR}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) @@ -51,11 +34,9 @@ add_definitions(-Ofast -march=native) add_library(discreture SHARED Sequences.cpp Subsets.cpp Vectorhelpers.cpp Probability.cpp) message("Installing to " ${CMAKE_INSTALL_PREFIX}) -install(TARGETS discreture - LIBRARY DESTINATION lib) +install(TARGETS discreture LIBRARY DESTINATION lib) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.hpp") - if(BUILD_TESTS) add_executable(testdiscreture main.cpp Tests.cpp) target_link_libraries(testdiscreture discreture) diff --git a/README.md b/README.md index dd26bc0..48f733d 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,7 @@ Within this library, one can construct a few combinatorial objects, such as: All follow the same design principle: The templated class is calles basic_SOMETHING, and the most reasonable type for T is instantiated as SOMETHING. For example, `combinations` is a typedef of `basic_combinations`, and `partitions` is a typedef of `basic_partitions`. -# Advanced use +# Basic usage Although the full reference is in the doxygen documentation, here is a quick preview. Remember to always `#include ` and either add `using namespace dscr;` or add `dscr::` to everything.): @@ -115,6 +115,10 @@ std::partition_point(X.begin(), X.end(), predicate); ``` where `predicate` is a unary predicate that takes a `const vector&` as an argument and returns true or false, in a way that for all the first combinations it returns true and the last ones return false. This would do binary search. +## Combinations find_if and find_all +Combinations is the most mature part of the library, so the following functions have been implemented: + + # Benchmarks. ## Vs GSL. diff --git a/Tests.cpp b/Tests.cpp index b3353d4..ffa354b 100644 --- a/Tests.cpp +++ b/Tests.cpp @@ -365,9 +365,11 @@ void testCombinationsSpeed(int n, int k) cout << "Time taken to see all (" << n << " choose " << k << ") = " << X.size() << " combinations in reverse order: " << C.Reset() << "s" << endl; combinations Z(24,12); + size_t zi = 0; for (auto& z : Z) { - + if (z[3] == 1) + ++zi; } cout << "Time taken to see all (" << 24 << " choose " << 12 << ") = " << Z.size() << " combinations: " << C.Reset() << "s" << endl; }