From 291d6f08acc3b5f283cc669829fc879d0885d07b Mon Sep 17 00:00:00 2001 From: Maik Herbers <maik.herbers@stud.tu-darmstadt.de> Date: Sat, 4 Feb 2023 12:29:16 +0100 Subject: [PATCH] Fix formatting. * src/common.cpp, src/cyclotomic_field.cpp, src/discriminant_form.cpp, src/weil.cpp: Fix formatting with `clang-format'. --- src/common.cpp | 4 +++- src/cyclotomic_field.cpp | 15 +++++++++------ src/discriminant_form.cpp | 23 +++++++++++++++-------- src/weil.cpp | 14 +++++--------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index d433fb9..5bb0388 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -26,7 +26,9 @@ namespace weil::internal namespace weil { - void format_eigen(std::ostream &o, const mpz_vector& v, IOFormat style) { + void + format_eigen(std::ostream& o, const mpz_vector& v, IOFormat style) + { Eigen::IOFormat fmt; switch (style) { using enum IOFormat; diff --git a/src/cyclotomic_field.cpp b/src/cyclotomic_field.cpp index 6f43598..19e9a63 100644 --- a/src/cyclotomic_field.cpp +++ b/src/cyclotomic_field.cpp @@ -21,7 +21,7 @@ namespace weil { } - CyclotomicField:: CyclotomicField(uint64_t n, CyclotomicFieldInitType init) + CyclotomicField::CyclotomicField(uint64_t n, CyclotomicFieldInitType init) : coeffs{ std::vector<mpq_class>(n ? n : 1) } { if (init == CyclotomicFieldInitType::IAmEigen) { @@ -29,7 +29,8 @@ namespace weil } } - CyclotomicField operator-(const CyclotomicField& a) + CyclotomicField + operator-(const CyclotomicField& a) { CyclotomicField res{ a }; @@ -85,7 +86,8 @@ namespace weil } for (uint64_t j = 0; j < b.coeffs.size(); j++) { - res.coeffs[(stride_a * i + stride_b * j) % res.coeffs.size()] += a.coeffs[i] * b.coeffs[j]; + res.coeffs[(stride_a * i + stride_b * j) % res.coeffs.size()] += + a.coeffs[i] * b.coeffs[j]; } } @@ -183,7 +185,7 @@ namespace weil */ if (this->coeffs.size() % 3 == 0) { - uint64_t third{ this->coeffs.size() / 3}; + uint64_t third{ this->coeffs.size() / 3 }; if (this->coeffs[third] == this->coeffs[2 * third]) { this->coeffs[0] -= this->coeffs[third]; this->coeffs[third] = 0_mpq; @@ -191,7 +193,7 @@ namespace weil } } if (this->coeffs.size() % 6 == 0) { - uint64_t sixth{ this->coeffs.size() / 6}; + uint64_t sixth{ this->coeffs.size() / 6 }; if (this->coeffs[sixth] == -this->coeffs[2 * sixth]) { this->coeffs[0] += this->coeffs[sixth]; this->coeffs[sixth] = 0_mpq; @@ -286,7 +288,8 @@ namespace weil return o; } - bool operator==(const CyclotomicField& a, const CyclotomicField& b) + bool + operator==(const CyclotomicField& a, const CyclotomicField& b) { auto res{ a - b }; for (uint64_t i = 0; i < res.coeffs.size(); i++) { diff --git a/src/discriminant_form.cpp b/src/discriminant_form.cpp index 4027990..f913775 100644 --- a/src/discriminant_form.cpp +++ b/src/discriminant_form.cpp @@ -116,7 +116,8 @@ namespace weil } - void PowerSeries::increment(uint64_t idx) + void + PowerSeries::increment(uint64_t idx) { if (this->coeffs.size() <= idx) { for (uint64_t i = this->coeffs.size(); i < idx; i++) { @@ -129,7 +130,8 @@ namespace weil } } - void format_powerseries(std::ostream& o, const PowerSeries& p, IOFormat style) + void + format_powerseries(std::ostream& o, const PowerSeries& p, IOFormat style) { const char* start = ""; const char* stop = ""; @@ -356,7 +358,7 @@ start_printing: uint64_t uint_prec = mpz_get_ui(mpz_class{ prec }.get_mpz_t()); - auto atomic_theta{ init_theta_series(mpz_get_ui(this->cardinality.get_mpz_t()), uint_prec)}; + auto atomic_theta{ init_theta_series(mpz_get_ui(this->cardinality.get_mpz_t()), uint_prec) }; #pragma omp parallel for for (uint64_t i = 0; i < vectors.size(); i++) { @@ -379,7 +381,8 @@ start_printing: for (const auto& v : *this) { // Remember: The upper bound is inclusive for (uint64_t i = 0; i <= uint_prec; i++) { - uint64_t c = atomic_theta_read(atomic_theta, internal::vector_to_index(v, this->elem_divs), i); + uint64_t c = + atomic_theta_read(atomic_theta, internal::vector_to_index(v, this->elem_divs), i); out[v].coeffs.push_back(c); } } @@ -404,7 +407,7 @@ start_printing: const mpq_matrix D{ this->elem_divs.cast<mpq_class>().asDiagonal() }; const mpq_matrix D_inv{ D.inverse() }; 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; @@ -417,7 +420,10 @@ start_printing: mpq_class max_offset_norm; for (uint64_t i = 0; i < representatives.size(); i++) { - mpq_class norm{ (representatives[i].transpose() * this->gram_matrix * representatives[i]).value() / 2_mpq }; + mpq_class norm{ + (representatives[i].transpose() * this->gram_matrix * representatives[i]).value() / + 2_mpq + }; if (norm > max_offset_norm) { max_offset_norm = norm; } @@ -433,7 +439,8 @@ start_printing: // lattice with norm less than prec + 1. To do this, we compute // all vectors in the lattice with norm less than or equal to // 2 (prec + max_offset_norm + 1). - const auto vectors{ lattice_vectors_up_to_bound(S, 2_mpq * (mpq_class{ prec } + max_offset_norm + 1_mpq)) }; + const auto vectors{ lattice_vectors_up_to_bound( + S, 2_mpq * (mpq_class{ prec } + max_offset_norm + 1_mpq)) }; const mpq_class max_norm{ prec }; auto atomic_theta{ init_theta_series(representatives.size(), prec) }; @@ -643,7 +650,7 @@ start_printing: remaining.erase(mapped); } - Orbit orbit_info{v, orbit.size()}; + Orbit orbit_info{ v, orbit.size() }; orbits.push_back(orbit_info); for (auto w : orbit) { diff --git a/src/weil.cpp b/src/weil.cpp index 3556750..fca3044 100644 --- a/src/weil.cpp +++ b/src/weil.cpp @@ -254,7 +254,6 @@ lattice_smith_gram_matrix(int argc, const char** argv, weil::IOFormat style) { if (argc != 1) { return print_help(true); -; } auto m{ read_square_mpz_matrix(argv[0]) }; @@ -476,9 +475,9 @@ main(int argc, const char** argv) weil::IOFormat style{ weil::IOFormat::Pretty }; const struct option long_options[] = { - {"help", no_argument, nullptr, 'h'}, - {"print-style", required_argument, nullptr, 0}, - {nullptr, 0, nullptr, 0}, + { "help", no_argument, nullptr, 'h' }, + { "print-style", required_argument, nullptr, 0 }, + { nullptr, 0, nullptr, 0 }, }; int opt_idx{ 0 }; @@ -507,11 +506,9 @@ main(int argc, const char** argv) } } break; - case 'h': - return print_help(false); + case 'h': return print_help(false); case '?': - default: - return print_help(true); + default: return print_help(true); } } @@ -519,7 +516,6 @@ main(int argc, const char** argv) return print_help(true); } - auto check_option = [argc, argv, style](const char* opt_name, auto func) -> void { if (strcmp(opt_name, argv[optind]) == 0) { exit(func(argc - optind - 1, argv + optind + 1, style)); -- GitLab