LatNet Builder Manual 2.1.3-6
Software Package for Constructing Highly Uniform Point Sets
Loading...
Searching...
No Matches
NetBuilder::GeneratingMatrix Class Reference

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.
Rowoperator[] (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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ GeneratingMatrix() [1/2]

NetBuilder::GeneratingMatrix::GeneratingMatrix ( unsigned int nRows = 0,
unsigned int nCols = 0 )

Constructs a generating matrix with all entries set to zero.

Parameters
nRowsNumber of rows.
nColsNumber of columns.

References nCols(), and nRows().

Referenced by createRandomLowerTriangularMatrix(), fromColsReverse(), operator*(), operator<<, stackBelow(), stackRight(), subMatrix(), and upperLeftSubMatrix().

◆ GeneratingMatrix() [2/2]

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.

Parameters
nRowsNumber of rows.
nColsNumber of columns.
initVector of uInteger of length nRows

References nCols(), and nRows().

Member Function Documentation

◆ createRandomLowerTriangularMatrix()

template<typename RAND>
GeneratingMatrix NetBuilder::GeneratingMatrix::createRandomLowerTriangularMatrix ( unsigned int nRows,
unsigned int nCols,
RAND & randomGen )
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).

Parameters
nRowsNumber of rows of the matrix.
nColsNumber of columns of the matrix.
randomGenRandom Number Generator. By default it is the LFSR258 generator by L'Ecuyer [18].

References GeneratingMatrix(), nCols(), and nRows().

◆ flip()

void NetBuilder::GeneratingMatrix::flip ( unsigned int i,
unsigned int j )

Flip the element at at position i, j of the matrix.

Parameters
iRow index.
jColumn index.

◆ fromColsReverse()

GeneratingMatrix NetBuilder::GeneratingMatrix::fromColsReverse ( unsigned int nInputBits,
unsigned int nOutputRows,
std::vector< unsigned long > columns )
static

Creates a matrix from its reversed column representation.

Parameters
nInputRowsNumber of bits in the integer representation of the columns. Typically equals 31.
nOutputRowsNumber of rows of the matrix returned by the function. Rows below are ignored. Typically equals the number of columns.
columnsInteger representation of the columns of the matrix.

References GeneratingMatrix().

◆ getColsReverse()

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.

◆ operator()() [1/2]

reference NetBuilder::GeneratingMatrix::operator() ( unsigned int i,
unsigned int j )

Returns a reference to the element at position i, j of the matrix.

Parameters
iRow index.
jColumn index.

◆ operator()() [2/2]

bool NetBuilder::GeneratingMatrix::operator() ( unsigned int i,
unsigned j ) const

Returns the element at position i, j of the matrix.

Parameters
iRow index.
jColumn index.

◆ operator*()

GeneratingMatrix NetBuilder::GeneratingMatrix::operator* ( const GeneratingMatrix & m) const

Computes the product of the matrix by matrix m.

Parameters
mRight multiplier.

References GeneratingMatrix().

◆ operator[]() [1/2]

Row & NetBuilder::GeneratingMatrix::operator[] ( unsigned int i)

Returns a reference to the row at position i of the matrix.

Parameters
iPosition of the row.

◆ operator[]() [2/2]

Row NetBuilder::GeneratingMatrix::operator[] ( unsigned int i) const

Returns the row at position i of the matrix.

Parameters
iPosition of the row.

◆ resize()

void NetBuilder::GeneratingMatrix::resize ( unsigned int nRows,
unsigned int nCols )

Resizes the matrix to the given shape.

Potential new elements are set to zero.

Parameters
nRowsis the new number of rows of the matrix
nColsis the new number of columns of the matrix

References nCols(), and nRows().

◆ stackBelow()

void NetBuilder::GeneratingMatrix::stackBelow ( GeneratingMatrix block)

Extends the matrix by stacking below the matrix block.

Parameters
blockThe matrix to stack. Should have the same number of columns as the base matrix.

References GeneratingMatrix().

◆ stackRight()

void NetBuilder::GeneratingMatrix::stackRight ( const GeneratingMatrix & block)

Extends the matrix by stacking on the right the matrix block.

Parameters
blockThe matrix to stack. Should have the same number of rows as the base matrix.

References GeneratingMatrix().

◆ subMatrix()

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.

Parameters
startingRowRow position of the upper-left corner.
startingColColumn position of the upper-left corner.
nRowsNumber of rows.
nColsNumber of columns.
Returns
A copy of the submatrix.

References GeneratingMatrix(), nCols(), and nRows().

Referenced by NetBuilder::FigureOfMerit::ResolutionGapProjMerit< EmbeddingType::MULTILEVEL >::operator()(), and NetBuilder::FigureOfMerit::ResolutionGapProjMerit< EmbeddingType::UNILEVEL >::operator()().

◆ swapRows()

void NetBuilder::GeneratingMatrix::swapRows ( unsigned int i1,
unsigned int i2 )

Swap the rows at position i1 and i2 of the matrix.

Parameters
i1Position of the first row.
i2Position of the second row.

◆ upperLeftSubMatrix()

GeneratingMatrix NetBuilder::GeneratingMatrix::upperLeftSubMatrix ( unsigned int nRows,
unsigned int nCols ) const

Returns the upper-left submatrix with nRows rows and nCols columns.

Parameters
nRowsNumber of rows.
nColsNumber of columns.
Returns
A copy of the submatrix.

References GeneratingMatrix(), nCols(), and nRows().


The documentation for this class was generated from the following file: