#include "cln/modinteger.h"
#include "cln/GV_integer.h"
#include "cl_DS.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
uintD data[1];
};
-static cl_boolean gf2_equal (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
+static bool gf2_equal (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
{{
DeclarePoly(cl_GV_MI,x);
DeclarePoly(cl_GV_MI,y);
var uintL xlen = xv->v.length();
var uintL ylen = yv->v.length();
if (!(xlen == ylen))
- return cl_false;
+ return false;
// We can compare full words since unused bits in the last word are 0.
var uintL count = ceiling(xlen,intDsize);
if (compare_loop_up(xv->data,yv->data,count) != 0)
- return cl_false;
- return cl_true;
+ return false;
+ return true;
}}
static const _cl_UP gf2_plus (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
return x;
}
-#if !(defined(__sparc__) || defined(__sparc64__))
+#if !defined(__sparc__) || defined(__sparc64__)
// Multiplication of polynomials over GF(2) can unfortunately not profit
// from hardware multiply instructions. Use a table instead.
// This is a 2^8 x 2^4 table. Maybe a 2^6 x 2^6 table would be better?
// Scalar multiplication of GF(2)-polynomials is trivial: 0*y = 0, 1*y = y.
static const _cl_UP gf2_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, const _cl_UP& y)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{
DeclarePoly(_cl_MI,x);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
static const cl_ring_element gf2_eval (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const cl_ring_element& y)
{{
DeclarePoly(cl_GV_MI,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(_cl_MI,y);
var cl_heap_modint_ring* R = TheModintRing(UPR->basering());
var const cl_heap_GV_I_bits1 * xv = (const cl_heap_GV_I_bits1 *) x.heappointer;
return cl_MI(R, x[0]);
else {
var uintL count = ceiling(len,intDsize);
- var uintL bitcount = 0;
+ var uintC bitcount = 0;
do {
count--;
bitcount += logcountD(xv->data[count]);
static cl_univpoly_polyops gf2_polyops = {
modint_degree,
+ modint_ldegree,
modint_monomial,
modint_coeff,
modint_create,
SUBCLASS_cl_heap_univpoly_ring()
public:
// Constructor.
- cl_heap_gf2_univpoly_ring (const cl_ring& r)
- : cl_heap_univpoly_ring (r, &gf2_setops, &gf2_addops, &gf2_mulops, &gf2_modulops, &gf2_polyops) {}
+ cl_heap_gf2_univpoly_ring (const cl_ring& r);
+ // Destructor.
+ ~cl_heap_gf2_univpoly_ring () {}
};
+static void cl_heap_gf2_univpoly_ring_destructor (cl_heap* pointer)
+{
+ (*(cl_heap_gf2_univpoly_ring*)pointer).~cl_heap_gf2_univpoly_ring();
+}
+
+cl_class cl_class_gf2_univpoly_ring = {
+ cl_heap_gf2_univpoly_ring_destructor,
+ cl_class_flags_univpoly_ring
+};
+
+// Constructor.
+inline cl_heap_gf2_univpoly_ring::cl_heap_gf2_univpoly_ring (const cl_ring& r)
+ : cl_heap_univpoly_ring (r, &gf2_setops, &gf2_addops, &gf2_mulops, &gf2_modulops, &gf2_polyops)
+{
+ type = &cl_class_gf2_univpoly_ring;
+}
+
} // namespace cln