Lattice Tester Online Documentation 0.1.0-861
Software Package For Testing The Uniformity Of Integral Lattices In The Real Space
|
This ReducerBB
class provides facilities to reduce the basis of a lattice (an IntLattice
object) in various ways (pairwise, LLL, BKZ, Minkowski [4], [9], [10]), and to find a shortest nonzero vector in the lattice using a BB algorithm [rFIN85a].
More...
#include <latticetester/ReducerBB.h>
Public Member Functions | |
ReducerBB (IntLattice< Int, Real > &lat) | |
Constructor that initializes the reducer to work on the lattice lat . | |
ReducerBB (int64_t maxDim) | |
Constructor of a ReducerBB than can handle up to maxDim dimensions. | |
ReducerBB (const ReducerBB< Int, Real > &red) | |
Copy constructor. | |
~ReducerBB () | |
Destructor. | |
ReducerBB< Int, Real > & | operator= (const ReducerBB< Int, Real > &red) |
Assignment operator that makes a deep copy of red into the current object, using copy . | |
void | init (int64_t maxDim) |
Initializes all matrices used in the following. | |
void | copy (const ReducerBB< Int, Real > &red) |
Copies red into the current object. | |
bool | shortestVector () |
Computes a shortest non-zero vector for the IntLattice stored in this ReducerBB object, with respect to the norm in this IntLattice , using the BB algorithm described in [6] and [7]. | |
bool | shortestVector (IntLattice< Int, Real > &lat) |
In this version, the lattice is passed as a parameter. | |
bool | reductMinkowski (int64_t d=0) |
Reduces the current basis to a Minkowski-reduced basis with respect to the Euclidean norm, assuming that the first \(d\) vectors are already reduced and sorted. | |
bool | reductMinkowski (IntLattice< Int, Real > &lat, int64_t d=0) |
In this version, the lattice is passed as a parameter. | |
void | redDieter (int64_t dim, bool taboo[]=NULL) |
This method performs pairwise reduction sequentially on all vectors of the basis whose indices are greater of equal to dim >=0 , as proposed in [4]. | |
void | redDieterRandomized (int64_t dim, int64_t seed) |
Same as redDieter(dim) but the choice of vectors on which to perform pairwise reduction is randomized, using a simple RNG from the standard C library, with the given integer seed. | |
void | redLLLOld (double delta=0.999999, std::int64_t maxcpt=1000000000, int64_t dim=0) |
This is an old implementation of LLL translated from an old Modula-2 code. | |
Real | getMinLength2 () |
Returns the square Euclidean length of the current shortest basis vector in the lattice. | |
Real | getMinLength () |
Returns the length of the current shortest basis vector in the lattice, which is stored in a local variable. | |
Real | getMaxLength () |
Returns the length of the current last basis vector in the lattice. | |
void | setBoundL2 (const RealVec &thresholds, int64_t dim1, int64_t dim2) |
Sets a vector of bounds on the square of the acceptable shortest vector lengths (for the Euclidean norm), in dimensions from dim1+1 to dim2 . | |
void | setIntLattice (IntLattice< Int, Real > &lat) |
Sets to lat the IntLattice object on which this reducer object will be working. | |
IntLattice< Int, Real > * | getIntLattice () |
Returns the IntLattice object that this object is working on. | |
void | setDecompTypeBB (DecompTypeBB decomp) |
Sets the decomposition method used by this reduced to compute bounds in the BB procedures. | |
Public Attributes | |
int64_t | maxNodesBB = 10000000 |
The maximum number of nodes in the branch-and-bound tree when calling shortestVector or reductMinkowski . | |
This ReducerBB
class provides facilities to reduce the basis of a lattice (an IntLattice
object) in various ways (pairwise, LLL, BKZ, Minkowski [4], [9], [10]), and to find a shortest nonzero vector in the lattice using a BB algorithm [rFIN85a].
Each Reducer
must have an internal IntLattice
object which is given upon construction and can also be changed later via setIntLattice
. The reduction methods are applied to this internal object.
The shortestVector
and reductMinkowski
methods do not apply any pre-reduction by themselves Before calling them, one should always reduce the basis separately beforehand with an LLL or BKZ reduction, because it drastically reduces the size of the BB search. These two methods have no static version. To use them one must create Reducer
object, which maintains several internal variables, vectors, and matrices. The recommended way is to create a single Reducer
object with a maximal dimension large enough, and then call the shortestVector
and reductMinkowski
methods with the relevant IntLattice
object as a parameter. ***** In fact, it can be always the same IntLattice object all the time!!! ***** The norm type, dimension, basis, vector lengths, etc. will be taken from this IntLattice
object. The dimensions of the internal vectors and matrices can be larger than required; the methods will use only the entries that are needed for the given IntLattice
basis. Creating a new Reducer
object for each IntLattice
that we want to handle is very inefficient and should be avoided, especially when we want to examine several projections for several lattices.
Most of the methods do not use or change the m-dual lattice. To reduce the m-dual basis or find a shortest nonzero vector in it, one should first dualize the lattice (IntLattice::dualize
does that) and then apply the desired methods.
LatticeTester::ReducerBB< Int, Real >::ReducerBB | ( | IntLattice< Int, Real > & | lat | ) |
Constructor that initializes the reducer to work on the lattice lat
.
The maximal dimension will be that of lat
.
LatticeTester::ReducerBB< Int, Real >::ReducerBB | ( | int64_t | maxDim | ) |
Constructor of a ReducerBB
than can handle up to maxDim
dimensions.
Space will be reserved once for all for the internal IntMat
objects such as the Gram and Cholesky matrices. These same matrices will be re-used over and over to avoid repeated space reallocation. It is recommended to create a reducer with a large enough max dim in the first place, using this constructor.
LatticeTester::ReducerBB< Int, Real >::ReducerBB | ( | const ReducerBB< Int, Real > & | red | ) |
Copy constructor.
LatticeTester::ReducerBB< Int, Real >::~ReducerBB | ( | ) |
Destructor.
void LatticeTester::ReducerBB< Int, Real >::copy | ( | const ReducerBB< Int, Real > & | red | ) |
Copies red
into the current object.
|
inline |
Returns the IntLattice object that this object is working on.
|
inline |
Returns the length of the current last basis vector in the lattice.
|
inline |
Returns the length of the current shortest basis vector in the lattice, which is stored in a local variable.
This depends only on the lattice, but this length is stored and used in this class.
|
inline |
Returns the square Euclidean length of the current shortest basis vector in the lattice.
void LatticeTester::ReducerBB< Int, Real >::init | ( | int64_t | maxDim | ) |
Initializes all matrices used in the following.
ReducerBB< Int, Real > & LatticeTester::ReducerBB< Int, Real >::operator= | ( | const ReducerBB< Int, Real > & | red | ) |
Assignment operator that makes a deep copy of red
into the current object, using copy
.
void LatticeTester::ReducerBB< Int, Real >::redDieter | ( | int64_t | dim, |
bool | taboo[] = NULL ) |
This method performs pairwise reduction sequentially on all vectors of the basis whose indices are greater of equal to dim >=0
, as proposed in [4].
For this function to work, both the primal and m-dual bases must be maintained together. The boolean vector taboo[]
is used internally in Minkowski reduction only: when this vector is not NULL
, ‘taboo[j]=true’ means that the j-th vector should not be modified.
void LatticeTester::ReducerBB< Int, Real >::redDieterRandomized | ( | int64_t | dim, |
int64_t | seed ) |
Same as redDieter(dim)
but the choice of vectors on which to perform pairwise reduction is randomized, using a simple RNG from the standard C library, with the given integer seed.
void LatticeTester::ReducerBB< Int, Real >::redLLLOld | ( | double | delta = 0.999999, |
std::int64_t | maxcpt = 1000000000, | ||
int64_t | dim = 0 ) |
This is an old implementation of LLL translated from an old Modula-2 code.
It is considerably slower than the NTL versions when Int = ZZ. We leave it here mostly to enable comparisons. This function performs a LLL basis reduction with factor delta
[7]. The reduction is applied to the first dim
basis vectors and coordinates when dim > 0
, and to the entire basis (all vectors) when dim=0
. Note that in the former case, the transformations are not applied to all the columns, so we no longer have a consistent basis for the original lattice, so we should make internal copies just in case dim > 0. If we want a reduced basis for a subset of coordinates, we should first make a copy to get a basis for these coordinates, before invoking this LLL.
This function always uses the Euclidean norm. The factor delta
must be between 1/2 and 1. The closer it is to 1, the more the basis is reduced, in the sense that the LLL algorithm will enforce tighter conditions on the basis, but this will require more work. The reduction algorithm is applied until maxcpt
successful transformations have been done, or until the basis is correctly LLL reduced with factor delta
.
bool LatticeTester::ReducerBB< Int, Real >::reductMinkowski | ( | int64_t | d = 0 | ) |
Reduces the current basis to a Minkowski-reduced basis with respect to the Euclidean norm, assuming that the first \(d\) vectors are already reduced and sorted.
If MaxNodesBB
is exceeded during one of the branch-and-bound step, the method aborts and returns false
. Otherwise it returns true
, the basis is reduced and sorted by increasing vector lengths. For a full reduction, just omit the d
parameter.
bool LatticeTester::ReducerBB< Int, Real >::reductMinkowski | ( | IntLattice< Int, Real > & | lat, |
int64_t | d = 0 ) |
In this version, the lattice is passed as a parameter.
It will become the new IntLattice
of this ReducerBB
object, exactly as in shortestVector(IntLattice)
.
void LatticeTester::ReducerBB< Int, Real >::setBoundL2 | ( | const RealVec & | thresholds, |
int64_t | dim1, | ||
int64_t | dim2 ) |
Sets a vector of bounds on the square of the acceptable shortest vector lengths (for the Euclidean norm), in dimensions from dim1+1
to dim2
.
thresholds[i]
must contain a lower bound on the square of the length of the shortest vector in the lattice in dimension i+1
. This bound will be used during during the Branch-and-Bound step when computing a shortest lattice vector. As soon as a vector shorter than the bound is found, the BB algorithm will stop. This is useful when we search for a good lattice with the spectral test, since it can reduce the work considerably. If these bounds are not set, the default values of 0 are used. It is recommended to set these bounds before calling shortestVector
for the first time when making searches for good lattices.
|
inline |
Sets the decomposition method used by this reduced to compute bounds in the BB procedures.
|
inline |
Sets to lat
the IntLattice
object on which this reducer object will be working.
If it is already lat
, nothing is done. If the dimension of lat
is larger than the max dimension for this ReducerBB
, the latter is increased and the ReducerBB
is re-initialized with new internal variables having the appropriate dimensions. Otherwise, the internal variables are left unchanged. It is recommended to create the reducer with a large enough max dim in the first place.
bool LatticeTester::ReducerBB< Int, Real >::shortestVector | ( | ) |
Computes a shortest non-zero vector for the IntLattice
stored in this ReducerBB
object, with respect to the norm in this IntLattice
, using the BB algorithm described in [6] and [7].
The admissible norm types here are L1NORM
and L2NORM
(see EnumTypes.h
). If the constant ReducerBB::MaxNodesBB
(see below) is exceeded during the branch-and-bound, the method aborts and returns false
. Otherwise, it returns true
. If the reduction was successful, the new reduced basis can be accessed via getIntLattice()
.
This function uses only the basis of the internal lattice, its vector lengths, and scalar products. It never uses its m-dual. To compute a shortest vector in the m-dual, one must first call dualize
on the target IntLattice
object. It is strongly recommended to use redBKZ
or redLLLNTL
to pre-reduce the basis before invoking this method; this is not done automatically. It is assumed that getDim
returns the correct dimension of the internal lattice.
bool LatticeTester::ReducerBB< Int, Real >::shortestVector | ( | IntLattice< Int, Real > & | lat | ) |
In this version, the lattice is passed as a parameter.
It will become the new IntLattice
of this ReducerBB
object. This method calls setIntLattice(lat)
, so if the max dimension for the ReducerBB is not large enough for lat
, all the internal variables of this reducer will be reset and the vectors and matrices will be automatically enlarged. In particular, the bounds set by setBoundL2
have to be reset. ***** If the max dimension is large enough, only a pointer is changed.
int64_t LatticeTester::ReducerBB< Int, Real >::maxNodesBB = 10000000 |
The maximum number of nodes in the branch-and-bound tree when calling shortestVector
or reductMinkowski
.
When this number is exceeded, the method aborts and returns false
.