Lattice Tester Online Documentation 0.1.0-861
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
|
This subclass of IntLatticeExt
defines a general rank 1 lattice rule in \(d\) dimensions, whose points \(\mathbb{u}_i\) are defined by.
More...
#include <latticetester/Rank1Lattice.h>
Public Member Functions | |
Rank1Lattice (const Int &m, const IntVec &aa, NormType norm=L2NORM) | |
This constructor takes as input the modulus m , the generating vector aa , and the norm used to measure the vector lengths. | |
Rank1Lattice (const Int &m, const Int &a, int64_t maxDim, NormType norm=L2NORM) | |
Constructor for the special case of a Korobov lattice. | |
Rank1Lattice (const Int &m, int64_t maxDim, NormType norm=L2NORM) | |
This constructor does not specify the generating vector. | |
Rank1Lattice (const Rank1Lattice< Int, Real > &Lat) | |
Copy constructor. | |
Rank1Lattice & | operator= (const Rank1Lattice< Int, Real > &Lat) |
Assigns Lat to this object. | |
~Rank1Lattice () | |
Destructor. | |
void | setaa (const IntVec &aa) |
Sets the generating vector to aa . | |
void | seta (const Int &a) |
Sets this lattice to a Korobov lattice with multiplier a . | |
void | buildBasis (int64_t dim) |
Builds a basis in dim dimensions. | |
void | buildDualBasis (int64_t dim) |
Builds only an m-dual lower triangular basis (and not the primal) directly in dim dimensions. | |
void | incDimBasis () |
Increases the current dimension of the primal basis by 1 and updates the basis. | |
void | incDimDualBasis () |
Increases the current dimension of only the m-dual basis by 1. | |
void | buildProjection (IntLattice< Int, Real > &projLattice, const Coordinates &proj) override |
This method overrides its namesake in IntLattice . | |
void | buildProjectionDual (IntLattice< Int, Real > &projLattice, const Coordinates &proj) override |
Similar to buildProjection , but builds a basis for the m-dual of the projection. | |
std::string | toStringCoef () const |
Returns the first dim components of the generating vector \(\ba\) as a string, where dim is the current lattice dimension. | |
Public Member Functions inherited from LatticeTester::IntLatticeExt< Int, Real > | |
IntLatticeExt (Int m, int64_t maxDim, NormType norm=L2NORM) | |
A constructor that initializes the primal and dual bases with the identity matrix. | |
IntLatticeExt (const IntLatticeExt< Int, Real > &lat) | |
Copy constructor that makes a copy of lat . | |
void | copy (const IntLatticeExt< Int, Real > &lat) |
Makes a copy of lattice into this object. | |
virtual | ~IntLatticeExt () |
Destructor. | |
virtual std::string | toString () const |
Returns a string describing this lattice. | |
Public Member Functions inherited from LatticeTester::IntLattice< Int, Real > | |
IntLattice (const Int m, const int64_t maxDim, NormType norm=L2NORM) | |
Constructs a lattice whose basis is the identity, in maxDim dimensions, with the specified norm type, and the scaling factor m . | |
IntLattice (const IntMat basis, const Int m, const int64_t maxDim, NormType norm=L2NORM) | |
Similar to the previous constructor, except that the primal basis is given in basis , which must be an IntMat object of size maxDim by maxDim . | |
IntLattice (const IntMat primalbasis, const IntMat dualbasis, const Int m, const int64_t maxDim, NormType norm=L2NORM) | |
Constructs a lattice with the given basis and given m-dual basis for the given m , in maxDim dimensions, and with the specified norm type. | |
IntLattice (const IntLattice< Int, Real > &lat) | |
Copy constructor. | |
virtual | ~IntLattice () |
Destructor. | |
void | copyLattice (const IntLattice< Int, Real > &lat) |
Makes a deep copy of the lattice lat into this (existing) object. | |
void | overwriteLattice (const IntLattice< Int, Real > &lat, long dim, long dimdual) |
virtual void | buildProjectionLLL (IntLattice< Int, Real > &projLattice, const Coordinates &proj, double delta=0.5) |
Constructs a set of generating vectors for the projection of the present lattice, over the set of coordinates determined by proj , and builds a basis for that projection using an LLL procedure from BasisConstruction . | |
IntMat & | getBasis () |
Returns the IntMat object that contains the basis of this lattice. | |
void | setBasis (const IntMat basis, const Int m, const int64_t dim, NormType norm=L2NORM) |
Changes the basis to 'basis', the modulus to 'm', and the current dimension to 'dim'. | |
void | setBasis (const IntMat basis, const int64_t dim) |
Changes only the 'basis' and the current dimension to 'dim'. | |
IntMat & | getDualBasis () |
Returns the m-dual basis represented in a matrix. | |
int64_t | getMaxDim () const |
Returns the maximal dimension for this lattice. | |
int64_t | getDim () const |
Returns the current dimension of the primal lattice, which is the dimension of the basis vectors, and also usually the number of independent vectors in the basis. | |
int64_t | getDimDual () const |
Returns the current dimension of the m-dual lattice. | |
NormType | getNormType () const |
Returns the NormType used by this lattice. | |
Real | getVecNorm (const int64_t &i) |
Returns the norm (squared in case of the L^2 norm) of the i-th vector of the basis, with the index i starting at 0. | |
RealVec | getVecNorm () const |
Returns the norm (squared in case of the L^2 norm) of each basis vector, in a vector. | |
Real | getDualVecNorm (const int64_t &i) |
Returns the norm (squared in case of the L^2 norm) of the i-th vector of the m-dual basis. | |
RealVec | getDualVecNorm () const |
Returns the norm (squared in case of the L^2 norm) of each vector of the m-dual basis, in a vector. | |
Int | getModulus () const |
Returns the scaling factor m . | |
void | setDim (const int64_t dim) |
Sets the dimension of the primal basis to dim . | |
void | setDimDual (const int64_t dim) |
Sets the dimension of the primal basis to dim . | |
void | setNormType (const NormType &norm) |
Sets the NormType used by this lattice to norm . | |
void | setVecNorm (const Real &value, const int64_t &i) |
Sets the norm of the i -th component of the basis to value , which is assumed to be the correct value. | |
void | setDualVecNorm (const Real &value, const int64_t &i) |
Sets the norm of the i -th component of the m-dual basis to value , which is assumed to be the correct value. | |
void | setNegativeNorm () |
Sets to -1 the first dim values in the array containing the norms of the basis vectors, where dim is the current dimension of the lattice. | |
void | setNegativeNorm (const int64_t &i) |
Sets the value of the i -th component in the array containing the norms of the basis vectors to -1. | |
void | setDualNegativeNorm () |
Sets all the values in the array containing the norms of the dual basis vectors to -1, to indicate that these norms are no longer up to date. | |
void | setDualNegativeNorm (const int64_t &i) |
Sets the value of the i -th component in the array containing the norms of the m-dual basis vectors to -1. | |
void | updateVecNorm () |
Updates the array containing the norms of the basis vectors by recomputing them. | |
void | updateVecNorm (const int64_t &d) |
Updates the array containing the norm of the basis vectors from the d -th component to the last, by recomputing them. | |
void | updateSingleVecNorm (const int64_t &d, const int64_t &c) |
Updates the 'd'-th entry of the array containing the basis vectors norms. | |
void | updateDualVecNorm () |
Updates the array containing the m-dual basis vectors norms by recomputing them. | |
void | updateSingleDualVecNorm (const int64_t &d, const int64_t &c) |
Updates the 'd'-th entry of the array containing the m-dual basis vectors norms. | |
void | updateDualVecNorm (const int64_t &d) |
Updates the array containing the m-dual basis vectors norms from the d -th component to the last by recomputing them. | |
void | updateDualVecNorm (const int64_t &d, const int64_t &c) |
Updates the array containing the m-dual basis vectors norms from the d -th component to the last by recomputing them. | |
void | updateScalL2Norm (const int64_t i) |
Updates the i -th value of the array containing the square norms of the basis vectors by recomputing it using the L2NORM . | |
void | updateScalL2Norm (const int64_t k1, const int64_t k2) |
Updates the k1 -th to the k2-1 -th values of the array containing the square norms of the basis vectors by recomputing them using the L2NORM . | |
void | updateDualScalL2Norm (const int64_t i) |
Updates the i -th value of the array containing the square norms of the m-dual basis vectors by recomputing it using the L2NORM . | |
void | updateDualScalL2Norm (const int64_t k1, const int64_t k2) |
Updates the k1 -th to the k2-1 -th values of the array containing the square norms of the m-dual basis vectors by recomputing them using the L2NORM . | |
void | permute (int64_t i, int64_t j) |
Exchanges vectors i and j in the basis. | |
void | permuteDual (int64_t i, int64_t j) |
Exchanges vectors i and j in the m -dual basis without changing the primal. | |
void | dualize () |
Exchanges the primal and m-dual bases, their dimensions, and vector norms. | |
bool | checkDuality () |
Returns true iff the m-dual basis contained in the object really is the m-dual of the current primal basis. | |
void | sortBasis (int64_t d) |
Sorts the primal basis vectors with indices greater of equal to d by increasing length. | |
void | sortDualBasis (int64_t d) |
Sorts the m -dual basis vectors with indices greater of equal to d by increasing length. | |
std::string | toStringBasis () const |
Returns a string that contains the primal basis vectors and their norms. | |
std::string | toStringDualBasis () const |
Returns a string with the m -dual basis vectors and their norms. | |
std::string | toString () const |
Returns a string that represents this lattice and its parameters. | |
void | write () const |
Writes on standard output the string returned by toString . | |
Protected Attributes | |
IntVec | m_a |
Vector of multipliers (generating vector) of the rank 1 lattice rule. | |
Protected Attributes inherited from LatticeTester::IntLattice< Int, Real > | |
Int | m_modulo |
The scaling factor m used for rescaling the lattice. | |
int64_t | m_maxDim |
The maximal dimension for this lattice. | |
int64_t | m_dim |
The current dimension of the primal basis, which is the number of (independent) vectors in it. | |
int64_t | m_dimdual |
The current dimension of the m-dual basis, which is the number of (independent) vectors in its basis. | |
IntMat | m_basis |
The rows of the m_dim x m_dim upper left corner of this matrix are the primal basis vectors. | |
IntMat | m_dualbasis |
The rows of the m_dim x m_dim upper left corner this matrix are the m-dual basis vectors. | |
NormType | m_norm |
The NormType used to measure the vector lengths for this lattice. | |
RealVec | m_vecNorm |
A vector that stores the norm of each basis vector. | |
RealVec | m_dualvecNorm |
Similar to vecNorm, but for the m-dual basis. | |
Additional Inherited Members | |
Protected Member Functions inherited from LatticeTester::IntLatticeExt< Int, Real > | |
virtual void | kill () |
This subclass of IntLatticeExt
defines a general rank 1 lattice rule in \(d\) dimensions, whose points \(\mathbb{u}_i\) are defined by.
\begin{equation} \mathbf{u}_i = (i \mathbf{a} \mod m)/m, \end{equation}
where \(\mathbf{a} = (a_1,a_2,\dots,a_d) \in \mathbb{Z}_m^d\) is called the generating vector. The lattice is rescaled simply by removing the division by \(m\). Given \(\mathbf{a}\), a basis of the rescaled (integer) lattice is given by
\begin{align*} \mathbf{v}_1 & = \mathbf{a} \\ \mathbf{v}_2 & = m \mathbf{e}_2 \\ \vdots & \\ \mathbf{v}_d & = m \mathbf{e}_d�\\ \end{align*}
where \(\mathbf{e}_i\) is the \(i^\text{th}\) unit vector.
A condition often required when building a rank 1 lattice is that \(\gcd(a_j, m) = 1\) for \(j =1, \dots,d\). When this condition is verified, each lower-dimensional projection of the lattice contains the same number of points (has the same density \(m\)) as the full lattice. When searching for lattices that satisfy this condition, one may assume without loss of generality generality that \(a_1 = 1\). Under that condition, it is straightforward to construct a basis for a projection that contains the first coordinate, and also its m-dual basis. In this class, we assume that \(a_1 = 1\) and \(\gcd(a_j, m) = 1\) for all \(j\). We exploit these conditions when building bases for the lattice, the projections, and their m-duals.
The functions buildBasis
and incDimBasis
always build and update the primal basis, because it is required to update the m-dual. To build only the m-dual, use buildDualBasis
.
LatticeTester::Rank1Lattice< Int, Real >::Rank1Lattice | ( | const Int & | m, |
const IntVec & | aa, | ||
NormType | norm = L2NORM ) |
This constructor takes as input the modulus m
, the generating vector aa
, and the norm used to measure the vector lengths.
The maximal dimension maxDim
will be the length d
of the vector aa
. The coefficient \(a_j\) will be aa[j-1]
. One must have aa[0] = 1
. The variable withPrimal
indicates if the primal basis will be maintained or not, and withDual
indicates if the dual basis will be maintained or not. This constructor does not build the basis, to leave more flexibility in the dimension when doing so.
LatticeTester::Rank1Lattice< Int, Real >::Rank1Lattice | ( | const Int & | m, |
const Int & | a, | ||
int64_t | maxDim, | ||
NormType | norm = L2NORM ) |
Constructor for the special case of a Korobov lattice.
Here the generating vector has the form \(\ba = (1, a, a^2 mod m, a^3 mod m, ...)\) where \(a\) is an integer such that \(1 < a < m\).
LatticeTester::Rank1Lattice< Int, Real >::Rank1Lattice | ( | const Int & | m, |
int64_t | maxDim, | ||
NormType | norm = L2NORM ) |
This constructor does not specify the generating vector.
LatticeTester::Rank1Lattice< Int, Real >::Rank1Lattice | ( | const Rank1Lattice< Int, Real > & | Lat | ) |
Copy constructor.
LatticeTester::Rank1Lattice< Int, Real >::~Rank1Lattice | ( | ) |
Destructor.
|
virtual |
Builds a basis in dim
dimensions.
This dim
must not exceed this->maxDim()
. This initial primal basis will be upper triangular. This function can be called only when withPrimal
is set to true. If withDual
is true, it also builds an m-dual lower-triangular basis.
Reimplemented from LatticeTester::IntLatticeExt< Int, Real >.
|
virtual |
Builds only an m-dual lower triangular basis (and not the primal) directly in dim
dimensions.
This dim
must not exceed maxDim
.
Reimplemented from LatticeTester::IntLatticeExt< Int, Real >.
|
overridevirtual |
This method overrides its namesake in IntLattice
.
The projection of this Rank1Lattice
over the coordinates in proj
is returned in projLattice
. The implementation used here exploits the rank-1 lattice structure and it is simpler and faster than the general one. See Section 5.5 of the guide. When the first coordinate is 1 and belongs to the projection, both the primal and m-dual constructions are direct, just by selecting the rows and columns whose indices are in proj
. Otherwise, those rows and columns plus the first row form a set of proj.size()+1
generating vectors for the primal. This number must not exceed the maxDim
of projLattice
.
Reimplemented from LatticeTester::IntLattice< Int, Real >.
|
overridevirtual |
Similar to buildProjection
, but builds a basis for the m-dual of the projection.
Reimplemented from LatticeTester::IntLattice< Int, Real >.
|
virtual |
Increases the current dimension of the primal basis by 1 and updates the basis.
This function can be called only when withPrimal
is set to true. If withDual
, it also increases the m-dual basis and makes it the m-dual of the primal basis. The new increased dimension must not exceed maxDim
.
Reimplemented from LatticeTester::IntLatticeExt< Int, Real >.
|
virtual |
Increases the current dimension of only the m-dual basis by 1.
The primal basis is left unchanged (not updated). The new increased dimension must not exceed maxDim
. This method uses the simplified method given in the lattice tester guide: the new m-dual basis vector is simply \(\bw_d = (-a_d, 0, ..., 0, 1)\).
Reimplemented from LatticeTester::IntLatticeExt< Int, Real >.
Rank1Lattice< Int, Real > & LatticeTester::Rank1Lattice< Int, Real >::operator= | ( | const Rank1Lattice< Int, Real > & | Lat | ) |
Assigns Lat
to this object.
void LatticeTester::Rank1Lattice< Int, Real >::seta | ( | const Int & | a | ) |
Sets this lattice to a Korobov lattice with multiplier a
.
Sets this lattice to a Korobov lattice with multiplier a
, with dim = maxDim.
The maximum dimension is unchanged.
void LatticeTester::Rank1Lattice< Int, Real >::setaa | ( | const IntVec & | aa | ) |
Sets the generating vector to aa
.
The maximum dimension will be set to its dimension.
std::string LatticeTester::Rank1Lattice< Int, Real >::toStringCoef | ( | ) | const |
Returns the first dim
components of the generating vector \(\ba\) as a string, where dim
is the current lattice dimension.
|
protected |
Vector of multipliers (generating vector) of the rank 1 lattice rule.
They are stored for up to maxDim()
dimensions. The first coordinate has index 0.