StatMech
Loading...
Searching...
No Matches
IntegerComposition_test.cpp File Reference

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)
6 {
7 if(argc != 4) {
8 std::cerr << "Usage: 0.(This) 1.(N) 2.(Length) 3.(Max)\n"
9 << " argc=" << argc << std::endl;
10 std::exit(EXIT_FAILURE);
11 }
12 int const N = std::atoi(argv[1]);
13 int const Length = std::atoi(argv[2]);
14 int const Max = std::atoi(argv[3]);
15
16 IntegerComposition iComp(N, Length, Max);
17 {
18 std::vector<bool> appeared(iComp.dim(), false);
19 for(auto j = 0; j < iComp.dim(); ++j) {
20 std::cout << std::setw(2) << j << ":\t" << iComp.ordinalToPart(j) << " \t";
21 for(auto l = 0; l < iComp.length(); ++l) std::cout << iComp.locNumber(j,l) << " ";
22 std::cout << std::endl;
23
24 if(j != iComp.partToOrdinal(iComp.ordinalToPart(j))) {
25 std::cerr << "Error: "
26 << "j(" << j << ") != iComp.partToOrdinal(iComp.ordinalToPart(" << j
27 << ")))" << std::endl;
28 std::exit(EXIT_FAILURE);
29 }
30 }
31 }
32
33 return EXIT_SUCCESS;
34}
Lists a weak composition of an integer N up to length L with a constraint that each summand does not ...
Definition IntegerComposition.hpp:57