// 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
struct _cl_univpoly_polyops {
// degree
sintL (* degree) (cl_heap_univpoly_ring* R, const _cl_UP& x);
+ // low degree
+ sintL (* ldegree) (cl_heap_univpoly_ring* R, const _cl_UP& x);
// monomial
const _cl_UP (* monomial) (cl_heap_univpoly_ring* R, const cl_ring_element& x, uintL e);
// coefficient (0 if index>degree)
// 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); }
{ return modulops->scalmul(this,x,y); }
sintL _degree (const _cl_UP& x)
{ return polyops->degree(this,x); }
+ sintL _ldegree (const _cl_UP& x)
+ { return polyops->ldegree(this,x); }
const _cl_UP _monomial (const cl_ring_element& x, uintL e)
{ return polyops->monomial(this,x,e); }
const cl_ring_element _coeff (const _cl_UP& x, uintL index)
// 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)) throw runtime_exception();
+ return _ldegree(x);
+ }
const cl_UP monomial (const cl_ring_element& x, uintL e)
{
return cl_UP(this,_monomial(x,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.
{ properties.add_property(new_property); }
// Constructor.
cl_heap_univpoly_ring (const cl_ring& r, cl_univpoly_setops*, cl_univpoly_addops*, cl_univpoly_mulops*, cl_univpoly_modulops*, cl_univpoly_polyops*);
-// This class is intented to be subclassable, hence needs a virtual destructor.
- virtual ~cl_heap_univpoly_ring () {}
-private:
- virtual void dummy ();
+ ~cl_heap_univpoly_ring () {}
};
#define SUBCLASS_cl_heap_univpoly_ring() \
SUBCLASS_cl_heap_ring()
// 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)
-// Runtime typing support.
-extern cl_class cl_class_univpoly_ring;
+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.
inline sintL degree (const cl_UP& x)
{ return x.ring()->degree(x); }
+// Low degree.
+inline sintL ldegree (const cl_UP& x)
+ { return x.ring()->ldegree(x); }
+
// Coefficient.
inline const cl_ring_element coeff (const cl_UP& x, uintL index)
{ return x.ring()->coeff(x,index); }
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)) {}
// Debugging support.
#ifdef CL_DEBUG
extern int cl_UP_debug_module;
-static void* const cl_UP_debug_dummy[] = { &cl_UP_debug_dummy,
- &cl_UP_debug_module
-};
+CL_FORCE_LINK(cl_UP_debug_dummy, cl_UP_debug_module)
#endif
} // namespace cln
{
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);
}
{
return cl_heap_univpoly_ring::degree(x);
}
+ sintL ldegree (const cl_UP_specialized<T>& x)
+ {
+ return cl_heap_univpoly_ring::ldegree(x);
+ }
const cl_UP_specialized<T> monomial (const T& x, uintL e)
{
return The2(cl_UP_specialized<T>)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_C_ring??,x),e));