This assertion is checked only in the INDEX_CHECKS compilation mode.
Either a reference to a container whose lifetime is not shorter than that of the permutation object, or a "bare" container type for a temporary object. See also the detailed discussion.
Either a functor class satisfying the extended requirements for binary operations, or an untyped template of such a class wrapped into BuildBinary or BuildBinaryIt (preferably expressed via the convenience typedef from namespace polymake::operations.
This is a convenience function, which allows to embed a temporary object into an expression without writing down its exact type. The result is identical to a direct call to the constructor of the corresponding class with the same arguments.
Please note that this and similar convenience functions always create an object parameterized with references to the input data (containers.) Sometimes, especially in a function return statement, you will need a reference-less variant; then you have to use the constructor.
Either a functor class satisfying the extended requirements for unary operations, or an untyped template of such a class wrapped into BuildUnary or BuildUnaryIt (preferably expressed via the convenience typedef from namespace polymake::operations.

There is a little collection of enumeration algorithms generating objects of some class in a systematic manner. They are implemented as pseudo-containers, so that you can browse through the class exactly the same you would visit all elements of a standard list.

## Permutations

class AllPermutations;

The "source" of all permutations of a fixed length. The elements are permutations of the integer sequence [0..n).

The Heap's generating algorithm is used (see Heap, B.R., "Permutations by Interchanges," Computer Journal 6 (1963) pp. 293-294), the implementation follows the suggestion of R. Sedgewick. This algorithm guarantees that each two consecutive permutations differ by interchanging exactly one pair of elements. This implies that the permutations in the sequence have alternating evenness.

### Prerequisits

    #include <permutations.h>
    using namespace polymake;

### Construction

AllPermutations(int n); AllPermutations all_permutations(int n);

### Miscellaneous tools dealing with permutations

template <typename Permutation> int permutation_sign(const Permutation& perm);
Returns 1 if the permutation is even, -1 if odd. perm is assumed to contain integer numbers from [0..n).
template <typename Permutation, typename InvPermutation> void inverse_permutation(const Permutation& perm, InvPermutation& inv_perm);
Fills inv_perm with the permutation inverse to perm.
template <typename Container1, typename Container2> Array<int> find_permutation(const Container1& c1, const Container2& c2); throw (no_match); template <typename Container1, typename Container2, typename Comparator> Array<int> find_permutation(const Container1& c1, const Container2& c2, const Comparator& comparator); throw (no_match);
Finds a permutation of indices @c{ [0 .. c1.size()) } which would make c1 equal to c2. Raises an exception if no such permutation exists (due to different container sizes or an unmatched element).
The first variant uses the default comparison functor operations::cmp, the second one allows to use a non-standard comparator.
template <typename PermutationRef, typename Element=int> class PermutationMatrix; template <typename Element, typename Permutation> PermutationMatrix<const Permutation&, Element> permutation_matrix(const Permutation& perm);
Create a temporary sparse matrix equal to a unary matrix with columns permuted according to perm. The template parameter Element specifies the apparent type of the matrix elements; it must be specified explicitly in the convenience function call, as it can't be deduced from its argument.

## Integral points in a cuboid

template <bool left_to_right=true, typename Element=int> class MultiDimCounter;

The MultiDimCounter is a bidirectional iterator, yielding all integral points in a d-dimensional cuboid. The points are represented by Array<int> objects.

The template parameter left_to_right determines whether coordinate [0] or [d-1] is the least significant (that is, changes first.) Default is true, where the counter is read from left to right and the element [0] is the least significant.

Element is the coordinate type.

MultiDimCounter implements the resettable and end-sensitive interfaces, as well as several special methods described further.

### Prerequisits

    #include <MultiDimCounter.h>
    using namespace polymake;

### Construction

template <typename Container> MultiDimCounter(const Container& limits);
limits are the exclusive upper limits for coordinates in each dimension. The lower limits are assumed to be all zeroes.
template <typename Container1, typename Container2> MultiDimCounter(const Container1& start, const Container2& limits);
The same as above, but with arbitrary inclusive lower limits (start values).

### Modification

MultiDimCounter::operator++ (); MultiDimCounter::operator-- ();
Moves to the next integral point. The least significant digit (as specified by left_to_right) changes first.
template <typename Container> void set(const Container& values);
Moves the iterator to the given integral point.
New values must lie in the intervals set up during the construction.
void set_digit(int digit, Element value);
Sets the specified coordinate to the given value.
The new value must lie in the interval set up during the construction.

## Facets of a cube

template <typename Element> class CubeFacets;

This is a list of all facets of a d-dimensional cube. The facets are represented combinatorially as sets of vertex indices, the vertices are enumerated contiguously (usually from 0 to 2d-1.) During the iteration the facets do not appear in lexicographical order.

Template parameter Element specifies the type of the vertex indices. For dimensions less than the machine word size (for example, 32 on an usual PC), it can be safely chosen as int.

CubeFacets implements the forward container interface; it is a virtual container, producing its elements "on the fly" just when they are needed.

### Prerequisits

    #include <CubeFacets.h>
    using namespace polymake::polytope;

### Construction

CubeFacets(int dim, Element start=0); dim is the cube dimension, start is the index of the first vertex.