LatNet Builder Manual 2.1.3-6
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. | |
IntLatticeBasis (const BasIntMat basis, const int dim, NormType norm=L2NORM) | |
Constructor taking all three needed component of an IntLatticeBasis. | |
IntLatticeBasis (const BasIntMat primalbasis, const BasIntMat dualbasis, const Int modulo, const int dim, NormType norm=L2NORM) | |
Complete constructor. | |
IntLatticeBasis (const IntLatticeBasis< Int, BasInt, Dbl, RedDbl > &Lat) | |
Copy constructor. | |
~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. | |
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. | |
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. | |
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. | |
void | setDim (const int &d) |
Sets the dimension of the basis to d. | |
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. | |
void | setDualVecNorm (const Dbl &value, const int &i) |
Sets the norm of the i-th component of the dual basis to value. | |
bool | withDual () const |
Returns true if a dual has been defined and false otherwise. | |
void | setDualFlag (bool flag) |
Sets the withDual flag to flag. | |
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. | |
void | permuteNoDual (int i, int j) |
Exchanges vectors i and j in the basis without changing the dual. | |
bool | checkDuality () |
Returns true if the dual basis contained in the object really is the dual of the basis, and false otherwise. | |
void | sort (int d) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length. | |
void | sortNoDual (int d) |
Sorts the basis vectors with indices greater of equal to \(d\) by increasing length. | |
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. |
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. | |
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. | |
BasInt | 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. |
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.
References initVecNorm(), m_basis, m_dim, m_modulo, m_norm, m_vecNorm, and m_withDual.
Referenced by copyBasis(), copyBasis(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::IntLattice(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::IntLattice(), IntLatticeBasis(), and IntLatticeBasis().
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 initVecNorm(), m_basis, m_dim, m_modulo, m_norm, m_vecNorm, and m_withDual.
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 IntLatticeBasis(), m_dualbasis, m_dualvecNorm, m_modulo, m_withDual, and 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 copyBasis(), getDim(), getNorm(), IntLatticeBasis(), m_dim, and m_norm.
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.
References getDim(), m_basis, m_dualbasis, m_modulo, m_withDual, and LatticeTester::ProdScal().
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 IntLatticeBasis(), m_basis, m_dualbasis, m_dualvecNorm, m_modulo, m_vecNorm, and m_withDual.
Referenced by IntLatticeBasis().
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.
References LatticeTester::CopyMatr(), LatticeTester::CopyVect(), IntLatticeBasis(), m_basis, m_dim, m_dualbasis, m_dualvecNorm, m_modulo, m_vecNorm, and 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 m_dim.
Referenced by LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::buildProjection(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::calcLgVolDual2(), checkDuality(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::fixLatticeNormalization(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::getNormalizer(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::incDim(), LatticeTester::Rank1Lattice< Int, BasInt, Dbl, RedDbl >::incDim(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::init(), LatticeTester::Rank1Lattice< Int, BasInt, Dbl, RedDbl >::init(), IntLatticeBasis(), LatticeTester::BasisConstruction< BasInt >::ProjectionConstruction(), LatticeTester::Rank1Lattice< Int, BasInt, Dbl, RedDbl >::Rank1Lattice(), LatticeTester::Reducer< Int, BasInt, Dbl, RedDbl >::Reducer(), sort(), sortNoDual(), and LatticeTester::Rank1Lattice< Int, BasInt, Dbl, RedDbl >::toStringCoef().
|
inline |
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 m_basis, m_dim, m_dualbasis, m_dualvecNorm, m_vecNorm, m_withDual, and LatticeTester::swap9().
Referenced by sort().
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().
References m_basis, m_dim, m_vecNorm, and LatticeTester::swap9().
Referenced by sortNoDual().
|
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 m_dim.
Referenced by LatticeTester::Rank1Lattice< Int, BasInt, Dbl, RedDbl >::buildBasis(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::buildProjection(), and LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::incDim().
|
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 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 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 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.
References getDim(), getVecNorm(), and permute().
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().
References getDim(), getVecNorm(), and permuteNoDual().
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.
References m_basis, m_dim, m_dualbasis, m_dualvecNorm, m_norm, m_vecNorm, and m_withDual.
|
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 copyBasis(), getDim(), initVecNorm(), LatticeTester::IntLattice< Int, BasInt, Dbl, RedDbl >::IntLattice(), IntLatticeBasis(), IntLatticeBasis(), IntLatticeBasis(), permute(), permuteNoDual(), setDim(), setDualNegativeNorm(), setNegativeNorm(), toStringBasis(), toStringDualBasis(), updateDualScalL2Norm(), updateDualVecNorm(), updateScalL2Norm(), updateVecNorm(), and write().