#include "cln/SV_number.h"
#include "cln/number.h"
#include "cln/integer.h"
-#include "cln/abort.h"
+#include "cln/exception.h"
namespace cln {
}
}}
-static cl_boolean num_equal (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
+static bool num_equal (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
{{
DeclarePoly(cl_SV_number,x);
DeclarePoly(cl_SV_number,y);
var sintL xlen = x.length();
var sintL ylen = y.length();
if (!(xlen == ylen))
- return cl_false;
+ return false;
for (var sintL i = xlen-1; i >= 0; i--)
if (!ops.equal(x[i],y[i]))
- return cl_false;
- return cl_true;
+ return false;
+ return true;
}}
static const _cl_UP num_zero (cl_heap_univpoly_ring* UPR)
return _cl_UP(UPR, cl_null_SV_number);
}
-static cl_boolean num_zerop (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
+static bool num_zerop (cl_heap_univpoly_ring* UPR, const _cl_UP& x)
{
unused UPR;
{ DeclarePoly(cl_SV_number,x);
var sintL xlen = x.length();
if (xlen == 0)
- return cl_true;
+ return true;
else
- return cl_false;
+ return false;
}}
static const _cl_UP num_plus (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP& y)
// Negate. No normalization necessary, since the degree doesn't change.
var sintL i = xlen-1;
var cl_number hicoeff = ops.uminus(x[i]);
- if (ops.zerop(hicoeff)) cl_abort();
+ if (ops.zerop(hicoeff)) throw runtime_exception();
var cl_SV_number result = cl_SV_number(cl_make_heap_SV_number_uninit(xlen));
init1(cl_number, result[i]) (hicoeff);
for (i-- ; i >= 0; i--)
}
// Normalize (not necessary in integral domains).
//num_normalize(ops,result,len);
- if (ops.zerop(result[len-1])) cl_abort();
+ if (ops.zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
init1(cl_number, result[0]) (ops.square(x[0]));
// Normalize (not necessary in integral domains).
//num_normalize(ops,result,len);
- if (ops.zerop(result[len-1])) cl_abort();
+ if (ops.zerop(result[len-1])) throw runtime_exception();
return _cl_UP(UPR, result);
}}
static const _cl_UP num_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_number,x);
DeclarePoly(cl_SV_number,y);
static const _cl_UP num_monomial (cl_heap_univpoly_ring* UPR, const cl_ring_element& x, uintL e)
{
- if (!(UPR->basering() == x.ring())) cl_abort();
+ if (!(UPR->basering() == x.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,x);
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops;
if (ops.zerop(x))
static void num_set_coeff (cl_heap_univpoly_ring* UPR, _cl_UP& x, uintL index, const cl_ring_element& y)
{{
DeclareMutablePoly(cl_SV_number,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,y);
- if (!(index < x.length())) cl_abort();
+ if (!(index < x.length())) throw runtime_exception();
x[index] = y;
}}}
// If y = 0, return x[0].
// Else compute (...(x[len-1]*y+x[len-2])*y ...)*y + x[0].
DeclarePoly(cl_SV_number,x);
- if (!(UPR->basering() == y.ring())) cl_abort();
+ if (!(UPR->basering() == y.ring())) throw runtime_exception();
{ DeclarePoly(cl_number,y);
var cl_heap_number_ring* R = TheNumberRing(UPR->basering());
var cl_number_ring_ops<cl_number>& ops = *R->ops;