Skip to content

Commit

Permalink
unify template param names
Browse files Browse the repository at this point in the history
  • Loading branch information
malb committed Jul 8, 2017
1 parent 26d8590 commit c0db87a
Show file tree
Hide file tree
Showing 8 changed files with 562 additions and 521 deletions.
232 changes: 116 additions & 116 deletions src/fpylll/fplll/bkz.pyx

Large diffs are not rendered by default.

240 changes: 139 additions & 101 deletions src/fpylll/fplll/decl.pxd

Large diffs are not rendered by default.

110 changes: 55 additions & 55 deletions src/fpylll/fplll/enumeration.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ from fplll cimport EVALMODE_SV

from fplll cimport dpe_t
from fpylll.mpfr.mpfr cimport mpfr_t
from decl cimport mpz_d, mpz_ld, mpz_dpe, mpz_mpfr, fp_nr_t
from decl cimport gso_mpz_d, gso_mpz_ld, gso_mpz_dpe, gso_mpz_mpfr, fp_nr_t
from decl cimport d_t, ld_t
from fplll cimport FT_DOUBLE, FT_LONG_DOUBLE, FT_DPE, FT_MPFR, FloatType

from fplll cimport multimap

IF HAVE_QD:
from fpylll.qd.qd cimport dd_real, qd_real
from decl cimport mpz_dd, mpz_qd
from decl cimport gso_mpz_dd, gso_mpz_qd, dd_t, qd_t
from fplll cimport FT_DD, FT_QD

class EnumerationError(Exception):
Expand All @@ -53,19 +53,19 @@ cdef class Enumeration:
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[longdouble]] *m_ld
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[dpe_t]] *m_dpe
IF HAVE_QD:
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[dd_real]] *m_dd
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[qd_real]] *m_qd
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[dd_t]] *m_dd
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[qd_t]] *m_qd
cdef MatGSO_c[Z_NR[mpz_t], FP_NR[mpfr_t]] *m_mpfr

self.M = M

if M._type == mpz_d:
if M._type == gso_mpz_d:
m_double = M._core.mpz_d
self._fe_core.double = new FastEvaluator_c[FP_NR[double]](nr_solutions,
self._fe_core.d = new FastEvaluator_c[FP_NR[double]](nr_solutions,
strategy,
False)
self._core.double = new Enumeration_c[FP_NR[double]](m_double[0], self._fe_core.double[0])
elif M._type == mpz_ld:
self._core.d = new Enumeration_c[FP_NR[double]](m_double[0], self._fe_core.d[0])
elif M._type == gso_mpz_ld:
IF HAVE_LONG_DOUBLE:
m_ld = M._core.mpz_ld
self._fe_core.ld = new FastEvaluator_c[FP_NR[longdouble]](nr_solutions,
Expand All @@ -74,13 +74,13 @@ cdef class Enumeration:
self._core.ld = new Enumeration_c[FP_NR[longdouble]](m_ld[0], self._fe_core.ld[0])
ELSE:
raise RuntimeError("MatGSO object '%s' has no core."%self)
elif M._type == mpz_dpe:
elif M._type == gso_mpz_dpe:
m_dpe = M._core.mpz_dpe
self._fe_core.dpe = new FastEvaluator_c[FP_NR[dpe_t]](nr_solutions,
strategy,
False)
self._core.dpe = new Enumeration_c[FP_NR[dpe_t]](m_dpe[0], self._fe_core.dpe[0])
elif M._type == mpz_mpfr:
elif M._type == gso_mpz_mpfr:
m_mpfr = M._core.mpz_mpfr
self._fe_core.mpfr = new FastErrorBoundedEvaluator_c(M.d,
M._core.mpz_mpfr.get_mu_matrix(),
Expand All @@ -92,42 +92,42 @@ cdef class Enumeration:
self._core.mpfr = new Enumeration_c[FP_NR[mpfr_t]](m_mpfr[0], self._fe_core.mpfr[0])
else:
IF HAVE_QD:
if M._type == mpz_dd:
if M._type == gso_mpz_dd:
m_dd = M._core.mpz_dd
self._fe_core.dd = new FastEvaluator_c[FP_NR[dd_real]](nr_solutions,
self._fe_core.dd = new FastEvaluator_c[FP_NR[dd_t]](nr_solutions,
strategy,
False)
self._core.dd = new Enumeration_c[FP_NR[dd_real]](m_dd[0], self._fe_core.dd[0])
elif M._type == mpz_qd:
self._core.dd = new Enumeration_c[FP_NR[dd_t]](m_dd[0], self._fe_core.dd[0])
elif M._type == gso_mpz_qd:
m_qd = M._core.mpz_qd
self._fe_core.qd = new FastEvaluator_c[FP_NR[qd_real]](nr_solutions,
self._fe_core.qd = new FastEvaluator_c[FP_NR[qd_t]](nr_solutions,
strategy,
False)
self._core.qd = new Enumeration_c[FP_NR[qd_real]](m_qd[0], self._fe_core.qd[0])
self._core.qd = new Enumeration_c[FP_NR[qd_t]](m_qd[0], self._fe_core.qd[0])
else:
raise RuntimeError("MatGSO object '%s' has no core."%self)
ELSE:
raise RuntimeError("MatGSO object '%s' has no core."%self)

def __dealloc__(self):
if self.M._type == mpz_d:
del self._fe_core.double
del self._core.double
if self.M._type == gso_mpz_d:
del self._fe_core.d
del self._core.d
IF HAVE_LONG_DOUBLE:
if self.M._type == mpz_ld:
if self.M._type == gso_mpz_ld:
del self._fe_core.ld
del self._core.ld
if self.M._type == mpz_dpe:
if self.M._type == gso_mpz_dpe:
del self._fe_core.dpe
del self._core.dpe
IF HAVE_QD:
if self.M._type == mpz_dd:
if self.M._type == gso_mpz_dd:
del self._fe_core.dd
del self._core.dd
if self.M._type == mpz_qd:
if self.M._type == gso_mpz_qd:
del self._fe_core.qd
del self._core.qd
if self.M._type == mpz_mpfr:
if self.M._type == gso_mpz_mpfr:
del self._fe_core.mpfr
del self._core.mpfr

Expand All @@ -150,13 +150,13 @@ cdef class Enumeration:
cdef int block_size = last-first
cdef fp_nr_t tmp

cdef vector[FP_NR[double]] target_coord_d
cdef vector[FP_NR[d_t]] target_coord_d
IF HAVE_LONG_DOUBLE:
cdef vector[FP_NR[longdouble]] target_coord_ld
cdef vector[FP_NR[ld_t]] target_coord_ld
cdef vector[FP_NR[dpe_t]] target_coord_dpe
IF HAVE_QD:
cdef vector[FP_NR[dd_real]] target_coord_dd
cdef vector[FP_NR[qd_real]] target_coord_qd
cdef vector[FP_NR[dd_t]] target_coord_dd
cdef vector[FP_NR[qd_t]] target_coord_qd
cdef vector[FP_NR[mpfr_t]] target_coord_mpfr

cdef vector[double] sub_tree_
Expand All @@ -175,13 +175,13 @@ cdef class Enumeration:
pruning_.push_back(pruning[i])

cdef double max_dist__ = max_dist
cdef FP_NR[double] max_dist_d = max_dist__
cdef FP_NR[d_t] max_dist_d = max_dist__
IF HAVE_LONG_DOUBLE:
cdef FP_NR[longdouble] max_dist_ld = max_dist__
cdef FP_NR[ld_t] max_dist_ld = max_dist__
cdef FP_NR[dpe_t] max_dist_dpe = max_dist__
IF HAVE_QD:
cdef FP_NR[dd_real] max_dist_dd = max_dist__
cdef FP_NR[qd_real] max_dist_qd = max_dist__
cdef FP_NR[dd_t] max_dist_dd = max_dist__
cdef FP_NR[qd_t] max_dist_qd = max_dist__
cdef FP_NR[mpfr_t] max_dist_mpfr = max_dist__

solutions = []
Expand All @@ -190,24 +190,24 @@ cdef class Enumeration:
cdef multimap[FP_NR[longdouble], vector[FP_NR[longdouble]]].reverse_iterator solutions_ld
cdef multimap[FP_NR[dpe_t], vector[FP_NR[dpe_t]]].reverse_iterator solutions_dpe
IF HAVE_QD:
cdef multimap[FP_NR[dd_real], vector[FP_NR[dd_real]]].reverse_iterator solutions_dd
cdef multimap[FP_NR[qd_real], vector[FP_NR[qd_real]]].reverse_iterator solutions_qd
cdef multimap[FP_NR[dd_t], vector[FP_NR[dd_t]]].reverse_iterator solutions_dd
cdef multimap[FP_NR[qd_t], vector[FP_NR[qd_t]]].reverse_iterator solutions_qd
cdef multimap[FP_NR[mpfr_t], vector[FP_NR[mpfr_t]]].reverse_iterator solutions_mpfr

if self.M._type == mpz_d:
if self.M._type == gso_mpz_d:
if target is not None:
for it in target:
tmp.double = float(it)
target_coord_d.push_back(tmp.double)
tmp.d = float(it)
target_coord_d.push_back(tmp.d)
sig_on()
self._core.double.enumerate(first, last, max_dist_d, max_dist_expo,
target_coord_d, sub_tree_, pruning_, dual)
self._core.d.enumerate(first, last, max_dist_d, max_dist_expo,
target_coord_d, sub_tree_, pruning_, dual)
sig_off()
if not self._fe_core.double.size():
if not self._fe_core.d.size():
raise EnumerationError("No vector found.")

solutions_d = self._fe_core.double.begin()
while solutions_d != self._fe_core.double.end():
solutions_d = self._fe_core.d.begin()
while solutions_d != self._fe_core.d.end():
cur_dist = deref(solutions_d).first.get_d()
cur_sol = []
for j in range(deref(solutions_d).second.size()):
Expand All @@ -216,7 +216,7 @@ cdef class Enumeration:
inc(solutions_d)

IF HAVE_LONG_DOUBLE:
if self.M._type == mpz_ld:
if self.M._type == gso_mpz_ld:
if target is not None:
for it in target:
tmp.ld = float(it)
Expand All @@ -237,7 +237,7 @@ cdef class Enumeration:
solutions.append([tuple(cur_sol), cur_dist])
inc(solutions_ld)

if self.M._type == mpz_dpe:
if self.M._type == gso_mpz_dpe:
if target is not None:
for it in target:
tmp.dpe = float(it)
Expand All @@ -259,7 +259,7 @@ cdef class Enumeration:
inc(solutions_dpe)

IF HAVE_QD:
if self.M._type == mpz_dd:
if self.M._type == gso_mpz_dd:
if target is not None:
for it in target:
tmp.dd = float(it)
Expand All @@ -280,7 +280,7 @@ cdef class Enumeration:
solutions.append([tuple(cur_sol), cur_dist])
inc(solutions_dd)

if self.M._type == mpz_qd:
if self.M._type == gso_mpz_qd:
if target is not None:
for it in target:
tmp.qd = float(it)
Expand All @@ -301,7 +301,7 @@ cdef class Enumeration:
solutions.append([tuple(cur_sol), cur_dist])
inc(solutions_qd)

if self.M._type == mpz_mpfr:
if self.M._type == gso_mpz_mpfr:
if target is not None:
for it in target:
tmp.mpfr = float(it)
Expand All @@ -327,18 +327,18 @@ cdef class Enumeration:
def get_nodes(self):
"""Return number of visited nodes in last enumeration call.
"""
if self.M._type == mpz_d:
return self._core.double.get_nodes()
if self.M._type == gso_mpz_d:
return self._core.d.get_nodes()
IF HAVE_LONG_DOUBLE:
if self.M._type == mpz_ld:
if self.M._type == gso_mpz_ld:
return self._core.ld.get_nodes()
if self.M._type == mpz_dpe:
if self.M._type == gso_mpz_dpe:
return self._core.dpe.get_nodes()
IF HAVE_QD:
if self.M._type == mpz_dd:
if self.M._type == gso_mpz_dd:
return self._core.dd.get_nodes()
if self.M._type == mpz_qd:
if self.M._type == gso_mpz_qd:
return self._core.qd.get_nodes()
if self.M._type == mpz_mpfr:
if self.M._type == gso_mpz_mpfr:
return self._core.mpfr.get_nodes()

0 comments on commit c0db87a

Please sign in to comment.