LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
pfqn_comb_common.h File Reference

Integer-composition enumeration shared by the CoMoM and MVAC ports. More...

#include <cstddef>
#include <vector>
#include "line/util/error.h"
Include dependency graph for pfqn_comb_common.h:

Go to the source code of this file.

Namespaces

namespace  line
namespace  line::pfqn

Functions

std::vector< std::vector< int > > line::pfqn::multichoose_rows (int n, int k)
 All n-vectors of nonnegative integers summing to k, in MATLAB multichoose(n,k) order.
int line::pfqn::matchrow (const std::vector< std::vector< int > > &rows, const std::vector< int > &row)
 Position of row in rows, or -1 when absent.
void line::pfqn::sort_by_nnz_pos (std::vector< std::vector< int > > &I)
 MATLAB's sortbynnzpos: a stable bubble sort putting the rows with FEWER nonzeros first and, among rows with equally many, the row whose leftmost differing entry is nonzero first.

Detailed Description

Integer-composition enumeration shared by the CoMoM and MVAC ports.

Templated-free helpers mirroring matlab/src/util/multichoose.m and matlab/src/util/matchrow.m. Both are pure index arithmetic on integers, so they carry no number type at all and are usable from any instantiation.

ORDERING MATTERS. MATLAB's multichoose(n,k) recurses as

for i = 0:k, rows = [ i , multichoose(n-1, k-i) ]

so the first component ascends slowest. Several callers (pfqn_comom's basis layout, pfqn_mvac's multiplicity list) index into the result by position rather than by content, and a different but equally valid enumeration order would silently permute their bases. The recursion is reproduced verbatim rather than replaced by a "nicer" odometer.

line::multichoose in util/population.h returns the COUNT C(n+k-1,k); multichoose_rows here returns the compositions themselves. The names are kept distinct so that a call site cannot pick up the wrong one.

Definition in file pfqn_comb_common.h.