From 47df24dd89d5d2a7bdd01a4282886a29c0adbaf8 Mon Sep 17 00:00:00 2001
From: Maik Herbers <maik.herbers@stud.tu-darmstadt.de>
Date: Fri, 10 Feb 2023 14:58:50 +0100
Subject: [PATCH] weil: Add command `DS-info'.

* src/weil.cpp (ds_info): New function.
---
 src/weil.cpp | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/weil.cpp b/src/weil.cpp
index 66393f1..ea5a5da 100644
--- a/src/weil.cpp
+++ b/src/weil.cpp
@@ -26,6 +26,8 @@ print_help(bool error)
 			"\tweil [options] <command> [arguments]\n"
 			"\n"
 			"Commands:\n"
+			"  DS-info <file>                            output some information about the discriminant form associated\n"
+			"                                            to the gram matrix in `file'\n"
 			"  DS-c-kernel <file> <c>                    compute `D_c' where `D' is the discriminant form associated\n"
 			"                                            to the gram matrix in `file'\n"
 			"  DS-c-image <file> <c>                     compute `D^c' where `D' is the discriminant form associated\n"
@@ -470,6 +472,29 @@ transformation_matrix(int argc, const char** argv, weil::IOFormat style)
 	return EXIT_SUCCESS;
 }
 
+int
+ds_info(int argc, const char** argv, weil::IOFormat style)
+{
+	// FIXME: merge with DS-get-orbits?
+	(void)style;
+
+	if (argc != 1) {
+		return print_help(true);
+	}
+
+	auto m{ read_square_mpz_matrix(argv[0]) };
+	if (!m) {
+		return EXIT_FAILURE;
+	}
+
+	weil::DiscriminantForm D{ *m };
+
+	std::cout << "cardinality: " << D.cardinality << "\n";
+	std::cout << "level: " << D.level() << "\n";
+
+	return EXIT_SUCCESS;
+}
+
 int
 main(int argc, const char** argv)
 {
@@ -523,6 +548,8 @@ main(int argc, const char** argv)
 		}
 	};
 
+	check_option("DS-info", ds_info);
+
 #define ds_c_action(action_type)                                                                                       \
 	[]<typename... Ts>(Ts... args) {                                                                               \
 		return ds_c_action_common(                                                                             \
-- 
GitLab