Skip to content

Commit

Permalink
Some last minute fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mraggi committed Aug 20, 2016
1 parent af1a487 commit 5dd9657
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
23 changes: 2 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<class T>, and the most reasonable type for T is instantiated as SOMETHING. For example, `combinations` is a typedef of `basic_combinations<int>`, and `partitions` is a typedef of `basic_partitions<int>`.

# Advanced use
# Basic usage

Although the full reference is in the doxygen documentation, here is a quick preview. Remember to always `#include <discreture.hpp>` and either add `using namespace dscr;` or add `dscr::` to everything.):

Expand Down Expand Up @@ -115,6 +115,10 @@ std::partition_point(X.begin(), X.end(), predicate);
```
where `predicate` is a unary predicate that takes a `const vector<int>&` 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.
Expand Down
4 changes: 3 additions & 1 deletion Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5dd9657

Please sign in to comment.