19#ifndef FPLLL_GSOInterface_H
20#define FPLLL_GSOInterface_H
106 row_op_first = row_op_last = -1;
225 throw std::runtime_error(
"Error: gptr == nullpointer.");
267 inline const FT &
get_r_exp(
int i,
int j,
long &expo)
const;
275 inline FT &
get_r(FT &f,
int i,
int j);
395 inline void dump_mu_d(
double *
mu,
int offset = 0,
int block_size = -1);
396 inline void dump_mu_d(vector<double>
mu,
int offset = 0,
int block_size = -1);
408 inline void dump_r_d(
double *
r,
int offset = 0,
int block_size = -1);
409 inline void dump_r_d(vector<double> &
r,
int offset = 0,
int block_size = -1);
466 void virtual babai(vector<ZT> &v,
int start = 0,
int dimension = -1);
477 void virtual babai(vector<ZT> &w,
const vector<FT> &v,
int start = 0,
int dimension = 1);
619 int row_op_first, row_op_last;
620 bool in_row_op_range(
int i) {
return i >= row_op_first && i < row_op_last; }
633 throw std::runtime_error(
"Error: gptr is equal to the nullpointer.");
636 for (
int i = 0; i < d; i++)
638 for (
int j = 0; j < d; j++)
640 gr(i, j) = sym_g(i, j);
647 os <<
"mu = " << endl;
649 os << endl <<
"r = " << endl;
654 os <<
"g = " << endl;
665 throw std::runtime_error(
"Error: gptr is equal to the nullpointer.");
668 return (i >= j) ? gr(i, j) : gr(j, i);
671template <
class ZT,
class FT>
674 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < i && j < gso_valid_cols[i] &&
675 !in_row_op_range(i));
677 expo = row_expo[i] - row_expo[j];
683template <
class ZT,
class FT>
686 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < i && j < gso_valid_cols[i] &&
687 !in_row_op_range(i));
693 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < i && j < gso_valid_cols[i] &&
694 !in_row_op_range(i));
697 f.mul_2si(f, row_expo[i] - row_expo[j]);
701template <
class ZT,
class FT>
704 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < gso_valid_cols[i] &&
705 !in_row_op_range(i));
707 expo = row_expo[i] + row_expo[j];
713template <
class ZT,
class FT>
716 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < gso_valid_cols[i] &&
717 !in_row_op_range(i));
723 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && j >= 0 && j < gso_valid_cols[i] &&
724 !in_row_op_range(i));
727 f.mul_2si(f, row_expo[i] + row_expo[j]);
733 return update_gso_row(i, i);
738 FPLLL_DEBUG_CHECK(i >= 0 && i < n_known_rows && gso_valid_cols[i] >= j && j >= 0 &&
741 if (gso_valid_cols[i] == j)
745template <
class ZT,
class FT>
748 row_addmul_we(i, j, x, 0);
760 while (n_known_rows < d)
766 for (
int i = 0; i < d; i++)
768 if (!update_gso_row(i))
778 row_op_first = first;
782template <
class ZT,
class FT>
788template <
class ZT,
class FT>
794 block_size = get_rows_of_b();
797 for (
int i = 0; i < block_size; ++i)
799 for (
int j = 0; j < block_size; ++j)
801 get_mu(e, offset + i, offset + j);
802 mu[i * block_size + j] = e.get_d();
807template <
class ZT,
class FT>
813 block_size = get_rows_of_b();
816 mu.reserve(mu.size() + block_size * block_size);
817 for (
int i = 0; i < block_size; ++i)
819 for (
int j = 0; j < block_size; ++j)
821 get_mu(e, offset + i, offset + j);
822 mu.push_back(e.get_d());
827template <
class ZT,
class FT>
833 block_size = get_rows_of_b();
836 for (
int i = 0; i < block_size; ++i)
838 get_r(e, offset + i, offset + i);
843template <
class ZT,
class FT>
849 block_size = get_rows_of_b();
852 r.reserve(r.size() + block_size * block_size);
853 for (
int i = 0; i < block_size; ++i)
855 get_r(e, offset + i, offset + i);
856 r.push_back(e.get_d());
Definition: gso_interface.h:60
vector< long > row_expo
Definition: gso_interface.h:167
int alloc_dim
Definition: gso_interface.h:558
virtual void row_addmul(int i, int j, const FT &x)
Definition: gso_interface.h:746
ZT get_max_gram()
Definition: gso_interface.cpp:55
void apply_transform(const Matrix< FT > &transform, int src_base)
Definition: gso_interface.h:380
bool cols_locked
Definition: gso_interface.h:557
vector< int > gso_valid_cols
Definition: gso_interface.h:605
const bool enable_int_gram
Definition: gso_interface.h:480
virtual void size_increased()=0
const Matrix< FT > & get_r_matrix() const
Definition: gso_interface.h:214
virtual long get_max_exp_of_b()=0
Matrix< FT > mu
Definition: gso_interface.h:572
Matrix< FT > bf
Definition: gso_interface.h:545
FT ftmp2
Definition: gso_interface.h:608
FT get_slide_potential(int start_row, int end_row, int block_size)
Return slide potential of the basis.
Definition: gso_interface.cpp:251
FT & get_r(FT &f, int i, int j)
Definition: gso_interface.h:721
const bool enable_inverse_transform
Definition: gso_interface.h:493
bool update_gso()
Definition: gso_interface.h:764
const FT & get_r_exp(int i, int j, long &expo) const
Definition: gso_interface.h:702
int n_known_rows
Definition: gso_interface.h:554
virtual void move_row(int old_r, int new_r)=0
MatGSOInterface(Matrix< ZT > &arg_u, Matrix< ZT > &arg_uinv_t, int flags)
Definition: gso_interface.h:98
void invalidate_gso_row(int i, int new_valid_cols=0)
Definition: gso_interface.cpp:26
virtual int get_cols_of_b() const =0
int n_source_rows
Definition: gso_interface.h:555
virtual ~MatGSOInterface()
Definition: gso_interface.h:624
bool update_gso_row(int i)
Definition: gso_interface.h:731
bool update_gso_row(int i, int last_j)
Definition: gso_interface.cpp:131
virtual void remove_last_rows(int n_removed_rows)=0
const FT & get_r_exp(int i, int j) const
Definition: gso_interface.h:714
FT get_log_det(int start_row, int end_row)
Return log of the (squared) determinant of the basis.
Definition: gso_interface.cpp:236
const FT & get_mu_exp(int i, int j, long &expo) const
Definition: gso_interface.h:672
virtual int get_rows_of_b() const =0
void row_op_end(int first, int last)
Definition: gso_interface.cpp:32
void dump_r_d(double *r, int offset=0, int block_size=-1)
Definition: gso_interface.h:828
Matrix< FT > gf
Definition: gso_interface.h:601
long get_max_mu_exp(int i, int n_columns)
Definition: gso_interface.cpp:88
void dump_mu_d(double *mu, int offset=0, int block_size=-1)
Definition: gso_interface.h:789
int n_known_cols
Definition: gso_interface.h:556
Matrix< ZT > * gptr
Definition: gso_interface.h:597
virtual void row_addmul_si(int i, int j, long x)=0
void remove_last_row()
Definition: gso_interface.h:753
FT ftmp1
Definition: gso_interface.h:608
void discover_all_rows()
Definition: gso_interface.h:758
void dump_mu_d(vector< double > mu, int offset=0, int block_size=-1)
Definition: gso_interface.h:808
virtual void babai(vector< ZT > &v, int start=0, int dimension=-1)
Definition: gso_interface.cpp:284
const Matrix< FT > & get_mu_matrix() const
Definition: gso_interface.h:207
const bool enable_row_expo
Definition: gso_interface.h:483
const FT & get_mu_exp(int i, int j) const
Definition: gso_interface.h:684
virtual ZT & sqnorm_coordinates(ZT &sqnorm, vector< ZT > coordinates)=0
FT & get_mu(FT &f, int i, int j)
Definition: gso_interface.h:691
virtual ZT & get_int_gram(ZT &z, int i, int j)=0
ZT ztmp1
Definition: gso_interface.h:611
double get_current_slope(int start_row, int stop_row)
Return slope of the curve fitted to the lengths of the vectors from start_row to stop_row.
Definition: gso_interface.cpp:198
virtual void row_swap(int i, int j)=0
Matrix< ZT > & u_inv_t
Definition: gso_interface.h:548
void row_op_begin(int first, int last)
Definition: gso_interface.h:783
vector< int > init_row_size
Definition: gso_interface.h:551
const bool row_op_force_long
Definition: gso_interface.h:499
int d
Definition: gso_interface.h:114
vector< long > tmp_col_expo
Definition: gso_interface.h:615
virtual void discover_row()=0
virtual void update_bf(int i)=0
void set_r(int i, int j, FT &f)
Definition: gso_interface.h:736
void create_row()
Definition: gso_interface.h:751
Matrix< FT > r
Definition: gso_interface.h:586
void print_mu_r_g(ostream &os)
Definition: gso_interface.h:645
virtual void invalidate_gram_row(int i)=0
void unlock_cols()
Definition: gso_interface.cpp:168
FT get_max_bstar()
Definition: gso_interface.cpp:79
void symmetrize_g()
Definition: gso_interface.h:629
virtual void negate_row_of_b(int i)=0
ZT & sym_g(int i, int j)
Definition: gso_interface.h:661
FT get_root_det(int start_row, int end_row)
Return (squared) root determinant of the basis.
Definition: gso_interface.cpp:226
void dump_r_d(vector< double > &r, int offset=0, int block_size=-1)
Definition: gso_interface.h:844
const Matrix< ZT > & get_g_matrix() const
Definition: gso_interface.h:221
const bool enable_transform
Definition: gso_interface.h:486
virtual bool b_row_is_zero(int i)=0
virtual void row_add(int i, int j)=0
virtual void row_sub(int i, int j)=0
Matrix< ZT > & u
Definition: gso_interface.h:547
virtual FT & get_gram(FT &f, int i, int j)=0
void lock_cols()
Definition: gso_interface.cpp:166
virtual void row_addmul_we(int i, int j, const FT &x, long expo_add)=0
void apply_transform(const Matrix< FT > &transform, int src_base, int target_base)
Definition: gso_interface.cpp:175
ZT ztmp2
Definition: gso_interface.h:613
virtual void create_rows(int n_new_rows)=0
#define FPLLL_END_NAMESPACE
Definition: defs.h:117
#define FPLLL_DEBUG_CHECK(x)
Definition: defs.h:109
#define FPLLL_BEGIN_NAMESPACE
Definition: defs.h:114
MatGSOInterfaceFlags
Definition: gso_interface.h:27
@ GSO_OP_FORCE_LONG
Definition: gso_interface.h:31
@ GSO_ROW_EXPO
Definition: gso_interface.h:30
@ GSO_INT_GRAM
Definition: gso_interface.h:29
@ GSO_DEFAULT
Definition: gso_interface.h:28
void adjust_radius_to_gh_bound(FT &max_dist, long max_dist_expo, int block_size, const FT &root_det, double gh_factor)
Use Gaussian Heuristic to compute a bound on the length of the shortest vector.
Definition: gso_interface.cpp:267