25#ifndef ENUMLIB_ENUMERATION_HPP
26#define ENUMLIB_ENUMERATION_HPP
85template <
int N,
int SWIRLY,
int SWIRLY2BUF,
int SWIRLY1FRACTION,
bool findsubsols = false>
111 array<float_type, N + 1>
_l;
126 inline int myround(
double a) {
return (
int)(round(a)); }
127 inline int myround(
float a) {
return (
int)(roundf(a)); }
128 inline int myround(
long double a) {
return (
int)(roundl(a)); }
142 for (
int k = 0; k <
N; ++k)
144 for (
int k = 0; k <
N; ++k)
150 template <
int i,
bool svp,
int swirl,
int swirl
id>
struct i_tag
154 template <
int i,
bool svp,
int swirl,
int swirl
id>
157 if (
_r[i] >
_r[i - 1])
172 for (
int j = i + 1; j <
N; ++j)
178 _Dx[i] =
_D2x[i] = (((int)(yi >= 0) & 1) << 1) - 1;
183 for (
int j =
_r[i - 1]; j > i - 1; --j)
194 if (
_l[i + 1] == 0.0)
221 template <
bool svp,
int swirl,
int swirl
id>
224 static const int i = 0;
238 for (
int j = i + 1; j <
N; ++j)
244 _Dx[i] =
_D2x[i] = (((int)(yi >= 0) & 1) << 1) - 1;
257 if (
_l[i + 1] == 0.0)
280 template <
bool svp,
int swirl,
int swirl
id>
283 if (
_l[0] >
_AA[0] ||
_l[0] == 0.0)
288 for (
int j = 0; j <
N; ++j)
295 for (
size_t j = 0; j <
globals.signal.size(); ++j)
302 template <
bool svp,
int swirl,
int swirl
id>
306 template <
bool svp,
int swirl,
int swirl
id>
313 if (
_r[i] >
_r[i - 1])
329 for (
int j = i + 1; j <
N; ++j)
337 _Dx[i] =
_D2x[i] = (((int)(yi >= 0) & 1) << 1) - 1;
339 for (
int j =
_r[i - 1]; j > i - 1; --j)
349 globals.swirlys[swirlid].emplace_back();
350 for (
int j = i; j <
N; ++j)
351 globals.swirlys[swirlid].back().first[j] =
_x[j];
352 globals.swirlys[swirlid].back().second.first =
_l[i];
353 globals.swirlys[swirlid].back().second.second = li2;
355 if (
_l[i + 1] == 0.0)
384 for (
size_t i = 0; i <
globals.signal.size(); ++i)
391 for (
int j = 0; j <
N; ++j)
398 for (
int k = 0; k <
N; ++k)
409#ifdef SINGLE_THREADED
412 auto &swirlys =
globals.swirlys;
418 {
return l.second.second < r.second.second; };
421 sort(swirlys[0].begin(), swirlys[0].end(), swirl_less);
424 size_t swirly0idx = 0;
426 while (swirly0idx < swirlys[0].size())
428 int swirly1newstart = (int)(swirlys[1].size());
429 while (swirly0idx < swirlys[0].size() && swirlys[1].size() < SWIRLY2BUF)
431 const int i =
N - SWIRLY;
432 _x = swirlys[0][swirly0idx].first;
433 _l[i] = swirlys[0][swirly0idx].second.first;
434 for (
int j = 0; j <
N; ++j)
436 for (
int j =
N - 1; j > i - 1; --j)
444 size_t swirly1end = (int)(swirlys[1].size());
448 sort(swirlys[1].begin() + swirly1newstart, swirlys[1].end(), swirl_less);
450 inplace_merge(swirlys[1].begin(), swirlys[1].begin() + swirly1newstart, swirlys[1].end(),
454 swirly1end = (SWIRLY2BUF >> SWIRLY1FRACTION);
455 if (swirly1end > swirlys[1].size())
456 swirly1end = swirlys[1].size();
459 auto &swirly_ref = swirlys[1];
460 std::atomic<std::size_t> swirly_i(0);
462 auto f = [
this, &swirly_ref, &swirly_i, swirly1end, &
threadid]()
469 for (
int j = 0; j <
N - SWIRLY; ++j)
470 mylat._counts[j] = 0;
473 std::size_t idx = swirly_i++;
474 if (idx >= swirly1end)
477 const int i =
N - 2 * SWIRLY;
478 mylat._x = swirly_ref[idx].first;
479 mylat._l[i] = swirly_ref[idx].second.first;
480 for (
int j = 0; j <
N; ++j)
482 for (
int j =
N - 1; j > i - 1; --j)
483 mylat._sigT[i - 1][j - 1] = mylat._sigT[i - 1][j] - mylat._x[j] * mylat.muT[i - 1][j];
485 mylat._thread_local_update();
491 for (
int j = 0; j <
N - SWIRLY; ++j)
492 this->_counts[j] += mylat._counts[j];
493 for (
int j = 0; j <
N; ++j)
494 if (mylat._subsolL[j] < this->_subsolL[j])
496 this->_subsolL[j] = mylat._subsolL[j];
497 this->_subsol[j] = mylat._subsol[j];
504 swirlys[1].erase(swirlys[1].begin(), swirlys[1].begin() + swirly1end);
void push(const std::function< void()> &f)
Definition: thread_pool.hpp:214
void wait_work()
Definition: thread_pool.hpp:200
#define FPLLL_END_NAMESPACE
Definition: defs.h:117
#define FPLLL_BEGIN_NAMESPACE
Definition: defs.h:114
fplll_extenum_enumf std::function< extenum_cb_set_config > std::function< extenum_cb_process_sol > std::function< extenum_cb_process_subsol > bool bool findsubsols
Definition: enumerate_ext_api.h:92
Definition: enumeration.h:53
std::lock_guard< std::mutex > lock_type
Definition: enumeration.h:63
array< atomic_int_fast8_t, 256 > global_signal_t
Definition: enumeration.h:66
::fplll::enumf fplll_float
Definition: fplll_types.h:36
fplll_float float_type
Definition: enumeration.h:61
std::mutex mutex_type
Definition: enumeration.h:62
atomic< float_type > global_A_t
Definition: enumeration.h:65
Definition: enumeration.h:69
std::function< extenum_cb_process_subsol > process_subsol
Definition: enumeration.h:78
mutex_type mutex
Definition: enumeration.h:73
global_A_t A
Definition: enumeration.h:74
pair< introw_t, pair< float_type, float_type > > swirl_item_t
Definition: enumeration.h:71
vector< vector< swirl_item_t > > swirlys
Definition: enumeration.h:80
global_signal_t signal
Definition: enumeration.h:75
std::function< extenum_cb_process_sol > process_sol
Definition: enumeration.h:77
array< int, N > introw_t
Definition: enumeration.h:70
Definition: enumeration.h:151
Definition: enumeration.h:87
fltrow_t risq
Definition: enumeration.h:94
introw_t _D2x
Definition: enumeration.h:107
fltrow_t _sol
Definition: enumeration.h:108
std::chrono::system_clock::time_point starttime
Definition: enumeration.h:119
fltrow_t pr2
Definition: enumeration.h:96
void enumerate_recur(i_tag< N+1, svp, swirl, swirlid >)
Definition: enumeration.h:303
lattice_enum_t(globals_t< N > &globals_)
Definition: enumeration.h:121
introw_t _x
Definition: enumeration.h:107
int myround(float a)
Definition: enumeration.h:127
fltrow_t _AA
Definition: enumeration.h:106
void enumerate_recur(i_tag<-1, svp, swirl, swirlid >)
Definition: enumeration.h:281
array< float_type, N+1 > _l
Definition: enumeration.h:111
void _update_AA()
Definition: enumeration.h:140
fltrow_t _AA2
Definition: enumeration.h:106
void _thread_local_update()
Definition: enumeration.h:130
fltrow_t pr
Definition: enumeration.h:95
float_type _A
Definition: enumeration.h:105
introw_t _r
Definition: enumeration.h:110
globals_t< N > & globals
Definition: enumeration.h:103
bool activeswirly
Definition: enumeration.h:99
pair< introw_t, pair< float_type, float_type > > swirl_item_t
Definition: enumeration.h:90
float_type muT[N][N]
Definition: enumeration.h:93
void enumerate_recur(i_tag< 0, svp, swirl, swirlid >)
Definition: enumeration.h:222
int threadid
Definition: enumeration.h:102
fltrow_t _c
Definition: enumeration.h:109
float_type _sigT[N][N]
Definition: enumeration.h:114
int myround(double a)
Definition: enumeration.h:126
fltrow_t _subsolL
Definition: enumeration.h:116
void enumerate_recur(i_tag< N+2, svp, swirl, swirlid >)
Definition: enumeration.h:307
int myround(long double a)
Definition: enumeration.h:128
void enumerate_recur(i_tag< i, svp, swirl, swirlid >)
Definition: enumeration.h:155
void enumerate_recursive()
Definition: enumeration.h:382
void enumerate_recur(i_tag< i, svp, i, swirlid >)
Definition: enumeration.h:311
array< int, N > introw_t
Definition: enumeration.h:89
array< fltrow_t, N > _subsol
Definition: enumeration.h:117
array< uint64_t, N+1 > _counts
Definition: enumeration.h:112
introw_t _Dx
Definition: enumeration.h:107
array< float_type, N > fltrow_t
Definition: enumeration.h:88
#define N
Read matrix from input_filename.
Definition: test_pruner.cpp:34
FPLLL_BEGIN_NAMESPACE thread_pool::thread_pool threadpool
Definition: threadpool.cpp:20
int get_threads()
Definition: threadpool.cpp:23
FPLLL_BEGIN_NAMESPACE typedef std::mutex mutex
Definition: threadpool.h:25