23 #ifndef PLLL_INCLUDE_GUARD__PLLL2_LLL_HPP
24 #define PLLL_INCLUDE_GUARD__PLLL2_LLL_HPP
48 #include <plll/config.hpp>
55 #include <boost/function.hpp>
64 class LatticeReductionImpl;
76 std::auto_ptr<LatticeReductionImpl> d_impl;
100 virtual const char * what()
const PLLL_INTERNAL_NOTHROW_POSTFIX_ENFORCE;
116 virtual const char * what()
const PLLL_INTERNAL_NOTHROW_POSTFIX_ENFORCE;
780 typedef boost::function<void(const linalg::math_matrix<arithmetic::Integer> &)>
CallbackFunction;
788 typedef boost::function<void(const linalg::math_matrix<arithmetic::NInt<long int> > &)>
CallbackFunction_LI;
797 typedef boost::function<void(const linalg::math_matrix<arithmetic::Integer> &, unsigned,
807 typedef boost::function<void(const linalg::math_matrix<arithmetic::NInt<long int> > &, unsigned,
818 typedef boost::function<void(const linalg::math_matrix<arithmetic::Integer> & basis,
833 typedef boost::function<void(const linalg::math_matrix<arithmetic::NInt<long int> > & basis,
849 typedef boost::function<bool(const linalg::math_matrix<arithmetic::Integer> &,
862 typedef boost::function<bool(const linalg::math_matrix<arithmetic::Integer> &,
876 typedef boost::function<bool (const linalg::math_matrix<arithmetic::Integer> &,
877 int k,
int windowsize,
914 template<
typename IType>
923 #if __cplusplus >= 201103L
954 template<
typename IType>
963 #if __cplusplus >= 201103L
981 unsigned rank()
const;
1128 void modSwap(
unsigned,
unsigned);
1425 void setRange(
unsigned begin,
unsigned end = std::numeric_limits<unsigned>::max());
1436 std::pair<unsigned, unsigned>
getRange()
const;
1446 void sort(
bool projected =
false);
1481 void hkz(
bool dual =
false);
1491 void svp(
bool make_basis =
true,
bool extreme =
false,
bool dual =
false);
unsigned long vectorinsertions_rearrange
bool isTransformationRecorded() const
Queries whether a transformation matrix is recorded.
void modSwap(unsigned, unsigned)
Swaps two given basis vectors.
const Statistics & getStatistics() const
Retrieves the current statistics object.
arithmetic::Real getGSSqNormR(unsigned) const
Returns the squared norm of the i-th Gram-Schmidt orthogonalized basis vector as a arithmetic::Real n...
bool isSVPBasis(bool dual=false) const
Tests whether the given lattice basis (or its reversed dual, in case dual is true) has a shortest vec...
void hkz(bool dual=false)
Computes a Hermite-Korkine-Zolotarev reduced basis.
RealContext & getThreadRealContext()
Retrieves a context for the current thread. The context is thread local and cannot be accessed by thi...
boost::function< bool(const linalg::math_matrix< arithmetic::Integer > &, int k, arithmetic::RealContext &, arithmetic::RandomNumberGenerator &, arithmetic::Real &T, GramSchmidtInformer *)> LLL_AnnealFunction
A annealing function for LLL.
void setLattice(const linalg::math_matrix< arithmetic::Integer > &lattice)
Sets the current lattice of the LatticeReduction object to the lattice given by the current matrix...
void setAnnealing(const AnnealCallbackFunction &, const LLL_AnnealFunction &, const BKZ_AnnealFunction &)
Sets annealing functions for both LLL and BKZ.
boost::function< bool(const linalg::math_matrix< arithmetic::Integer > &, int k, int windowsize, linalg::math_rowvector< arithmetic::Integer > &lincomb, arithmetic::RealContext &, arithmetic::RandomNumberGenerator &, arithmetic::Real &T, GramSchmidtInformer *)> BKZ_AnnealFunction
A annealing function for BKZ.
void modAdd(unsigned i, unsigned j, const arithmetic::Integer &m)
Adds m times the i-th basis vector to the j-th basis vector.
void setCallbackInterval(double=60.0 *5.0)
Sets the callback interval for the callback function.
std::pair< EnumCallbackFunction, EnumCallbackFunction_LI > getEnumCallbackFunction()
Retrieves the current enumeration callback function.
unsigned long sizereductions
std::pair< MinCallbackFunction, MinCallbackFunction_LI > getMinCallbackFunction() const
Retrieves the currently set minimum callback function.
DIMethod
Specifies which Deep Insertion mode is used.
boost::function< void(VerboseLevel, const std::string &)> VerboseFunction
A verbose output callback function.
long double getGSCoefficientLD(unsigned, unsigned) const
Returns the (i, j) Gram-Schmidt coefficient as a long double.
The matrix and vector template library.
boost::function< void(const linalg::math_matrix< arithmetic::NInt< long int > > &)> CallbackFunction_LI
A generic callback function for long int lattices.
boost::function< void(const linalg::math_matrix< arithmetic::NInt< long int > > &basis, int p, const linalg::math_rowvector< arithmetic::NInt< long int > > &vec)> EnumCallbackFunction_LI
A callback function for newly found shortest vectors during enumerations, or more generally SVP solvi...
Integers getIntegers() const
Returns the currently set integer arithmetic.
unsigned getMaximalCoreUsage()
Returns the current maximal number of cores used.
double getGSSqNormD(unsigned) const
Returns the squared norm of the i-th Gram-Schmidt orthogonalized basis vector as a double...
This exception should be thrown by callback functions to stop reduction and return the current state ...
void setIntegers(Integers)
Sets which integer arithmetic will be used for all lattice operations.
double getCallbackInterval() const
Retrieves the current (minimal) callback interval.
This exception should be thrown by callback functions to stop enumeration and return the currently fo...
boost::function< void(const linalg::math_matrix< arithmetic::Integer > &basis, int p, const linalg::math_rowvector< arithmetic::Integer > &vec)> EnumCallbackFunction
A callback function for newly found shortest vectors during enumerations, or more generally SVP solvi...
Statistics()
Creates a new statistics object with all values set to zero.
void svp(bool make_basis=true, bool extreme=false, bool dual=false)
Computes a shortest vector of the lattice and inserts it at the beginning.
void setSVPMode(SVPMode)
Sets the current SVP solver.
void setDefaultAnnealing()
Sets the default annealing functions.
arithmetic::Real getGSCoefficientR(unsigned, unsigned) const
Returns the (i, j) Gram-Schmidt coefficient as a arithmetic::Real number.
DIMethod getDeepInsertionMethod() const
Retrieves the current Deep Insertions method.
boost::function< void(const linalg::math_matrix< arithmetic::Integer > &, unsigned, const arithmetic::Integer &)> MinCallbackFunction
A callback function for newly found shortest vectors.
void sort(bool projected=false)
Sorts the vectors by their norm.
SVPMode
Specifies which SVP solver is used.
const linalg::math_matrix< arithmetic::Integer > * getTransformation() const
Queries the current transformation matrix.
unsigned getDeepInsertionBlocksize() const
Retrieves the current Deep Insertions choice block size parameter.
bool getGramSchmidtRestart() const
Returns whether restarts are used for the current Gram-Schmidt orthogonalization method.
Arithmetic
Specifies which arithmetic to use for Gram-Schmidt orthogonalization.
bool isLLLBasis(double alpha=0.99, LLLMode mode=LLL_Classic) const
Tests whether the given lattice basis is LLL reduced with respect to the given reduction parameter al...
void setVerbose(VerboseOutputLevel level, const VerboseFunction &=0)
Sets the verbose output level to level.
bool isHKZBasis(bool dual=false) const
Tests whether the given lattice basis (or its reversed dual, in case dual is true) is HKZ reduced...
bool isBKZBasis(double alpha=0.99, unsigned blocksize=20, BKZMode mode=BKZ_SchnorrEuchner) const
Tests whether the given lattice basis is BKZ reduced with respect to the given reduction parameter al...
void setDefaultAnnealingBKZ()
Sets the defalut BKZ annealing function.
LLLMode
Specifies which LLL condition is used.
boost::function< bool(const linalg::math_matrix< arithmetic::Integer > &, arithmetic::RealContext &, arithmetic::Real &T)> AnnealCallbackFunction
A callback function for Simulated Annealing.
bool isSizeReduced() const
Tests whether the given lattice is size reduced.
void setDeepInsertionMode(DIMode)
Sets the Deep Insertions mode.
void setEnumCallbackFunction(const EnumCallbackFunction &, const EnumCallbackFunction_LI &=EnumCallbackFunction_LI())
Sets a enumeration callback function which will be used if a new shortest vector is found during an e...
void setAnnealingBKZ(const AnnealCallbackFunction &, const BKZ_AnnealFunction &)
Sets annealing functions for BKZ.
void setDefaultAnnealingLLL()
Sets the defalut LLL annealing function.
void sizereduction()
Applies only size reduction to the vectors.
unsigned rank() const
Returns the current rank, i.e. the number of generating vectors.
bool ensurePrecision(unsigned long)
Ensures a minimal floating point precision (if possible).
VerboseOutputLevel getVerboseOutputLevel()
Retrieves the current verbose output level.
DIChoice getDeepInsertionChoice() const
Retrieves the current Deep Insertions choice.
void lll(double alpha=0.99, LLLMode mode=LLL_Classic)
Applies LLL with given reduction parameter alpha ( ) and mode mode.
double getGSCoefficientD(unsigned, unsigned) const
Returns the (i, j) Gram-Schmidt coefficient as a double.
bool isAnnealingLLLEnabled() const
Tests whether annealing for LLL is enabled.
void setDeepInsertionChoice(DIChoice, unsigned=1)
Sets the Deep Insertion choice and block size, which by default is 1.
Provides an interface to the lattice reduction algorithms of the plll library.
std::pair< unsigned, unsigned > getRange() const
Retrieves the current range.
Represents a random number generator.
Represents a math row vector with coefficients in T.
LatticeReduction()
Creates a default LatticeReduction object with default settings.
GramSchmidt getGramSchmidt() const
Returns the currently used Gram-Schmidt orthogonalization method.
~LatticeReduction()
Destroys the LatticeReduction object.
bool isAnnealingBKZEnabled() const
Tests whether annealing for BKZ is enabled.
boost::function< void(const linalg::math_matrix< arithmetic::Integer > &)> CallbackFunction
A generic callback function.
unsigned long deepinsertions
void disableAnnealingLLL()
Disable annealing for LLL.
Transform
Specifies which transformation matrix is computed.
Represents a native integer.
Integers
Specifies which arithmetic to use for integer operations.
void disableAnnealing()
Disable annealing for both LLL and BKZ.
long double getGSSqNormLD(unsigned) const
Returns the squared norm of the i-th Gram-Schmidt orthogonalized basis vector as a long double...
void setArithmetic(Arithmetic)
Sets which arithmetic will be used for Gram-Schmidt orthogonalizations.
void disableTransform()
Disables recording of a transformation matrix.
Represents an arbitrary precision floating point value.
void setGramSchmidtRestart(bool)
Sets that the current Gram-Schmidt method should use restarts.
const linalg::math_matrix< arithmetic::Integer > & getLattice() const
Returns the current lattice generating set as a matrix.
void bkz(double alpha=0.99, unsigned blocksize=20, BKZMode mode=BKZ_SchnorrEuchner)
Applies BKZ (or one of its variants) with given reduction parameter alpha ( ), block size blocksize a...
VerboseLevel
Specifies a warning level for a specific output message.
Describes lattice basis reduction statistics.
DIMode getDeepInsertionMode() const
Retrieves the current Deep Insertions mode.
void enableTransform(Transform=T_Normal)
Enables that from this point on, a transformation matrix is recorded.
Transform getTransformationMode() const
Queries whether transformation matrix (normal or inverse) is recorded.
BKZMode
Specifies which BKZ algorithm is used.
void setGramSchmidt(GramSchmidt)
Sets which Gram-Schmidt orthogonalization method will be used.
Represents an arithmetic context for arbitrary precision floating point values.
void setRange(unsigned begin, unsigned end=std::numeric_limits< unsigned >::max())
Retricts all algorithms to the range [begin, end].
GramSchmidt
Specifies which Gram-Schmidt orthogonalization is used.
void setMaximalCoreUsage(unsigned)
Setups the maximal number of cores which will be used by the plll library.
Header for native integer arithmetic in the plll arithmetic context framework.
Arithmetic getArithmetic() const
Returns the currently set arithmetic for Gram-Schmidt orthogonalizations.
void reset()
Resets the statistics.
unsigned long vectorinsertions
void setDeepInsertionMethod(DIMethod, DIMode=DIM_Default)
Sets the Deep Insertions method and optionally also the mode.
void setCallbackFunction(const CallbackFunction &, const CallbackFunction_LI &=CallbackFunction_LI())
Sets a callback function.
VerboseOutputLevel
Specifies the verbosity output level.
void disableAnnealingBKZ()
Disable annealing for LLL.
DIChoice
Specifies which Deep Insertion choice is used.
unsigned dimension() const
Returns the dimension of the ambient space in which the lattice exists.
const VerboseFunction & getVerboseFunction()
Retrieves the current verbose output function.
void resetStatistics()
Resets the current statistics object.
void setAnnealingLLL(const AnnealCallbackFunction &, const LLL_AnnealFunction &)
Sets annealing functions for LLL.
Represents an arbitrary precision integer.
boost::function< void(const linalg::math_matrix< arithmetic::NInt< long int > > &, unsigned, const arithmetic::NInt< long int > &)> MinCallbackFunction_LI
A callback function for newly found shortest vectors for long int lattices.
Represents a math matrix with coefficients in T.
std::pair< CallbackFunction, CallbackFunction_LI > getCallbackFunction() const
Retrieves the currently set callback function.
DIMode
Specifies which Deep Insertions mode is used.
void forceGSRebuild(bool makeSureAllComputed=false)
Forces the Gram-Schmidt coefficients to be rebuild.
void modFlip(unsigned)
Flips the signs of the given basis vector.
SVPMode getSVPMode() const
Retrieves the current SVP solver.
void setMinCallbackFunction(const MinCallbackFunction &, const MinCallbackFunction_LI &=MinCallbackFunction_LI())
Sets a minimum callback function which will be called as soon as a new shortest vector is found durin...