// equality
// (Be careful: This is not well-defined for polynomials with
// floating-point coefficients.)
- cl_boolean (* equal) (cl_heap_univpoly_ring* R, const _cl_UP& x, const _cl_UP& y);
+ bool (* equal) (cl_heap_univpoly_ring* R, const _cl_UP& x, const _cl_UP& y);
};
struct _cl_univpoly_addops /* cf. _cl_ring_addops */ {
// 0
const _cl_UP (* zero) (cl_heap_univpoly_ring* R);
- cl_boolean (* zerop) (cl_heap_univpoly_ring* R, const _cl_UP& x);
+ bool (* zerop) (cl_heap_univpoly_ring* R, const _cl_UP& x);
// x+y
const _cl_UP (* plus) (cl_heap_univpoly_ring* R, const _cl_UP& x, const _cl_UP& y);
// x-y
// Low-level operations.
void _fprint (std::ostream& stream, const _cl_UP& x)
{ setops->fprint(this,stream,x); }
- cl_boolean _equal (const _cl_UP& x, const _cl_UP& y)
+ bool _equal (const _cl_UP& x, const _cl_UP& y)
{ return setops->equal(this,x,y); }
const _cl_UP _zero ()
{ return addops->zero(this); }
- cl_boolean _zerop (const _cl_UP& x)
+ bool _zerop (const _cl_UP& x)
{ return addops->zerop(this,x); }
const _cl_UP _plus (const _cl_UP& x, const _cl_UP& y)
{ return addops->plus(this,x,y); }
// High-level operations.
void fprint (std::ostream& stream, const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_fprint(stream,x);
}
- cl_boolean equal (const cl_UP& x, const cl_UP& y)
+ bool equal (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return _equal(x,y);
}
const cl_UP zero ()
{
return cl_UP(this,_zero());
}
- cl_boolean zerop (const cl_UP& x)
+ bool zerop (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _zerop(x);
}
const cl_UP plus (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_plus(x,y));
}
const cl_UP minus (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_minus(x,y));
}
const cl_UP uminus (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_uminus(x));
}
const cl_UP one ()
}
const cl_UP mul (const cl_UP& x, const cl_UP& y)
{
- if (!(x.ring() == this)) cl_abort();
- if (!(y.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_mul(x,y));
}
const cl_UP square (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_square(x));
}
const cl_UP expt_pos (const cl_UP& x, const cl_I& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return cl_UP(this,_expt_pos(x,y));
}
const cl_UP scalmul (const cl_ring_element& x, const cl_UP& y)
{
- if (!(y.ring() == this)) cl_abort();
+ if (!(y.ring() == this)) throw runtime_exception();
return cl_UP(this,_scalmul(x,y));
}
sintL degree (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _degree(x);
}
sintL ldegree (const cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _ldegree(x);
}
const cl_UP monomial (const cl_ring_element& x, uintL e)
}
const cl_ring_element coeff (const cl_UP& x, uintL index)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _coeff(x,index);
}
const cl_UP create (sintL deg)
}
void set_coeff (cl_UP& x, uintL index, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_set_coeff(x,index,y);
}
void finalize (cl_UP& x)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
_finalize(x);
}
const cl_ring_element eval (const cl_UP& x, const cl_ring_element& y)
{
- if (!(x.ring() == this)) cl_abort();
+ if (!(x.ring() == this)) throw runtime_exception();
return _eval(x,y);
}
// Property operations.
// Lookup or create the "standard" univariate polynomial ring over a ring r.
extern const cl_univpoly_ring find_univpoly_ring (const cl_ring& r);
-//CL_REQUIRE(cl_UP_unnamed)
// Lookup or create a univariate polynomial ring with a named variable over r.
extern const cl_univpoly_ring find_univpoly_ring (const cl_ring& r, const cl_symbol& varname);
-//CL_REQUIRE(cl_UP_named)
-CL_REQUIRE(cl_UP)
+class cl_UP_init_helper
+{
+ static int count;
+public:
+ cl_UP_init_helper();
+ ~cl_UP_init_helper();
+};
+static cl_UP_init_helper cl_UP_init_helper_instance;
// Operations on polynomials.
{ return !x.ring()->equal(x,y); }
// Compare against 0.
-inline cl_boolean zerop (const cl_UP& x)
+inline bool zerop (const cl_UP& x)
{ return x.ring()->zerop(x); }
// Multiply.
extern const cl_univpoly_ring cl_no_univpoly_ring;
extern cl_class cl_class_no_univpoly_ring;
-CL_REQUIRE(cl_UP_no_ring)
+
+class cl_UP_no_ring_init_helper
+{
+ static int count;
+public:
+ cl_UP_no_ring_init_helper();
+ ~cl_UP_no_ring_init_helper();
+};
+static cl_UP_no_ring_init_helper cl_UP_no_ring_init_helper_instance;
inline cl_univpoly_ring::cl_univpoly_ring ()
: cl_ring (as_cl_private_thing(cl_no_univpoly_ring)) {}
{
cl_heap_univpoly_ring::fprint(stream,x);
}
- cl_boolean equal (const cl_UP_specialized<T>& x, const cl_UP_specialized<T>& y)
+ bool equal (const cl_UP_specialized<T>& x, const cl_UP_specialized<T>& y)
{
return cl_heap_univpoly_ring::equal(x,y);
}
{
return The2(cl_UP_specialized<T>)(cl_heap_univpoly_ring::zero());
}
- cl_boolean zerop (const cl_UP_specialized<T>& x)
+ bool zerop (const cl_UP_specialized<T>& x)
{
return cl_heap_univpoly_ring::zerop(x);
}