LatNet Builder Manual 2.1.3-6
Software Package for Constructing Highly Uniform Point Sets
|
This class implements a generating matrix of a digital net in base 2. More...
#include <GeneratingMatrix.h>
Public Types | |
typedef boost::dynamic_bitset | Row |
Type for the rows of the matrices. | |
typedef Row::reference | reference |
Type for references to rows. | |
typedef unsigned long | uInteger |
Type for unsigned long. |
Public Member Functions | |
GeneratingMatrix (unsigned int nRows=0, unsigned int nCols=0) | |
Constructs a generating matrix with all entries set to zero. | |
GeneratingMatrix (unsigned int nRows, unsigned int nCols, std::vector< uInteger > init) | |
Constructs a generating matrix with rows initialized using the given integers. | |
unsigned int | nCols () const |
Returns the number of columns of the matrix. | |
unsigned int | nRows () const |
Returns the number of rows of the matrix. | |
void | resize (unsigned int nRows, unsigned int nCols) |
Resizes the matrix to the given shape. | |
bool | operator() (unsigned int i, unsigned j) const |
Returns the element at position i , j of the matrix. | |
reference | operator() (unsigned int i, unsigned int j) |
Returns a reference to the element at position i , j of the matrix. | |
void | flip (unsigned int i, unsigned int j) |
Flip the element at at position i , j of the matrix. | |
Row | operator[] (unsigned int i) const |
Returns the row at position i of the matrix. | |
Row & | operator[] (unsigned int i) |
Returns a reference to the row at position i of the matrix. | |
GeneratingMatrix | upperLeftSubMatrix (unsigned int nRows, unsigned int nCols) const |
Returns the upper-left submatrix with nRows rows and nCols columns. | |
GeneratingMatrix | subMatrix (unsigned int startingRow, unsigned int startingCol, unsigned nRows, unsigned nCols) const |
Returns the submatrix with upper-left corner at position startingRow , startingCol with nRows rows and nCols columns. | |
GeneratingMatrix | operator* (const GeneratingMatrix &m) const |
Computes the product of the matrix by matrix m . | |
void | swapRows (unsigned int i1, unsigned int i2) |
Swap the rows at position i1 and i2 of the matrix. | |
void | stackRight (const GeneratingMatrix &block) |
Extends the matrix by stacking on the right the matrix block . | |
void | stackBelow (GeneratingMatrix block) |
Extends the matrix by stacking below the matrix block . | |
std::string | formatToColumnsReverse (unsigned int nBits=31) const |
std::vector< unsigned long > | getColsReverse () const |
Returns an integer representation of the columns of the matrix. |
Static Public Member Functions | |
static GeneratingMatrix | fromColsReverse (unsigned int nInputBits, unsigned int nOutputRows, std::vector< unsigned long > columns) |
Creates a matrix from its reversed column representation. | |
template<typename RAND> | |
static GeneratingMatrix | createRandomLowerTriangularMatrix (unsigned int nRows, unsigned int nCols, RAND &randomGen) |
Creates a matrix with ones on the main diagonal, random bits below the main diagonal, and zeros above. |
Friends | |
std::ostream & | operator<< (std::ostream &os, const GeneratingMatrix &mat) |
Overloads of << operator to print matrices. |
This class implements a generating matrix of a digital net in base 2.
Internally, a matrix is represented as a std::vector
of rows implemented by boost::dynamic_bitset
. This internal representation allows to work with arbitrarly large matrices. The choice of representing the matrix by its rows and not its columns comes from the rank computation algorithm, which is the most complicated algorithm handling matrices in the software. For this algorithm, it is more convenient to handle matrices by rows.
For now, we did not implement an algorithm to compute directly the points generated by a given matrix. However, the Stride associated with a matrix, i.e. the permutation of \({i/n, 0 <= i <= n}\), is computed in latbuilder/Storage-SIMPLE-DIGITAL.h. For more information, see Section 4.3.2 of Maxime’s report (https://github.com/umontreal-simul/latnetbuilder/blob/dev/reports/report_godin.pdf), and the documentation of netbuilder/DigitalNet.n.
NetBuilder::GeneratingMatrix::GeneratingMatrix | ( | unsigned int | nRows = 0, |
unsigned int | nCols = 0 ) |
Constructs a generating matrix with all entries set to zero.
nRows | Number of rows. |
nCols | Number of columns. |
References nCols(), and nRows().
Referenced by createRandomLowerTriangularMatrix(), fromColsReverse(), operator*(), operator<<, stackBelow(), stackRight(), subMatrix(), and upperLeftSubMatrix().
NetBuilder::GeneratingMatrix::GeneratingMatrix | ( | unsigned int | nRows, |
unsigned int | nCols, | ||
std::vector< uInteger > | init ) |
Constructs a generating matrix with rows initialized using the given integers.
The elements of a row are the binary digits of the corresponding integer, with the least significant bit on the left.
nRows | Number of rows. |
nCols | Number of columns. |
init | Vector of uInteger of length nRows |
|
inlinestatic |
Creates a matrix with ones on the main diagonal, random bits below the main diagonal, and zeros above.
This is done by sampling one unsigned long integer for each row, so it works only if the number of columns is smaller than the number of bits of an unsigned long (usually 32).
nRows | Number of rows of the matrix. |
nCols | Number of columns of the matrix. |
randomGen | Random Number Generator. By default it is the LFSR258 generator by L'Ecuyer [18]. |
References GeneratingMatrix(), nCols(), and nRows().
void NetBuilder::GeneratingMatrix::flip | ( | unsigned int | i, |
unsigned int | j ) |
Flip the element at at position i
, j
of the matrix.
i | Row index. |
j | Column index. |
|
static |
Creates a matrix from its reversed column representation.
nInputRows | Number of bits in the integer representation of the columns. Typically equals 31. |
nOutputRows | Number of rows of the matrix returned by the function. Rows below are ignored. Typically equals the number of columns. |
columns | Integer representation of the columns of the matrix. |
References GeneratingMatrix().
std::vector< unsigned long > NetBuilder::GeneratingMatrix::getColsReverse | ( | ) | const |
Returns an integer representation of the columns of the matrix.
A column is read as a bit string with highest bit in first position. This function is used to generate the points from the digital net.
reference NetBuilder::GeneratingMatrix::operator() | ( | unsigned int | i, |
unsigned int | j ) |
Returns a reference to the element at position i
, j
of the matrix.
i | Row index. |
j | Column index. |
bool NetBuilder::GeneratingMatrix::operator() | ( | unsigned int | i, |
unsigned | j ) const |
Returns the element at position i
, j
of the matrix.
i | Row index. |
j | Column index. |
GeneratingMatrix NetBuilder::GeneratingMatrix::operator* | ( | const GeneratingMatrix & | m | ) | const |
Computes the product of the matrix by matrix m
.
m | Right multiplier. |
References GeneratingMatrix().
Row & NetBuilder::GeneratingMatrix::operator[] | ( | unsigned int | i | ) |
Returns a reference to the row at position i
of the matrix.
i | Position of the row. |
Row NetBuilder::GeneratingMatrix::operator[] | ( | unsigned int | i | ) | const |
Returns the row at position i
of the matrix.
i | Position of the row. |
void NetBuilder::GeneratingMatrix::resize | ( | unsigned int | nRows, |
unsigned int | nCols ) |
void NetBuilder::GeneratingMatrix::stackBelow | ( | GeneratingMatrix | block | ) |
Extends the matrix by stacking below the matrix block
.
block | The matrix to stack. Should have the same number of columns as the base matrix. |
References GeneratingMatrix().
void NetBuilder::GeneratingMatrix::stackRight | ( | const GeneratingMatrix & | block | ) |
Extends the matrix by stacking on the right the matrix block
.
block | The matrix to stack. Should have the same number of rows as the base matrix. |
References GeneratingMatrix().
GeneratingMatrix NetBuilder::GeneratingMatrix::subMatrix | ( | unsigned int | startingRow, |
unsigned int | startingCol, | ||
unsigned | nRows, | ||
unsigned | nCols ) const |
Returns the submatrix with upper-left corner at position startingRow
, startingCol
with nRows
rows and nCols
columns.
startingRow | Row position of the upper-left corner. |
startingCol | Column position of the upper-left corner. |
nRows | Number of rows. |
nCols | Number of columns. |
References GeneratingMatrix(), nCols(), and nRows().
Referenced by NetBuilder::FigureOfMerit::ResolutionGapProjMerit< EmbeddingType::MULTILEVEL >::operator()(), and NetBuilder::FigureOfMerit::ResolutionGapProjMerit< EmbeddingType::UNILEVEL >::operator()().
void NetBuilder::GeneratingMatrix::swapRows | ( | unsigned int | i1, |
unsigned int | i2 ) |
Swap the rows at position i1 and i2 of the matrix.
i1 | Position of the first row. |
i2 | Position of the second row. |
GeneratingMatrix NetBuilder::GeneratingMatrix::upperLeftSubMatrix | ( | unsigned int | nRows, |
unsigned int | nCols ) const |
Returns the upper-left submatrix with nRows
rows and nCols
columns.
nRows | Number of rows. |
nCols | Number of columns. |
References GeneratingMatrix(), nCols(), and nRows().