Lattice Tester Online Documentation 0.1.0-861
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
|
An IntLattice
object is an integral lattice, with its basis or its m
-dual basis, or both.
More...
#include <latticetester/IntLattice.h>
Public Member Functions | |
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 . | |
virtual void | buildProjection (IntLattice< Int, Real > &projLattice, const Coordinates &proj) |
Builds a basis for the projection of the present lattice over the set of coordinates determined by proj . | |
virtual void | buildProjectionDual (IntLattice< Int, Real > &projLattice, const Coordinates &proj) |
Similar to buildProjection , except that it builds an upper-triangular basis for the primal and a lower-triangular basis for the $m$-dual of the projection, both in projLattice . | |
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 | |
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. | |
An IntLattice
object is an integral lattice, with its basis or its m
-dual basis, or both.
There are tools to perform simple manipulations on those lattice bases. The value of m
must be chosen in a way that all coordinates of the basis and of its m
-dual are integers, so they can be represented exactly. The basis or its m
-dual is rescaled by m
, which is typically the smallest integer with this property.
The dimension dim
of the lattice is the number of independent vectors that form a basis. Usually, these vectors also have dim
coordinates, but in general they may have more. The basis and/or the m
-dual basis are stored in IntMat
arrays (from NTL) of sizes maxDim x maxDim
, where maxDim is usually fixed to a value as large as the largest
dimthat we want to handle. We use only the upper-left
dim x dimcorner of each array to store the actual basis. These arrays can then be allocated only once and never have to be resized, which improves speed. A boolean variable
withPrimalindicates if we maintain the primal basis and a variable
withDual` indicates if we maintain the dual basis. At least one of them (or both) should be true.
A norm is also chosen in NormType
to measure the vector lengths; by default it is the Euclidean norm. Methods and attributes are offered to compute and store the norms of the basis and/or the m-dual basis vectors, to permute these vectors, sort them by length, etc. The norms are for the vectors of the rescaled lattice and its m-dual. An IntLattice
object contains protected variables to store all these quantities. For better efficiency, we should avoid creating many IntLattice
objects, for example when making searches for good lattices. We should try to reuse the same one as much as we can.
Often, we want to assess the quality of projections of the lattice over subsets of coordinates. The method buildProjection
computes a basis for the lattice defined as the projection of the full lattice on a subset \(I\) of coordinates indices defined by a Coordinates
object. When computing figures of merit, one may want to recompute a basis for a large number of different projections, which can be specified by a CoordinateSets
object.
NOTE: There are no methods to copy or overwrite only the dual lattice!!! Maybe not needed?
The class IntLatticeExt
extends this class and contains virtual methods that must be defined in its subclasses.
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
.
LatticeTester::IntLattice< Int, Real >::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
.
LatticeTester::IntLattice< Int, Real >::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.
In this case, by default, both the primal and m-dual basis will be maintained. The two IntMat
objects must be of size maxDim
by maxDim
.
LatticeTester::IntLattice< Int, Real >::IntLattice | ( | const IntLattice< Int, Real > & | lat | ) |
Copy constructor.
Makes a deep copy of lat
into *this
new object.
|
virtual |
Destructor.
|
virtual |
Builds a basis for the projection of the present lattice over the set of coordinates determined by proj
.
This becomes the basis in projLattice
. By default, it uses an upper-triangular construction. It is assumed that a basis for the present lattice is already available and contains all the coordinates in proj
.
Reimplemented in LatticeTester::MRGLattice< Int, Real >, and LatticeTester::Rank1Lattice< Int, Real >.
|
virtual |
Similar to buildProjection
, except that it builds an upper-triangular basis for the primal and a lower-triangular basis for the $m$-dual of the projection, both in projLattice
.
The dimensions in the latter are updated. We should use this function when we need a basis for the $m$-dual of the projection.
Reimplemented in LatticeTester::MRGLattice< Int, Real >, and LatticeTester::Rank1Lattice< Int, Real >.
|
virtual |
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
.
It is assumed that a basis for the present lattice is already available and contains all the coordinates in proj
. The maxDim
of the projLattice
object must be large enough so it can holds the projection. The modulus m
is assumed to be the same for projLattice
and for the current object. This function can be called several times with the same projLattice
object to examine several different projections. Note that representing each projection as an IntLattice
object is required when we want to call Reducer::shortestVector
for several projections. This function can be overridden by more efficient ones in certain classes.
bool LatticeTester::IntLattice< Int, Real >::checkDuality | ( | ) |
Returns true
iff the m-dual basis contained in the object really is the m-dual of the current primal basis.
Otherwise, it returns false.
void LatticeTester::IntLattice< Int, Real >::copyLattice | ( | const IntLattice< Int, Real > & | lat | ) |
Makes a deep copy of the lattice lat
into this (existing) object.
New matrix and vector objects are constructed to store the bases and norms.
void LatticeTester::IntLattice< Int, Real >::dualize | ( | ) |
Exchanges the primal and m-dual bases, their dimensions, and vector norms.
|
inline |
Returns the IntMat
object that contains the basis of this lattice.
|
inline |
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.
|
inline |
Returns the current dimension of the m-dual lattice.
|
inline |
Returns the m-dual basis represented in a matrix.
|
inline |
Returns the norm (squared in case of the L^2 norm) of each vector of the m-dual basis, in a vector.
|
inline |
Returns the norm (squared in case of the L^2 norm) of the i-th vector of the m-dual basis.
The index i starts at 0.
|
inline |
Returns the maximal dimension for this lattice.
|
inline |
Returns the scaling factor m
.
|
inline |
Returns the NormType
used by this lattice.
|
inline |
Returns the norm (squared in case of the L^2 norm) of each basis vector, in a vector.
|
inline |
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.
void LatticeTester::IntLattice< Int, Real >::overwriteLattice | ( | const IntLattice< Int, Real > & | lat, |
long | dim, | ||
long | dimdual ) |
void LatticeTester::IntLattice< Int, Real >::permute | ( | int64_t | i, |
int64_t | j ) |
Exchanges vectors i
and j
in the basis.
This also changes the m-dual basis vectors and the arrays containing secondary information about the two bases (like the norms) accordingly.
void LatticeTester::IntLattice< Int, Real >::permuteDual | ( | int64_t | i, |
int64_t | j ) |
Exchanges vectors i
and j
in the m
-dual basis without changing the primal.
|
inline |
Changes the basis to 'basis', the modulus to 'm', and the current dimension to 'dim'.
Does not change maxDim
.
|
inline |
Changes only the 'basis' and the current dimension to 'dim'.
Does not change m
and maxDim
.
|
inline |
Sets the dimension of the primal basis to dim
.
This does not change maxDim
nor any of the basis vectors, but only the dimension variable.
|
inline |
Sets the dimension of the primal basis to dim
.
This does not change maxDim
nor any of the basis vectors, but only the dimension variable.
void LatticeTester::IntLattice< Int, Real >::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.
|
inline |
Sets the value of the i
-th component in the array containing the norms of the m-dual basis vectors to -1.
|
inline |
Sets the norm of the i
-th component of the m-dual basis to value
, which is assumed to be the correct value.
To recompute the norm, use updateDualVecNorm(const int64_t&)
instead.
void LatticeTester::IntLattice< Int, Real >::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.
This means that these norms are no longer up to date.
|
inline |
Sets the value of the i
-th component in the array containing the norms of the basis vectors to -1.
|
inline |
Sets the NormType
used by this lattice to norm
.
|
inline |
Sets the norm of the i
-th component of the basis to value
, which is assumed to be the correct value.
To recompute the norm, use updateVecNorm(const int64_t&)
instead.
void LatticeTester::IntLattice< Int, Real >::sortBasis | ( | int64_t | d | ) |
Sorts the primal basis vectors with indices greater of equal to d
by increasing length.
The m-dual vectors are permuted accordingly. Assumes that the lengths (norms) of the corresponding basis vectors are up to date. The dual basis vectors are not permuted.
void LatticeTester::IntLattice< Int, Real >::sortDualBasis | ( | int64_t | d | ) |
Sorts the m
-dual basis vectors with indices greater of equal to d
by increasing length.
The primal basis vectors are not permuted.
std::string LatticeTester::IntLattice< Int, Real >::toString | ( | ) | const |
Returns a string that represents this lattice and its parameters.
It contains the dimension, the norm used, the basis and m-dual basis vectors and the basis and dual basis vector norms.
std::string LatticeTester::IntLattice< Int, Real >::toStringBasis | ( | ) | const |
Returns a string that contains the primal basis vectors and their norms.
std::string LatticeTester::IntLattice< Int, Real >::toStringDualBasis | ( | ) | const |
Returns a string with the m
-dual basis vectors and their norms.
void LatticeTester::IntLattice< Int, Real >::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 LatticeTester::IntLattice< Int, Real >::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 LatticeTester::IntLattice< Int, Real >::updateDualVecNorm | ( | ) |
Updates the array containing the m-dual basis vectors norms by recomputing them.
Assumes that the dual basis is available.
void LatticeTester::IntLattice< Int, Real >::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 LatticeTester::IntLattice< Int, Real >::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.
Only the first c components are used for calculating the norm
void LatticeTester::IntLattice< Int, Real >::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 LatticeTester::IntLattice< Int, Real >::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 LatticeTester::IntLattice< Int, Real >::updateSingleDualVecNorm | ( | const int64_t & | d, |
const int64_t & | c ) |
Updates the 'd'-th entry of the array containing the m-dual basis vectors norms.
Only the first c components are used for calculating the norm.
void LatticeTester::IntLattice< Int, Real >::updateSingleVecNorm | ( | const int64_t & | d, |
const int64_t & | c ) |
Updates the 'd'-th entry of the array containing the basis vectors norms.
Only the first c components are used for calculating the norm.
void LatticeTester::IntLattice< Int, Real >::updateVecNorm | ( | ) |
Updates the array containing the norms of the basis vectors by recomputing them.
We could also return the index of the vector that is shortest!
void LatticeTester::IntLattice< Int, Real >::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.
Putting d=0
recomputes all the norms.
void LatticeTester::IntLattice< Int, Real >::write | ( | ) | const |
Writes on standard output the string returned by toString
.
|
protected |
The rows of the m_dim x m_dim upper left corner of this matrix are the primal basis vectors.
|
protected |
The current dimension of the primal basis, which is the number of (independent) vectors in it.
It cannot exceed the number of coordinates in those vectors. It also cannot exceed m_maxDim
.
|
protected |
The current dimension of the m-dual basis, which is the number of (independent) vectors in its basis.
It cannot exceed the number of coordinates in those vectors. It also cannot exceed m_maxDim
.
|
protected |
The rows of the m_dim x m_dim upper left corner this matrix are the m-dual basis vectors.
May not be initialized.
|
protected |
Similar to vecNorm, but for the m-dual basis.
|
protected |
The maximal dimension for this lattice.
It should correspond to the size of the IntMat
objects that contain the basis and/or its m-dual.
|
protected |
The scaling factor m
used for rescaling the lattice.
|
protected |
The NormType used to measure the vector lengths for this lattice.
It is used for the basis reduction and compute a shortest vector, for example.
|
protected |
A vector that stores the norm of each basis vector.
In case of the L_2 norm, it contains the square norm instead. A value of -1 means that the norm is not up to date.