Skip to content
Snippets Groups Projects
Verified Commit 1c9d73ce authored by Herbers, Maik's avatar Herbers, Maik
Browse files

discriminant_form: Remove redundant computations.

* src/discriminant_form.cpp (internal::babai_near_vector): Take inverse
of `trans' as parameter.
(DiscriminantForm::theta_series_direct): Compute `trans_inv' here and
pass it as argument, calculate `::get_gram_wrt_smith_basis' only once.
parent 2a24d0b9
No related branches found
No related tags found
No related merge requests found
...@@ -92,9 +92,9 @@ namespace weil ...@@ -92,9 +92,9 @@ namespace weil
} }
mpq_vector mpq_vector
babai_near_vector(const mpq_matrix& trans, const mpq_vector& v) babai_near_vector(const mpq_matrix& trans, const mpq_matrix& trans_inv, const mpq_vector& v)
{ {
mpq_vector mapped{ trans.inverse() * v }; mpq_vector mapped{ trans_inv * v };
mpq_vector rounded{ v.rows() }; mpq_vector rounded{ v.rows() };
// round to nearest integer // round to nearest integer
for (int64_t i = 0; i < v.rows(); i++) { for (int64_t i = 0; i < v.rows(); i++) {
...@@ -405,13 +405,14 @@ start_printing: ...@@ -405,13 +405,14 @@ start_printing:
const mpq_matrix D_inv{ D.inverse() }; const mpq_matrix D_inv{ D.inverse() };
const mpz_matrix g{ this->get_gram_wrt_smith_basis() }; const mpz_matrix g{ this->get_gram_wrt_smith_basis() };
const mpq_matrix trans{ lll_gram(g).cast<mpq_class>()}; const mpq_matrix trans{ lll_gram(g).cast<mpq_class>()};
const mpq_matrix trans_inv{ trans.inverse() };
std::vector<mpq_vector> representatives; std::vector<mpq_vector> representatives;
// find representatives of the shifted lattices with small norms // find representatives of the shifted lattices with small norms
for (const auto& o : orbits) { for (const auto& o : orbits) {
const mpq_matrix lifted_repr{ o.representative.cast<mpq_class>() }; const mpq_matrix lifted_repr{ o.representative.cast<mpq_class>() };
mpq_vector v{ -(D_inv * lifted_repr) }; mpq_vector v{ -(D_inv * lifted_repr) };
representatives.push_back(lifted_repr + D * internal::babai_near_vector(trans, v)); representatives.push_back(lifted_repr + D * internal::babai_near_vector(trans, trans_inv, v));
} }
mpq_class max_offset_norm; mpq_class max_offset_norm;
...@@ -422,7 +423,7 @@ start_printing: ...@@ -422,7 +423,7 @@ start_printing:
} }
} }
const mpq_matrix S{ this->get_gram_wrt_smith_basis().cast<mpq_class>() }; const mpq_matrix S{ g.cast<mpq_class>() };
for (uint64_t i = 0; i < representatives.size(); i++) { for (uint64_t i = 0; i < representatives.size(); i++) {
out[orbits[i].representative].offset = this->q(orbits[i].representative); out[orbits[i].representative].offset = this->q(orbits[i].representative);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment