diff --git a/src/weil.cpp b/src/weil.cpp index ea5a5daf9d9f0f2d69864211ccd1327cd422923c..caa9857f476e88b2063b2837982c221859e728a7 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;