Variable Lovász condition parameter

Former-commit-id: 726d5c1b1dc03a5b11f8d7b32e6bf589efec369d
This commit is contained in:
Marek Nečada 2019-08-25 21:17:23 +03:00
parent 953132e4c9
commit 4d4ab9936b
4 changed files with 8 additions and 6 deletions

View File

@ -72,7 +72,8 @@ static inline point2d point2d_fromxy(const double x, const double y) {
*/
int qpms_reduce_lattice_basis(double *b, ///< Array of dimension [bsize][ndim].
const size_t bsize, ///< Number of the basis vectors (dimensionality of the lattice).
const size_t ndim ///< Dimension of the space into which the lattice is embedded.
const size_t ndim, ///< Dimension of the space into which the lattice is embedded.
double delta
);
/// Generic lattice point generator type.

View File

@ -38,7 +38,8 @@ static void gram_schmidt(
static inline double fsq(double x) { return x * x; };
// A naïve implementation of Lenstra-Lenstra-Lovász algorithm.
int qpms_reduce_lattice_basis(double *b, const size_t bsize, const size_t ndim)
int qpms_reduce_lattice_basis(double *b, const size_t bsize, const size_t ndim,
double delta)
{
QPMS_ENSURE(bsize <= ndim,
"The basis must have less elements (%zd) than the space dimension (%zd).",
@ -59,7 +60,7 @@ int qpms_reduce_lattice_basis(double *b, const size_t bsize, const size_t ndim)
}
// Step 2
if (k > 0 && // Case 1
bstar_sqnorm[k] < (0.75 - fsq(mu[mu_index(k, k-1)])) * bstar_sqnorm[k-1]) {
bstar_sqnorm[k] < (delta - fsq(mu[mu_index(k, k-1)])) * bstar_sqnorm[k-1]) {
// swap b(k) and b(k-1)
cblas_dswap(ndim, &b[k*ndim], 1, &b[(k-1)*ndim], 1);
double B_k = bstar_sqnorm[k];

View File

@ -610,7 +610,7 @@ def gamma_inc_CF(double a, cdouble x):
cx_gamma_inc_CF_e(a, x, &res)
return (res.val, res.err)
def lll_reduce(basis):
def lll_reduce(basis, double delta=0.75):
"""
Lattice basis reduction with the Lenstra-Lenstra-Lovász algorithm.
@ -630,7 +630,7 @@ def lll_reduce(basis):
"the dimensionality of the lattice (%d) embedded into it."
% (d, n))
cdef double [:,:] basis_view = basis
if 0 != qpms_reduce_lattice_basis(&basis_view[0,0], n, d):
if 0 != qpms_reduce_lattice_basis(&basis_view[0,0], n, d, delta):
raise RuntimeError("Something weird happened")
return basis

View File

@ -209,7 +209,7 @@ cdef extern from "lattices.h":
PGEN_1D_INC_TOWARDS_ORIGIN
PGen PGen_1D_new_minMaxR(double period, double offset, double minR, bint inc_minR,
double maxR, bint inc_maxR, PGen_1D_incrementDirection incdir)
int qpms_reduce_lattice_basis(double *b, size_t bsize, size_t ndim)
int qpms_reduce_lattice_basis(double *b, size_t bsize, size_t ndim, double delta)
cdef extern from "quaternions.h":