G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsCombinatorics.h File Reference

Provides combinatorial unitilies. More...

+ Include dependency graph for gsCombinatorics.h:

Go to the source code of this file.

Namespaces

 gismo
 The G+Smo namespace, containing all definitions for the library.
 

Functions

template<typename Z >
binomial (const Z n, const Z r)
 Computes the binomial expansion coefficient binomial(n,r) More...
 
template<unsigned n, unsigned r>
unsigned binomial ()
 Returns binomial(n,r) as a compile time constant. More...
 
void binomial_into (unsigned n, gsVector< unsigned > &v)
 Returns a vector containing all the binomials (n,r) with n fixed. More...
 
template<typename Z , int d>
void cubeIsometry (const gsVector< bool, d > &flip, const gsVector< index_t, d > &perm, gsVector< Z > &result)
 Computes the isometry of the unit d-cube implied by a permutation perm of the cube directions plus a relocation flip of the cube vertices. More...
 
template<int d>
void cubeIsometryMatrix (const gsVector< bool, d > &flip, const gsVector< index_t, d > &perm, gsMatrix< int, d, d > &result)
 Computes the rotation matrix implied by a permutation perm of the cube directions plus a relocation flip. More...
 
template<class Vec >
index_t dimCubeElement (const Vec &cur)
 Returns the dimension of an element (face) of the d-cube [0,1]^d. The element is expected to contain 0,1 (corresponding to cube extrema) and the special value 2 at the position of "free" coordinates.
 
unsigned factorial (unsigned n)
 Returns the factorial of n i.e. n! Remember that factorial grow too fast and only n! with n<=13 can be stored in a 32bit that is an unsigned.
 
template<class Vec >
void firstCombination (const unsigned n, const unsigned r, Vec &res)
 Computes the first r-combination of {0,..,n-1}.
 
template<class Vec >
void firstComposition (typename Vec::Scalar sum, index_t dim, Vec &res)
 Construct first composition of sum into dim integers.
 
template<class Vec >
void firstCubeElement (Vec &cur, const index_t k=0)
 Updates cur to contain the lexicographically first element (face) of the cube [0,1]^d of dimension k. For k==d the face (2..2) is returned, corresponding to the cube itself.
 
template<class Vec , class Mat >
void firstMultiComposition (const Vec &a, index_t k, Mat &res)
 Constructs first multi-composition of a = (a_1,..,a_d) into k integers.
 
template<class Vec >
void firstPermutation (Vec &current)
 changes current to the first permutation of 0 ... size(current)-1 note that you must resize the vector to specify the number of elements
 
template<class Vec >
bool nextCombination (Vec &v, const unsigned n)
 Computes the next r-combination of {0,..,n-1}, where r = v.size(). The input v is expected to be a valid combination.
 
template<class Vec >
bool nextComposition (Vec &v)
 Returns (inplace) the next composition in lexicographic order.
 
template<class Vec >
bool nextCubeBoundary (Vec &cur, const Vec &start, const Vec &end)
 Iterates in lex-order through the boundary points of the cube [start,end]. Updates cur with the current point and returns true if another point is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeBoundaryOffset (Vec &cur, const Vec &start, const Vec &end, Vec &offset)
 Iterates in lex-order through the boundary points of the cube [start,end], with an \ offset to the interior. Updates cur with the current point and returns true if another point is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeBoundaryOffset (Vec &cur, const Vec &start, const Vec &end, Vec &loffset, Vec &uoffset)
 Iterates in lex-order through the boundary points of the cube [start,end], with offset loffset from \ start and roffset .from the end. Updates cur with the current point and returns true if another point is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeElement (Vec &cur, const index_t k)
 Iterates in lexicographic order through the elements (faces) of dimension k of the cube [0,1]^d. Updates cur with the current element (face) and returns true if another element (face) of dimension k is available. Coordinates with value 2 indicate free/not-fixed dimensions.
 
template<class Vec >
bool nextCubePoint (Vec &cur, const Vec &end)
 Iterate in lexigographic order through the points of the integer lattice contained in the cube [0,end]. Updates cur with the current point and returns true if another point is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubePoint (Vec &cur, const Vec &start, const Vec &end)
 Iterates in lexigographic order through the points of the integer lattice contained in the cube [start,end]. Updates cur with the current point and returns true if another point is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeVertex (Vec &cur, const Vec &start, const Vec &end)
 Iterate in lexicographic order through the vertices of the cube [start,end]. Updates cur with the current vertex and returns true if another vertex is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeVertex (Vec &cur, const Vec &end)
 Iterate in lexicographic order through the vertices of the cube [0,end]. Updates cur with the current vertex and returns true if another vertex is available. Cube may be degenerate.
 
template<class Vec >
bool nextCubeVertex (Vec &cur)
 Iterate in lexigographic order through the vertices of the unit cube. Updates cur with the lexicographically next vertex and returns true if another point is available. This is equivalent to iterating over all possible binary sequences of length cur.size(). The input cur is expected to contain only zeros and ones (or true/false).
 
template<class Vec >
bool nextLexicographic (Vec &cur, const Vec &size)
 Iterates through a tensor lattice with the given size. Updates cur and returns true if another entry was available End values (size) are not included in the enumerated points, as with iterators.
 
template<class Vec >
bool nextLexicographic (Vec &cur, const Vec &start, const Vec &end)
 Iterate through a tensor lattice with the given start and end points. end coordinates are not included in the enumerated points, as with iterators. Updates cur and returns true if another entry was available.
 
template<class Mat >
bool nextMultiComposition (Mat &m)
 Returns (inplace) the next multi-composition in lexicographic order. More...
 
template<class Vec >
bool nextPermutation (Vec &current)
 Changes current to the next lexicographically ordered permutation. More...
 
unsigned numCompositions (int sum, short_t dim)
 Number of compositions of sum into dim integers.
 
index_t numCubeElements (const index_t k, const index_t d)
 Returns the number of elements (faces) of dimension k of a d-cube.
 
template<class Vec >
unsigned numMultiCompositions (const Vec &a, index_t k)
 Number of multi-composition of a = (a_1,..,a_d) into k integers.
 
template<class Vec >
Vec stridesOf (const Vec &sz)
 Computes the of a vector.
 

Detailed Description

Provides combinatorial unitilies.

This file is part of the G+Smo library.

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Author(s): A. Bressan, A. Mantzaflaris