From 984aa9af58e65a17ee77cc243db468f1142505d5 Mon Sep 17 00:00:00 2001 From: Maik Herbers <maik.herbers@stud.tu-darmstadt.de> Date: Tue, 14 Feb 2023 17:15:03 +0100 Subject: [PATCH] weil: Name orbits in `DS-get-orbits'. Note that the numbering (the letters) depend on the smith basis. * src/weil.cpp (base26): New function. (ds_info): Output orbit name for `Pretty' and 'LaTeX' output formats. --- src/weil.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/weil.cpp b/src/weil.cpp index ea5a5da..caa9857 100644 --- a/src/weil.cpp +++ b/src/weil.cpp @@ -3,6 +3,7 @@ #include <algorithm> #include <cstdlib> +#include <cstring> #include <exception> #include <fstream> #include <iostream> @@ -272,6 +273,26 @@ lattice_smith_gram_matrix(int argc, const char** argv, weil::IOFormat style) return EXIT_SUCCESS; } +std::string +base26(uint64_t n) +{ + const char* alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + const uint64_t len = strlen(alphabet) - 1; + + if (n == 0) { + return { alphabet[0] }; + } + + std::string s; + while (n > 0) { + s.push_back(alphabet[n % len]); + n /= len; + } + + std::ranges::reverse(s); + return s; +} + int ds_get_orbits(int argc, const char** argv, weil::IOFormat style) { @@ -307,7 +328,7 @@ ds_get_orbits(int argc, const char** argv, weil::IOFormat style) switch (style) { using enum weil::IOFormat; case Pretty: - start = "representative\tlength\tnorm\torder\n"; + start = "representative\tname\tlength\tnorm\torder\n"; stop = ""; prefix = ""; infix = "\t"; @@ -331,7 +352,7 @@ ds_get_orbits(int argc, const char** argv, weil::IOFormat style) sep = ",\\\n"; break; case LaTeX: - start = "\\begin{tabular}{c c c c}\n"; + start = "\\begin{tabular}{c c c c c}\n"; stop = "\n\\end{tabular}"; prefix = "$"; infix = "$ & $"; @@ -342,6 +363,8 @@ ds_get_orbits(int argc, const char** argv, weil::IOFormat style) std::cout << start; bool first{ true }; + uint64_t offset_idx{ 0 }; + mpz_class last_offset{ 0_mpz }; for (auto&& o : orbits) { if (first) { first = false; @@ -349,15 +372,27 @@ ds_get_orbits(int argc, const char** argv, weil::IOFormat style) std::cout << sep; } + mpz_class offset{ (D.level() * D.q(o.representative)) }; + if (last_offset != offset) { + last_offset = offset; + offset_idx = 0; + } + std::cout << prefix; format_eigen(std::cout, o.representative, style); std::cout << infix; + if (style == weil::IOFormat::Pretty || style == weil::IOFormat::LaTeX) { + std::cout << offset << base26(offset_idx); + std::cout << infix; + } std::cout << o.length; std::cout << infix; std::cout << D.q(o.representative); std::cout << infix; std::cout << D.element_order(o.representative); std::cout << suffix; + + offset_idx++; } std::cout << stop << std::endl; -- GitLab