Lattice Tester Guide  1.0-9
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl > Class Template Reference

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...
 
BasIntMatgetBasis ()
 Returns the basis represented in a matrix. More...
 
BasIntMatgetDualBasis ()
 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...
 

Detailed Description

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
class LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >

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.

Constructor & Destructor Documentation

◆ IntLatticeBasis() [1/4]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ IntLatticeBasis() [2/4]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ IntLatticeBasis() [3/4]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ IntLatticeBasis() [4/4]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ ~IntLatticeBasis()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::~IntLatticeBasis ( )

Destructor.

Member Function Documentation

◆ checkDuality()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ copyBasis() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ copyBasis() [2/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ getBasis()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
BasIntMat& LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getBasis ( )
inline

Returns the basis represented in a matrix.

◆ getDim()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
int LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getDim ( ) const
inline

Returns the dimension of the lattice.

(Both the number of vectors in the basis and the number of coordinates of those vectors.

◆ getDualBasis()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
BasIntMat& LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getDualBasis ( )
inline

Returns the dual basis represented in a matrix.

◆ getDualVecNorm() [1/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
Dbl LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getDualVecNorm ( const int &  i)
inline

Returns the norm of the i-th vector of the dual basis.

◆ getDualVecNorm() [2/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
DblVec LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getDualVecNorm ( ) const
inline

Returns the norm of each vector of the dual basis in a vector.

◆ getModulo()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
Int LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getModulo ( ) const
inline

Returns the m used for rescaling if it has been defined.

Returns 0 otherwise.

◆ getNorm()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
NormType LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getNorm ( ) const
inline

Returns the NormType used by this lattice.

◆ getVecNorm() [1/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
Dbl LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getVecNorm ( const int &  i)
inline

Returns the norm of the i-th vector of the basis.

◆ getVecNorm() [2/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
DblVec LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::getVecNorm ( ) const
inline

Returns the norm of each vector of the basis in a vector.

◆ initVecNorm()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::initVecNorm ( )

Initializes a vector containing the norms of the basis vectors to -1 at all components.

◆ kill()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::kill ( )

Cleans and releases all the memory allocated to this lattice.

◆ permute()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ permuteNoDual()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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().

◆ setDim()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDim ( const int &  d)
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.

◆ setDualFlag()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDualFlag ( bool  flag)
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().

◆ setDualNegativeNorm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ setDualNegativeNorm() [2/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDualNegativeNorm ( const int &  i)
inline

Sets the value of the i-th component in the array containing the norms of the dual basis vectors to -1.

◆ setDualVecNorm()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setDualVecNorm ( const Dbl &  value,
const int &  i 
)
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.

◆ setNegativeNorm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setNegativeNorm ( )

Sets all the values in the array containing the norms of the basis vectors to -1.

◆ setNegativeNorm() [2/2]

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setNegativeNorm ( const int &  i)
inline

Sets the value of the i-th component in the array containing the norms of the basis vectors to -1.

◆ setNorm()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setNorm ( const NormType norm)
inline

Sets the NormType used by this lattice to norm.

◆ setVecNorm()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::setVecNorm ( const Dbl &  value,
const int &  i 
)
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.

◆ sort()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ sortNoDual()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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().

◆ toStringBasis()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
std::string LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::toStringBasis ( ) const

Returns a string with the primal basis and its norms.

◆ toStringDualBasis()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
std::string LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::toStringDualBasis ( ) const

Returns a string with the dual basis and its norms.

◆ updateDualScalL2Norm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ updateDualScalL2Norm() [2/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ updateDualVecNorm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateDualVecNorm ( )

Updates the array containing the dual basis vectors norms by recomputing them.

◆ updateDualVecNorm() [2/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ updateScalL2Norm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ updateScalL2Norm() [2/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ updateVecNorm() [1/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
void LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::updateVecNorm ( )

Updates the array containing the basis vectors norms by recomputing them.

◆ updateVecNorm() [2/2]

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

◆ withDual()

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
bool LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::withDual ( ) const
inline

Returns true if a dual has been defined and false otherwise.

◆ write()

template<typename Int , typename BasInt , typename Dbl , typename RedDbl >
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.

Member Data Documentation

◆ m_basis

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
BasIntMat LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_basis
protected

Each row of this matrix represents a vector in the basis of the lattice.

◆ m_dim

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
int LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dim
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.

◆ m_dualbasis

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
BasIntMat LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualbasis
protected

Each row of this matrix represents a vector in the dual basis of the lattice.

◆ m_dualvecNorm

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
DblVec LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_dualvecNorm
protected

The norm of each vector in the dual basis.

◆ m_modulo

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
BasInt LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_modulo
protected

The m used for rescaling the lattice.

◆ m_norm

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
NormType LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_norm
protected

The NormType used in the reduction and for this lattice.

◆ m_vecNorm

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
DblVec LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_vecNorm
protected

The norm of each vector in the basis.

◆ m_withDual

template<typename Int, typename BasInt, typename Dbl, typename RedDbl>
bool LatticeTester::IntLatticeBasis< Int, BasInt, Dbl, RedDbl >::m_withDual
protected

If m_withDual is true a dual basis has been specified, otherwise it is false.


The documentation for this class was generated from the following file: