|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Combinatorics helpers in Aleph-w (ah-comb.H): transpose, Cartesian products, combinations.
More...
#include <iostream>#include <iomanip>#include <string>#include <tclap/CmdLine.h>#include <htlist.H>#include <ah-comb.H>Go to the source code of this file.
Functions | |
| void | print_section (const string &title) |
| void | print_subsection (const string &title) |
| template<typename T > | |
| void | print_list (const string &label, const DynList< T > &l) |
| template<typename T > | |
| void | print_matrix (const string &label, const DynList< DynList< T > > &mat) |
| void | demo_transpose () |
| void | demo_permutations () |
| void | demo_perm_predicates () |
| void | demo_traverse () |
| void | demo_fold () |
| void | demo_build () |
| void | demo_practical () |
| int | main (int argc, char *argv[]) |
Combinatorics helpers in Aleph-w (ah-comb.H): transpose, Cartesian products, combinations.
This example demonstrates combinatorics utilities from ah-comb.H, including:
In this file, the "permutations" demos are about Cartesian products of lists (choose one element from each list), not the classic factorial n! permutations.
This example uses TCLAP and supports selecting one section:
--section / -s <section>: one of transpose, perm, predicates, traverse, fold, build, practical, all (default).--help: show help.n×m matrix-like structure: O(n*m)O(∏ n_i) outputs (can be exponential)O(C(n, k)) outputsDefinition in file comb_example.C.
| void demo_build | ( | ) |
Definition at line 361 of file comb_example.C.
References Aleph::DynList< T >::append(), Aleph::build_perms(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), print_section(), print_subsection(), and Aleph::HTList::size().
Referenced by main().
| void demo_fold | ( | ) |
Definition at line 331 of file comb_example.C.
References Aleph::DynList< T >::append(), Aleph::fold_perm(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), print_section(), print_subsection(), and Aleph::product().
Referenced by main().
| void demo_perm_predicates | ( | ) |
Definition at line 224 of file comb_example.C.
References Aleph::all_perm(), Aleph::DynList< T >::append(), Aleph::exists_perm(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), Aleph::none_perm(), print_section(), print_subsection(), and Aleph::sum().
Referenced by main().
| void demo_permutations | ( | ) |
Definition at line 165 of file comb_example.C.
References Aleph::DynList< T >::append(), Aleph::count(), Aleph::for_each_perm(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), Aleph::perm_count(), print_section(), and print_subsection().
Referenced by main().
| void demo_practical | ( | ) |
Definition at line 400 of file comb_example.C.
References Aleph::DynList< T >::append(), Aleph::for_each_perm(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), Aleph::perm_count(), print_section(), and print_subsection().
Referenced by main().
| void demo_transpose | ( | ) |
Definition at line 132 of file comb_example.C.
References Aleph::DynList< T >::append(), Aleph::in_place_transpose(), Aleph::maps(), print_matrix(), print_section(), print_subsection(), and Aleph::transpose().
Referenced by main().
| void demo_traverse | ( | ) |
Definition at line 287 of file comb_example.C.
References Aleph::DynList< T >::append(), LocateFunctions< Container, Type >::get_it(), Aleph::maps(), print_section(), print_subsection(), Aleph::sum(), and Aleph::traverse_perm().
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 450 of file comb_example.C.
References demo_build(), demo_fold(), demo_perm_predicates(), demo_permutations(), demo_practical(), demo_transpose(), demo_traverse(), and Aleph::maps().
Definition at line 96 of file comb_example.C.
References LocateFunctions< Container, Type >::get_it(), l, and Aleph::maps().
| void print_matrix | ( | const string & | label, |
| const DynList< DynList< T > > & | mat | ||
| ) |
Definition at line 110 of file comb_example.C.
References LocateFunctions< Container, Type >::get_it(), and Aleph::maps().
Referenced by demo_transpose().
| void print_section | ( | const string & | title | ) |
Definition at line 83 of file comb_example.C.
References Aleph::maps().
Referenced by demo_build(), demo_fold(), demo_perm_predicates(), demo_permutations(), demo_practical(), demo_transpose(), and demo_traverse().
| void print_subsection | ( | const string & | title | ) |
Definition at line 90 of file comb_example.C.
References Aleph::maps().
Referenced by demo_build(), demo_fold(), demo_perm_predicates(), demo_permutations(), demo_practical(), demo_transpose(), and demo_traverse().