Lattice Tester Guide
1.0-9
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
|
This class represents a lattice and its basis and offers tools to do basic manipulations on lattice bases. More...
#include <latticetester/IntLatticeBasis.h>
Inherited by LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >.
Public Member Functions | |
IntLatticeBasis (const int dim, NormType norm=L2NORM) | |
Constructor initializing the primal basis with the identity matrix. More... | |
IntLatticeBasis (const BasIntMat basis, const int dim, NormType norm=L2NORM) | |
Constructor taking all three needed component of an IntLatticeBasis. More... | |
IntLatticeBasis (const BasIntMat primalbasis, const BasIntMat dualbasis, const Int modulo, const int dim, NormType norm=L2NORM) | |
Complete constructor. More... | |
IntLatticeBasis (const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > &Lat) | |
Copy constructor. More... | |
~IntLatticeBasis () | |
Destructor. More... | |
void | kill () |
Cleans and releases all the memory allocated to this lattice. More... | |
void | copyBasis (const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > &lat) |
Copy the lattice lat , except it's NormType and dimension, into this object. More... | |
void | copyBasis (const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > &lat, long n) |
Copy the n first elements of the basis of the lattice lat into this object. More... | |
void | initVecNorm () |
Initializes a vector containing the norms of the basis vectors to -1 at all components. More... | |
BasIntMat & | getBasis () |
Returns the basis represented in a matrix. More... | |
BasIntMat & | getDualBasis () |
Returns the dual basis represented in a matrix. More... | |
int | getDim () const |
Returns the dimension of the lattice. More... | |
NormType | getNorm () const |
Returns the NormType used by this lattice. More... | |
Dbl | getVecNorm (const int &i) |
Returns the norm of the i-th vector of the basis. More... | |
DblVec | getVecNorm () const |
Returns the norm of each vector of the basis in a vector. More... | |
Dbl | getDualVecNorm (const int &i) |
Returns the norm of the i-th vector of the dual basis. More... | |
DblVec | getDualVecNorm () const |
Returns the norm of each vector of the dual basis in a vector. More... | |
Int | getModulo () const |
Returns the m used for rescaling if it has been defined. More... | |
void | setDim (const int &d) |
Sets the dimension of the basis to d . More... | |
void | setNorm (const NormType &norm) |
Sets the NormType used by this lattice to norm . More... | |
void | setVecNorm (const Dbl &value, const int &i) |
Sets the norm of the i -th component of the basis to value . More... | |
void | setDualVecNorm (const Dbl &value, const int &i) |
Sets the norm of the i -th component of the dual basis to value . More... | |
bool | withDual () const |
Returns true if a dual has been defined and false otherwise. More... | |
void | setDualFlag (bool flag) |
Sets the withDual flag to flag . More... | |
void | setNegativeNorm () |
Sets all the values in the array containing the norms of the basis vectors to -1. More... | |
void | setNegativeNorm (const int &i) |
Sets the value of the i -th component in the array containing the norms of the basis vectors to -1. More... | |
void | setDualNegativeNorm () |
Sets all the values in the array containing the norms of the dual basis vectors to -1. More... | |
void | setDualNegativeNorm (const int &i) |
Sets the value of the i -th component in the array containing the norms of the dual basis vectors to -1. More... | |
void | updateVecNorm () |
Updates the array containing the basis vectors norms by recomputing them. More... | |
void | updateVecNorm (const int &d) |
Updates the array containing the basis vectors norms from the d -th component to the last by recomputing them. More... | |
void | updateDualVecNorm () |
Updates the array containing the dual basis vectors norms by recomputing them. More... | |
void | updateDualVecNorm (const int &d) |
Updates the array containing the dual basis vectors norms from the d -th component to the last by recomputing them. More... | |
void | updateScalL2Norm (const int i) |
Updates the i -th value of the array containing the norms of the basis vectors by recomputing it using the L2NORM . More... | |
void | updateScalL2Norm (const int k1, const int k2) |
Updates the k1 -th to the k2-1 -th values of the array containing the norms of the basis vectors by recomputing them using the L2NORM . More... | |
void | updateDualScalL2Norm (const int i) |
Updates the i -th value of the array containing the norms of the dual basis vectors by recomputing it using the L2NORM . More... | |
void | updateDualScalL2Norm (const int k1, const int k2) |
Updates the k1 -th to the k2-1 -th values of the array containing the norms of the dual basis vectors by recomputing them using the L2NORM . More... | |
void | permute (int i, int j) |
Exchanges vectors i and j in the basis. More... | |
void | permuteNoDual (int i, int j) |
Exchanges vectors i and j in the basis without changing the dual. More... | |
bool | checkDuality () |
Returns true if the dual basis contained in the object really is the dual of the basis, and false otherwise. More... | |
void | sort (int d) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length. More... | |
void | sortNoDual (int d) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length. More... | |
std::string | toStringBasis () const |
Returns a string with the primal basis and its norms. More... | |
std::string | toStringDualBasis () const |
Returns a string with the dual basis and its norms. More... | |
void | write () const |
Writes the lattice and its parameters on standard output. More... | |
Protected Attributes | |
BasIntMat | m_basis |
Each row of this matrix represents a vector in the basis of the lattice. More... | |
BasIntMat | m_dualbasis |
Each row of this matrix represents a vector in the dual basis of the lattice. More... | |
int | m_dim |
The dimension of the lattice. More... | |
NormType | m_norm |
The NormType used in the reduction and for this lattice. More... | |
DblVec | m_vecNorm |
The norm of each vector in the basis. More... | |
DblVec | m_dualvecNorm |
The norm of each vector in the dual basis. More... | |
BasInt | m_modulo |
The m used for rescaling the lattice. More... | |
bool | m_withDual |
If m_withDual is true a dual basis has been specified, otherwise it is false . More... | |
This class represents a lattice and its basis and offers tools to do basic manipulations on lattice bases.
Lattices are always stored rescaled. That is, we only consider lattices with rational coordinates such that m
is a lcm for all the denominators in basis coordinates. It is then possible to represent the lattice in the integers instead of the real numbers by multiplying all it's vectors by m
. We call this lattice a rescaled lattice. In practice, this allows an exact representation of the arithmetic on the basis. This is usefull in all the use cases of this software.
There are numerous ways to represent a lattice. Depending on the calculations that need to be done, it is possible to only provide the basis vectors, the norm and the dimension. There are also fields to provide a dual basis and an m
(the variables named modulo
). Both these fields are needed for most applications using the dual basis. The dimension \(d\) specifies that the basis contains \(d\) vectors in \(\mathbb{Z}^d\). The norm is one of the norm of NormType.
This class also has methods and attributes that can be used to store and compute the norms of the basis and dual basis vectors. It can also permute vectors in the basis or sort them by length and do the corresponding changes in the dual. Finally, it can also check if the dual really is a dual to the primal basis.
This class is made to be built upon. It only offers the bare basics of what a user could want to do with a Lattice. It is most likely that the utilities presented here do not suffice common needs. For a more extensive representation of a lattice look for the IntLattice
and the Rank1Lattice
classes.
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::IntLatticeBasis | ( | const int | dim, |
NormType | norm = L2NORM |
||
) |
Constructor initializing the primal basis with the identity matrix.
The dimension of the lattice is set to dim
and the norm used for reduction to norm
.
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::IntLatticeBasis | ( | const BasIntMat | basis, |
const int | dim, | ||
NormType | norm = L2NORM |
||
) |
Constructor taking all three needed component of an IntLatticeBasis.
The primal basis is initialized with basis
, the dimension of the lattice with dim
and the norm used for reduction with norm
.
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::IntLatticeBasis | ( | const BasIntMat | primalbasis, |
const BasIntMat | dualbasis, | ||
const Int | modulo, | ||
const int | dim, | ||
NormType | norm = L2NORM |
||
) |
Complete constructor.
The primal basis is initialized with primalbasis
, the dual basis with dualbasis
, the \(m\) used for rescaling with modulo
, the dimension of the lattice with dim
and the norm used for reduction with norm
.
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::IntLatticeBasis | ( | const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > & | Lat | ) |
Copy constructor.
This will copy the entirety of Lat into *this
.
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::~IntLatticeBasis | ( | ) |
Destructor.
bool LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::checkDuality | ( | ) |
Returns true
if the dual basis contained in the object really is the dual of the basis, and false
otherwise.
This also returns false if no dual has been specified.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::copyBasis | ( | const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > & | lat | ) |
Copy the lattice lat
, except it's NormType and dimension, into this object.
This does not check if the dimensions match.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::copyBasis | ( | const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > & | lat, |
long | n | ||
) |
Copy the n first elements of the basis of the lattice lat
into this object.
The object into which lat
is copied has to be of dimension n.
|
inline |
Returns the basis represented in a matrix.
|
inline |
Returns the dimension of the lattice.
(Both the number of vectors in the basis and the number of coordinates of those vectors.
|
inline |
Returns the dual basis represented in a matrix.
|
inline |
Returns the norm of the i-th vector of the dual basis.
|
inline |
Returns the norm of each vector of the dual basis in a vector.
|
inline |
Returns the m
used for rescaling if it has been defined.
Returns 0
otherwise.
|
inline |
Returns the NormType used by this lattice.
|
inline |
Returns the norm of the i-th vector of the basis.
|
inline |
Returns the norm of each vector of the basis in a vector.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::initVecNorm | ( | ) |
Initializes a vector containing the norms of the basis vectors to -1 at all components.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::kill | ( | ) |
Cleans and releases all the memory allocated to this lattice.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::permute | ( | int | i, |
int | j | ||
) |
Exchanges vectors i
and j
in the basis.
This also changes the dual basis vectors and the arrays containing secondary information about the two basis (like the norms) accordingly.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::permuteNoDual | ( | int | i, |
int | j | ||
) |
Exchanges vectors i
and j
in the basis without changing the dual.
See permute()
.
|
inline |
Sets the dimension of the basis to d
.
This won't change any of the vectors of the basis by itself. This method should not be called directly on an object of this class except in a function specifically changing the dimension of this object.
|
inline |
Sets the withDual
flag to flag
.
This flag indicates whether or not this IntLatticeBasis contains a dual basis. It is the flag returned by withDual()
.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDualNegativeNorm | ( | ) |
Sets all the values in the array containing the norms of the dual basis vectors to -1.
|
inline |
Sets the value of the i
-th component in the array containing the norms of the dual basis vectors to -1.
|
inline |
Sets the norm of the i
-th component of the dual basis to value
.
The usage of updateDualVecNorm(const int&)
is recommended over this function.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setNegativeNorm | ( | ) |
Sets all the values in the array containing the norms of the basis vectors to -1.
|
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
.
The usage of updateVecNorm(const int&)
is recommended over this function.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::sort | ( | int | d | ) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length.
The dual vectors are permuted accordingly. Assumes that the lengths of the corresponding basis vectors are up to date.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::sortNoDual | ( | int | d | ) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length.
The dual vectors are not permuted. See sort()
.
std::string LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::toStringBasis | ( | ) | const |
Returns a string with the primal basis and its norms.
std::string LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::toStringDualBasis | ( | ) | const |
Returns a string with the dual basis and its norms.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateDualScalL2Norm | ( | const int | i | ) |
Updates the i
-th value of the array containing the norms of the dual basis vectors by recomputing it using the L2NORM
.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateDualScalL2Norm | ( | const int | k1, |
const int | k2 | ||
) |
Updates the k1
-th to the k2-1
-th values of the array containing the norms of the dual basis vectors by recomputing them using the L2NORM
.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateDualVecNorm | ( | ) |
Updates the array containing the dual basis vectors norms by recomputing them.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateDualVecNorm | ( | const int & | d | ) |
Updates the array containing the dual basis vectors norms from the d
-th component to the last by recomputing them.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateScalL2Norm | ( | const int | i | ) |
Updates the i
-th value of the array containing the norms of the basis vectors by recomputing it using the L2NORM
.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateScalL2Norm | ( | const int | k1, |
const int | k2 | ||
) |
Updates the k1
-th to the k2-1
-th values of the array containing the norms of the basis vectors by recomputing them using the L2NORM
.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateVecNorm | ( | ) |
Updates the array containing the basis vectors norms by recomputing them.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateVecNorm | ( | const int & | d | ) |
Updates the array containing the basis vectors norms from the d
-th component to the last by recomputing them.
|
inline |
Returns true
if a dual has been defined and false
otherwise.
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::write | ( | ) | const |
Writes the lattice and its parameters on standard output.
This prints the dimension, the norm used, the basis and dual basis vectors and the basis and dual basis vector norms.
|
protected |
Each row of this matrix represents a vector in the basis of the lattice.
|
protected |
The dimension of the lattice.
The dimension is both the number of vectors in the basis, and the dimension \(d\) of \(\mathbb{Z}^d\) containing the lattice.
|
protected |
Each row of this matrix represents a vector in the dual basis of the lattice.
|
protected |
The norm of each vector in the dual basis.
|
protected |
The m
used for rescaling the lattice.
|
protected |
The NormType used in the reduction and for this lattice.
|
protected |
The norm of each vector in the basis.
|
protected |
If m_withDual is true
a dual basis has been specified, otherwise it is false
.