LatNet Builder Manual
2.0.1-11
Software Package for Constructing Highly Uniform Point Sets
|
This class represents a lattice and its basis and offers tools to do basic manipulations on lattice bases. More...
#include <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. | |
void | kill () |
Cleans and releases all the memory allocated to this lattice. | |
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, int 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. | |
BasIntMat & | getBasis () |
Returns the basis represented in a matrix. | |
BasIntMat & | getDualBasis () |
Returns the dual basis represented in a matrix. | |
int | getDim () const |
Returns the dimension of the lattice. More... | |
NormType | getNorm () const |
Returns the NormType used by this lattice. | |
Dbl | getVecNorm (const int &i) |
Returns the norm of the i-th vector of the basis. | |
DblVec | getVecNorm () const |
Returns the norm of each vector of the basis in a vector. | |
Dbl | getDualVecNorm (const int &i) |
Returns the norm of the i-th vector of the dual basis. | |
DblVec | getDualVecNorm () const |
Returns the norm of each vector of the dual basis in a vector. | |
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 . | |
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 () |
Returns true if a dual has been defined and false otherwise. | |
void | setDualFlag (bool flag) |
Sets the withDual flag to flag . More... | |
bool | getXX (int i) const |
Gets whether or not there is a component at the i -th position in the basis. More... | |
void | setXX (bool val, int i) |
Sets value at the i -th position in the array xx. | |
void | setNegativeNorm () |
Sets all the values in the array containing the norms of the basis vectors to -1. | |
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. | |
void | setDualNegativeNorm () |
Sets all the values in the array containing the norms of the dual basis vectors to -1. | |
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. | |
void | updateVecNorm () |
Updates the array containing the basis vectors norms by recomputing them. | |
void | updateVecNorm (const int &d) |
Updates the array containing the basis vectors norms from the d -th component to the last by recomputing them. | |
void | updateDualVecNorm () |
Updates the array containing the dual basis vectors norms by recomputing them. | |
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. | |
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 . | |
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 . | |
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 . | |
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 . | |
void | permute (int i, int j) |
Exchanges vectors i and j in the basis. 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... | |
std::string | toStringBasis () const |
Returns a string with the primal basis and its norms. | |
std::string | toStringDualBasis () const |
Returns a string with the dual basis and its norms. | |
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. | |
BasIntMat | m_dualbasis |
Each row of this matrix represents a vector in the dual basis of the lattice. | |
int | m_dim |
The dimension of the lattice. More... | |
NormType | m_norm |
The NormType used in the reduction and for this lattice. | |
DblVec | m_vecNorm |
The norm of each vector in the basis. | |
DblVec | m_dualvecNorm |
The norm of each vector in the dual basis. | |
Int | m_modulo |
The m used for rescaling the lattice. | |
bool | m_withDual |
If m_withDual is true a dual basis has been specified, otherwise it is false . | |
bool * | m_xx |
This table is used in the Minkowski reduction, but it's usage is quite obscure. | |
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 usecases 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
.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::initVecNorm(), LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_basis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm, NTL::vector< T >::resize(), and NTL::matrix< T >::resize().
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
.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::initVecNorm(), LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm, and NTL::vector< T >::resize().
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
.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualbasis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualvecNorm, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_modulo, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_withDual, NTL::vector< T >::resize(), and LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDualNegativeNorm().
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
.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::copyBasis().
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.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getXX(), LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_basis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualbasis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualvecNorm, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_modulo, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm, and LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_withDual.
Referenced by LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::IntLatticeBasis().
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::copyBasis | ( | const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > & | lat, |
int | 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.
References LatticeTester::CopyMatr(), LatticeTester::CopyVect(), LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getXX(), LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_basis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualbasis, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualvecNorm, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_modulo, LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm, and LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_withDual.
|
inline |
Returns the dimension of the lattice.
(Both the number of vectors in the basis and the number of coordinates of those vectors.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dim.
Referenced by LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::copy(), and LatticeTester::Reducer< Int, BasInt, Dbl, RedDbl >::Reducer().
|
inline |
Returns the m
used for rescaling if it has been defined.
Returns 0
otherwise.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_modulo.
|
inline |
Gets whether or not there is a component at the i
-th position in the basis.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_xx.
Referenced by LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::copy(), and LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::copyBasis().
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.
References LatticeTester::swap9().
|
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.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dim.
Referenced by LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::buildProjection().
|
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()
.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_withDual.
|
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.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualvecNorm.
|
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.
References LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm.
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 >::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 |
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.
Referenced by LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getDim(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::IntLattice(), and LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDim().