|
@ -33,7 +33,7 @@ static void num_fprint (cl_heap_univpoly_ring* UPR, std::ostream& stream, const |
|
|
{{ |
|
|
{{ |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
fprint(stream, "0"); |
|
|
fprint(stream, "0"); |
|
|
else { |
|
|
else { |
|
@ -61,8 +61,8 @@ static bool num_equal (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const _cl_UP |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
var sintL ylen = y.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
|
|
|
var sintL ylen = y.size(); |
|
|
if (!(xlen == ylen)) |
|
|
if (!(xlen == ylen)) |
|
|
return false; |
|
|
return false; |
|
|
for (var sintL i = xlen-1; i >= 0; i--) |
|
|
for (var sintL i = xlen-1; i >= 0; i--) |
|
@ -80,7 +80,7 @@ static bool num_zerop (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
{ |
|
|
{ |
|
|
unused UPR; |
|
|
unused UPR; |
|
|
{ DeclarePoly(cl_SV_number,x); |
|
|
{ DeclarePoly(cl_SV_number,x); |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
return true; |
|
|
return true; |
|
|
else |
|
|
else |
|
@ -92,8 +92,8 @@ static const _cl_UP num_plus (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
var sintL ylen = y.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
|
|
|
var sintL ylen = y.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
return _cl_UP(UPR, y); |
|
|
return _cl_UP(UPR, y); |
|
|
if (ylen == 0) |
|
|
if (ylen == 0) |
|
@ -135,7 +135,7 @@ static const _cl_UP num_uminus (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
{{ |
|
|
{{ |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
return _cl_UP(UPR, x); |
|
|
return _cl_UP(UPR, x); |
|
|
// Now xlen > 0. |
|
|
// Now xlen > 0. |
|
@ -155,8 +155,8 @@ static const _cl_UP num_minus (cl_heap_univpoly_ring* UPR, const _cl_UP& x, cons |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
var sintL ylen = y.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
|
|
|
var sintL ylen = y.size(); |
|
|
if (ylen == 0) |
|
|
if (ylen == 0) |
|
|
return _cl_UP(UPR, x); |
|
|
return _cl_UP(UPR, x); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
@ -213,8 +213,8 @@ static const _cl_UP num_mul (cl_heap_univpoly_ring* UPR, const _cl_UP& x, const |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
var sintL ylen = y.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
|
|
|
var sintL ylen = y.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
return _cl_UP(UPR, x); |
|
|
return _cl_UP(UPR, x); |
|
|
if (ylen == 0) |
|
|
if (ylen == 0) |
|
@ -259,7 +259,7 @@ static const _cl_UP num_square (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
{{ |
|
|
{{ |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
if (xlen == 0) |
|
|
if (xlen == 0) |
|
|
return cl_UP(UPR, x); |
|
|
return cl_UP(UPR, x); |
|
|
var sintL len = 2*xlen-1; |
|
|
var sintL len = 2*xlen-1; |
|
@ -315,7 +315,7 @@ static const _cl_UP num_scalmul (cl_heap_univpoly_ring* UPR, const cl_ring_eleme |
|
|
DeclarePoly(cl_number,x); |
|
|
DeclarePoly(cl_number,x); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
DeclarePoly(cl_SV_number,y); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL ylen = y.length(); |
|
|
|
|
|
|
|
|
var sintL ylen = y.size(); |
|
|
if (ylen == 0) |
|
|
if (ylen == 0) |
|
|
return _cl_UP(UPR, y); |
|
|
return _cl_UP(UPR, y); |
|
|
if (ops.zerop(x)) |
|
|
if (ops.zerop(x)) |
|
@ -332,14 +332,14 @@ static sintL num_degree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
{ |
|
|
{ |
|
|
unused UPR; |
|
|
unused UPR; |
|
|
{ DeclarePoly(cl_SV_number,x); |
|
|
{ DeclarePoly(cl_SV_number,x); |
|
|
return (sintL) x.length() - 1; |
|
|
|
|
|
|
|
|
return (sintL) x.size() - 1; |
|
|
}} |
|
|
}} |
|
|
|
|
|
|
|
|
static sintL num_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
static sintL num_ldegree (cl_heap_univpoly_ring* UPR, const _cl_UP& x) |
|
|
{{ |
|
|
{{ |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var sintL xlen = x.length(); |
|
|
|
|
|
|
|
|
var sintL xlen = x.size(); |
|
|
for (sintL i = 0; i < xlen; i++) { |
|
|
for (sintL i = 0; i < xlen; i++) { |
|
|
if (!ops.zerop(x[i])) |
|
|
if (!ops.zerop(x[i])) |
|
|
return i; |
|
|
return i; |
|
@ -366,7 +366,7 @@ static const cl_ring_element num_coeff (cl_heap_univpoly_ring* UPR, const _cl_UP |
|
|
{{ |
|
|
{{ |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
DeclarePoly(cl_SV_number,x); |
|
|
var cl_heap_number_ring* R = TheNumberRing(UPR->basering()); |
|
|
var cl_heap_number_ring* R = TheNumberRing(UPR->basering()); |
|
|
if (index < x.length()) |
|
|
|
|
|
|
|
|
if (index < x.size()) |
|
|
return cl_ring_element(R, x[index]); |
|
|
return cl_ring_element(R, x[index]); |
|
|
else |
|
|
else |
|
|
return R->zero(); |
|
|
return R->zero(); |
|
@ -387,7 +387,7 @@ static void num_set_coeff (cl_heap_univpoly_ring* UPR, _cl_UP& x, uintL index, c |
|
|
DeclareMutablePoly(cl_SV_number,x); |
|
|
DeclareMutablePoly(cl_SV_number,x); |
|
|
if (!(UPR->basering() == y.ring())) throw runtime_exception(); |
|
|
if (!(UPR->basering() == y.ring())) throw runtime_exception(); |
|
|
{ DeclarePoly(cl_number,y); |
|
|
{ DeclarePoly(cl_number,y); |
|
|
if (!(index < x.length())) throw runtime_exception(); |
|
|
|
|
|
|
|
|
if (!(index < x.size())) throw runtime_exception(); |
|
|
x[index] = y; |
|
|
x[index] = y; |
|
|
}}} |
|
|
}}} |
|
|
|
|
|
|
|
@ -395,7 +395,7 @@ static void num_finalize (cl_heap_univpoly_ring* UPR, _cl_UP& x) |
|
|
{{ |
|
|
{{ |
|
|
DeclareMutablePoly(cl_SV_number,x); // NB: x is modified by reference! |
|
|
DeclareMutablePoly(cl_SV_number,x); // NB: x is modified by reference! |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *TheNumberRing(UPR->basering())->ops; |
|
|
var uintL len = x.length(); |
|
|
|
|
|
|
|
|
var uintL len = x.size(); |
|
|
if (len > 0) |
|
|
if (len > 0) |
|
|
num_normalize(ops,x,len); |
|
|
num_normalize(ops,x,len); |
|
|
}} |
|
|
}} |
|
@ -411,7 +411,7 @@ static const cl_ring_element num_eval (cl_heap_univpoly_ring* UPR, const _cl_UP& |
|
|
{ DeclarePoly(cl_number,y); |
|
|
{ DeclarePoly(cl_number,y); |
|
|
var cl_heap_number_ring* R = TheNumberRing(UPR->basering()); |
|
|
var cl_heap_number_ring* R = TheNumberRing(UPR->basering()); |
|
|
var cl_number_ring_ops<cl_number>& ops = *R->ops; |
|
|
var cl_number_ring_ops<cl_number>& ops = *R->ops; |
|
|
var uintL len = x.length(); |
|
|
|
|
|
|
|
|
var uintL len = x.size(); |
|
|
if (len==0) |
|
|
if (len==0) |
|
|
return R->zero(); |
|
|
return R->zero(); |
|
|
if (ops.zerop(y)) |
|
|
if (ops.zerop(y)) |
|
|