]> www.ginac.de Git - cln.git/blobdiff - include/cln/univpoly.h
Remove some unused configuration macros.
[cln.git] / include / cln / univpoly.h
index 23bd0336c3e48bda57302ca2c517ba3f0f3eb5a7..8915254f2d0d69850d785cd8518733dcb5cb9534 100644 (file)
@@ -115,12 +115,12 @@ struct _cl_univpoly_setops /* cf. _cl_ring_setops */ {
        // 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
@@ -147,6 +147,8 @@ struct _cl_univpoly_modulops {
 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)
@@ -186,11 +188,11 @@ public:
        // 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); }
@@ -212,6 +214,8 @@ public:
                { 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)
@@ -227,39 +231,39 @@ public:
        // 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 ()
@@ -272,37 +276,42 @@ public:
        }
        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)
@@ -311,17 +320,17 @@ public:
        }
        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.
@@ -331,10 +340,7 @@ public:
                { 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()
@@ -342,16 +348,18 @@ private:
 
 // 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.
@@ -380,7 +388,7 @@ inline bool operator!= (const cl_UP& x, const cl_UP& y)
        { 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.
@@ -415,6 +423,10 @@ inline const cl_UP operator* (const cl_UP& x, const cl_ring_element& y)
 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); }
@@ -444,7 +456,15 @@ extern const cl_UP deriv (const cl_UP& x);
 
 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)) {}
@@ -533,7 +553,7 @@ class cl_heap_univpoly_specialized_ring : public cl_heap_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);
        }
@@ -541,7 +561,7 @@ class cl_heap_univpoly_specialized_ring : public cl_heap_univpoly_ring {
        {
                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);
        }
@@ -585,6 +605,10 @@ class cl_heap_univpoly_specialized_ring : public cl_heap_univpoly_ring {
        {
                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));