/usr/include/linbox/algorithms/lattice.h is in liblinbox-dev 1.3.2-1.1.
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | /* linbox/algorithms/lattice.h
* Copyright (C) 2011 The LinBox group
* Written by Brice Boyer <bboyer@imag.fr>
*
* ========LICENCE========
* This file is part of the library LinBox.
*
* LinBox 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.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*/
#ifndef __LINBOX_algorithms_lattice_H
#define __LINBOX_algorithms_lattice_H
/*! @file algorithms/lattice.h
* @brief LLL reduction
* @ingroup algorithms
* @ingroup lattice
*
* This is an interface to NTL/FPLLL.
*
* @todo Create a BlasMatrix<NTL_ZZ> that is just like a mat_ZZ !
* @todo Create a BlasMatrix<FPLLL_ZZ> that is just like a IntMatrix !
* @todo This will avoid copy back/forth a BlasMatrix<PID_integer>
*/
#if !defined(__LINBOX_HAVE_FPLLL) && !defined(__LINBOX_HAVE_NTL)
#error "you need either FPLLL or NTL here"
#endif
#ifdef __LINBOX_HAVE_NTL
#include <NTL/LLL.h>
#endif
#ifdef __LINBOX_HAVE_FPLLL
// this is a damn FPLLL bug !!!
namespace FPLLL {
#define round
#define trunc
#include <fplll/fplll.h>
#include <fplll/heuristic.h>
#include <fplll/proved.h>
#include <fplll/wrapper.h>
#undef round
#undef trunc
}
#endif
namespace LinBox
{ /* Methods */
/*! NTL methods.
*
* This lists the methods implemented.
*/
class latticeMethod {
public:
struct genericMethod {};
#ifdef __LINBOX_HAVE_NTL
/*! NTL_LLL.
* This is NTL's LLL
* The Defaults are NTL's
*/
struct latticeNTL_LLL : public virtual genericMethod {
public :
enum localMeth { FP , XD , QP, RR } ;
private :
double _delta ;
long _deep ;
// LLLCheckFct
enum localMeth _met ;
bool _givens ; // true for Givens
public :
latticeNTL_LLL() :
_delta(0.99),
_deep(0),
_met(XD),
_givens(false)
{}
void setDelta(const double & delta)
{
_delta = delta ;
}
void setDepth(const long & deep)
{
_deep = deep ;
}
void setMet( enum localMeth met )
{
_met = met ;
}
void setGivens (bool giv )
{
_givens = giv ;
}
double getDelta() const
{
return _delta ;
}
long getDepth() const
{
return _deep ;
}
enum localMeth getMeth() const
{
return _met ;
}
bool givens() const
{
return _givens ;
}
};
/*! NTL_BKZ.
* This is NTL's BKZ.
* The Defaults are NTL's
*/
struct latticeNTL_BKZ : public virtual genericMethod {
enum localMeth { FP , XD , QP, RR } ;
private :
double _delta ;
long _bsize ;
long _prune ;
// LLLCheckFct
enum localMeth _met ;
bool _givens ;
public :
latticeNTL_BKZ() :
_delta(0.99),
_bsize(10),
_prune(0),
_met(XD),
_givens(false)
{}
void setDelta(const double & delta)
{
_delta = delta ;
}
void setBlockSize(const long & bsize)
{
_bsize = bsize ;
}
void setPrune( const long & prune)
{
_prune = prune ;
}
void setMet( enum localMeth met )
{
_met = met ;
}
void setGivens (bool giv )
{
_givens = giv ;
}
double getDelta() const
{
return _delta ;
}
long getBlockSize() const
{
return _bsize ;
}
long getPrune() const
{
return _prune ;
}
enum localMeth getMeth() const
{
return _met ;
}
bool givens() const
{
return _givens ;
}
};
#endif // __LINBOX_HAVE_NTL
#ifdef __LINBOX_HAVE_FPLLL
/*! FPLLL LLL.
* Wrapper to fplll
* Babai,GetBase not implemented,
* so class is not stored there yet.
*/
// template<class ZT, class FT>
struct latticeFPLLL : public virtual genericMethod {
enum localMeth {
P //!< proved
, H //!< heuristic
, W //!< wrapper
} ;
private :
int _pres ;
double _eta ;
double _delta ;
int _siegel ;
enum localMeth _met;
// proved<ZT,FT> * _meth1 ;
// heuristic<ZT,FT> * _meth2 ;
// wrapper * _meth3 ;
public :
latticeFPLLL() :
_pres (0),
_eta(0.51),
_delta(0.99),
_siegel(0),
_met(P)
{}
void setPrecision(int pres)
{
_pres = pres ;
}
void setEta(double eta)
{
_eta = eta ;
}
void setDelta(double delta)
{
_delta = delta ;
}
void setSiegel(int siegel)
{
_siegel = siegel ;
}
void setMeth(enum localMeth met)
{
_met = met ;
}
int getPrecision() const
{
return _pres;
}
double getEta() const
{
return _eta;
}
double getDelta() const
{
return _delta;
}
int getSiegel() const
{
return _siegel;
}
enum localMeth getMeth() const
{
return _met;
}
};
#endif // __LINBOX_HAVE_FPLLL
};
} // LinBox
#include "linbox/algorithms/lattice.inl"
#ifdef __LINBOX_HAVE_FPLLL
#define defaultLllMeth latticeMethod::latticeFPLLL
#else
#define defaultLllMeth latticeMethod::latticeNTL_LLL
#endif
namespace LinBox
{
template<class Ring, class myMethod>
void lllReduceIn(BlasMatrix<Ring> & H,
const myMethod & meth = defaultLllMeth())
{
Ring Z ;
BlasMatrix<Ring> U(Z,0,0);
const bool withU = false;
lllReduceInBase<Ring,withU>(H,U,meth);
}
template<class Ring, class myMethod>
void lllReduceIn(BlasMatrix<Ring> & H,
BlasMatrix<Ring> & U,
const myMethod & meth = defaultLllMeth())
{
const bool withU = true;
lllReduceInBase<Ring,withU>(H,U,meth);
}
template<class Ring, class myMethod>
void lllReduce(BlasMatrix<Ring> & H,
const BlasMatrix<Ring> & A,
const myMethod & meth = defaultLllMeth())
{
H = A ;
lllReduceIn<Ring>(H,meth);
}
template<class Ring, class myMethod>
void lllReduce(BlasMatrix<Ring> & H,
BlasMatrix<Ring> & U,
const BlasMatrix<Ring> & A,
const myMethod & meth = defaultLllMeth())
{
H = A ;
lllReduceIn<Ring>(H,U,meth);
}
}
#undef defaultLllMeth
#endif // __LINBOX_algorithms_lattice_H
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,:0,t0,+0,=s
// Local Variables:
// mode: C++
// tab-width: 8
// indent-tabs-mode: nil
// c-basic-offset: 8
// End:
|