]> www.ginac.de Git - cln.git/blobdiff - src/modinteger/cl_MI_pow2.h
Finalize CLN 1.3.7 release.
[cln.git] / src / modinteger / cl_MI_pow2.h
index 195726b171a443057f384b96a8feb64119278c52..c891a1af0339c51797ec695831774263dd189f26 100644 (file)
@@ -1,21 +1,19 @@
 // m > 0, m = 2^m1
 
+namespace cln {
+
 class cl_heap_modint_ring_pow2 : public cl_heap_modint_ring {
        SUBCLASS_cl_heap_modint_ring()
 public:
        // Constructor.
-       cl_heap_modint_ring_pow2 (const cl_I& m, uintL m1); // m = 2^m1
-       // Virtual destructor.
+       cl_heap_modint_ring_pow2 (const cl_I& m, uintC m1); // m = 2^m1
+       // Destructor.
        ~cl_heap_modint_ring_pow2 () {}
        // Additional information.
-       uintL m1;
+       uintC m1;
 };
 
-static
-#if !(defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ <= 90)) // workaround g++-2.7.2 and egcs-1.0.2-prerelease bug
-inline
-#endif
-const cl_I pow2_reduce_modulo (cl_heap_modint_ring* _R, const cl_I& x)
+static inline const cl_I pow2_reduce_modulo (cl_heap_modint_ring* _R, const cl_I& x)
 {
        var cl_heap_modint_ring_pow2* R = (cl_heap_modint_ring_pow2*)_R;
        return ldb(x,cl_byte(R->m1,0));
@@ -87,7 +85,7 @@ static const cl_MI_x pow2_recip (cl_heap_modint_ring* _R, const _cl_MI& x)
                if (R->m1 == 0)
                        return cl_MI(R, 0);
                if (zerop(xr))
-                       cl_error_division_by_0();
+                       throw division_by_0_exception();
                else
                        return cl_notify_composite(R,xr);
        } else
@@ -112,7 +110,7 @@ static const cl_MI_x pow2_div (cl_heap_modint_ring* _R, const _cl_MI& x, const _
                if (R->m1 == 0)
                        return cl_MI(R, 0);
                if (zerop(yr))
-                       cl_error_division_by_0();
+                       throw division_by_0_exception();
                else
                        return cl_notify_composite(R,yr);
        } else
@@ -139,6 +137,21 @@ static cl_modint_mulops pow2_mulops = {
        std_retract
 };
 
+static void cl_modint_ring_pow2_destructor (cl_heap* pointer)
+{
+       (*(cl_heap_modint_ring_pow2*)pointer).~cl_heap_modint_ring_pow2();
+}
+
+cl_class cl_class_modint_ring_pow2 = {
+       cl_modint_ring_pow2_destructor,
+       cl_class_flags_modint_ring
+};
+
 // Constructor.
-inline cl_heap_modint_ring_pow2::cl_heap_modint_ring_pow2 (const cl_I& m, uintL _m1)
-       : cl_heap_modint_ring (m, &std_setops, &pow2_addops, &pow2_mulops), m1 (_m1) {}
+inline cl_heap_modint_ring_pow2::cl_heap_modint_ring_pow2 (const cl_I& m, uintC _m1)
+       : cl_heap_modint_ring (m, &std_setops, &pow2_addops, &pow2_mulops), m1 (_m1)
+{
+       type = &cl_class_modint_ring_pow2;
+}
+
+}  // namespace cln