summaryrefslogtreecommitdiffstats
path: root/mpz.h
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2021-09-23 12:44:54 -0400
committerMalfurious <m@lfurio.us>2021-09-23 12:44:54 -0400
commit16ac36edf6250e1b8f414adec0fccccf5770c247 (patch)
tree0808ac29cdceb1c486b124757105d9d466ebabb4 /mpz.h
parentf1a44b273147c92cbfd4264093354e04486efec8 (diff)
downloadSorensenCompression-16ac36edf6250e1b8f414adec0fccccf5770c247.tar.gz
SorensenCompression-16ac36edf6250e1b8f414adec0fccccf5770c247.zip
Refactor bigint functions and add remaining helpers
A second variant of the mpz-based iterator is added, and both functions are moved into a new 'mpz' module, removing 'iterations' and the common pszip.h header. These iterators have been updated to have all (de)allocation performed externally as to reduce overhead / boost performance. Related helper functions have also been added to this module. Signed-off-by: Malfurious <m@lfurio.us>
Diffstat (limited to 'mpz.h')
-rw-r--r--mpz.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/mpz.h b/mpz.h
new file mode 100644
index 0000000..ef41ec6
--- /dev/null
+++ b/mpz.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <gmp.h>
+#include <stddef.h>
+
+/* This struct contains the instance data used by the iterators. Allocation is
+ * performed at a single point to reduce run-time overhead.
+ *
+ * 'current' contains the iterator's current value. The rest of the members are
+ * temporary variables. See the appropriate memory management functions for
+ * this type. */
+struct pszip_mpz_state
+{
+ mpz_t current, a, b, c, d;
+};
+
+void pszip_mpz_state_init(struct pszip_mpz_state *mpzs, size_t popcnt, size_t size);
+void pszip_mpz_state_clear(struct pszip_mpz_state *mpzs);
+void pszip_mpz_init_data(mpz_t n, const void *data, size_t size);
+
+void pszip_mpz_iterate_bithack01(struct pszip_mpz_state *mpzs);
+void pszip_mpz_iterate_bithack02(struct pszip_mpz_state *mpzs);