/usr/include/fplll/lll.h is in libfplll-dev 5.2.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | /* Copyright (C) 2005-2008 Damien Stehle.
Copyright (C) 2007 David Cade.
Copyright (C) 2011 Xavier Pujol.
This file is part of fplll. fplll is free software: you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation,
either version 2.1 of the License, or (at your option) any later version.
fplll is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with fplll. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FPLLL_LLL_H
#define FPLLL_LLL_H
#include "gso.h"
#include "gso_interface.h"
FPLLL_BEGIN_NAMESPACE
/* The precision of FT must be defined before creating an instance of
LLLReduction. The matrix b can be modified between each call to lll. */
template <class ZT, class FT> class LLLReduction
{
public:
/**
* Constructor.
* The precision of FT must be defined before creating an instance of the
* class and must remain the same until the object is destroyed (or no longer
* needed).
*/
LLLReduction(MatGSOInterface<ZT, FT> &m, double delta, double eta, int flags);
#ifdef FPLLL_WITH_LONG_DOUBLE
~LLLReduction() { LDConvHelper::free(); }
#endif
/**
@brief LLL reduction.
@param kappa_min minimal index to go back to
@param kappa_start index to start processing at
@param kappa_end end index (exclusive)
@param size_reduction_start only perform size reductions using vectors starting at this index
@return success or failure (due to numerical instability)
*/
bool lll(int kappa_min = 0, int kappa_start = 0, int kappa_end = -1,
int size_reduction_start = 0);
/**
@brief Size reduction.
Perform size reduction for all vectors between `kappa_start` and `kappa_end`.
@param kappa_min start index
@param kappa_end end index (exclusive)
@param size_reduction_start only perform size reductions using vectors starting at this index
@return success or failure (due to numerical instability)
*/
inline bool size_reduction(int kappa_min = 0, int kappa_end = -1, int size_reduction_start = 0);
int status;
int final_kappa;
int last_early_red;
int zeros;
int n_swaps;
private:
/**
@brief Size reduction.
@param kappa index to size reduce
@param size_reduction_end only perform size reductions using vectors up to this index
@param size_reduction_start only perform size reductions using vectors starting at this index
@return
*/
bool babai(int kappa, int size_reduction_end, int size_reduction_start = 0);
inline bool early_reduction(int start, int size_reduction_start = 0);
inline void print_params();
inline bool set_status(int new_status);
MatGSOInterface<ZT, FT> &m;
FT delta, eta, swap_threshold;
bool enable_early_red;
bool siegel;
bool verbose;
vector<FT> lovasz_tests;
vector<FT> babai_mu;
vector<long> babai_expo;
ZT ztmp1;
FT mu_m_ant, ftmp1;
};
template <class ZT, class FT>
bool is_lll_reduced(MatGSOInterface<ZT, FT> &m, double delta, double eta);
template <class ZT, class FT>
inline bool LLLReduction<ZT, FT>::size_reduction(int kappa_min, int kappa_end,
int size_reduction_start)
{
if (kappa_end == -1)
kappa_end = m.d;
for (int k = kappa_min; k < kappa_end; k++)
{
if ((k > 0 && !babai(k, k, size_reduction_start)) || !m.update_gso_row(k))
return false;
}
return set_status(RED_SUCCESS);
}
template <class ZT, class FT>
inline bool LLLReduction<ZT, FT>::early_reduction(int start, int size_reduction_start)
{
m.lock_cols();
if (verbose)
{
cerr << "Early reduction start=" << start + 1 << endl;
}
for (int i = start; i < m.d; i++)
{
if (!babai(i, start, size_reduction_start))
return false;
}
m.unlock_cols();
last_early_red = start;
return true;
}
template <class ZT, class FT> inline void LLLReduction<ZT, FT>::print_params()
{
cerr << "Entering LLL"
<< "\ndelta = " << delta << "\neta = " << eta << "\nprecision = " << FT::get_prec()
<< "\nexact_dot_product = " << static_cast<int>(m.enable_int_gram)
<< "\nrow_expo = " << static_cast<int>(m.enable_row_expo)
<< "\nearly_red = " << static_cast<int>(enable_early_red)
<< "\nsiegel_cond = " << static_cast<int>(siegel)
<< "\nlong_in_babai = " << static_cast<int>(m.row_op_force_long) << endl;
}
template <class ZT, class FT> inline bool LLLReduction<ZT, FT>::set_status(int new_status)
{
status = new_status;
if (verbose)
{
if (status == RED_SUCCESS)
cerr << "End of LLL: success" << endl;
else
cerr << "End of LLL: failure: " << RED_STATUS_STR[status] << endl;
}
return status == RED_SUCCESS;
}
FPLLL_END_NAMESPACE
#endif
|