Example program to test permutations (JTOOLS::next_permutation).
More...
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <algorithm>
#include "JTools/JPermutation.hh"
#include "JMath/JMathToolkit.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
Example program to test permutations (JTOOLS::next_permutation).
- Author
- mdejong
Definition in file JPermutation.cc.
◆ main()
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 22 of file JPermutation.cc.
32 JParser<> zap(
"Example program to test permutations.");
40 catch(
const exception &error) {
41 FATAL(error.what() << endl);
48 if (N > buffer.size()) {
49 FATAL(
"Number of elements " << N <<
" > " << buffer.size() << endl);
52 sort(buffer.begin(), buffer.end(), less<int>());
66 DEBUG(
'[' << setw(3) <<
n <<
']');
69 DEBUG(
' ' << setw(3) << *i);
75 data.rbegin()->insert(*i);
81 DEBUG(
' ' << setw(3) << *i);
96 NOTICE(
"number of permutations " <<
n <<
' ' <<
factorial(buffer.size(), N) << endl);
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
long long int factorial(const long long int n)
Determine factorial.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.