]> www.ginac.de Git - cln.git/blobdiff - include/cln/univpoly.h
Remove some unused configuration macros.
[cln.git] / include / cln / univpoly.h
index 7547c06e8b1b38e16bd094d884bdbfb8fa97c139..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
@@ -188,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); }
@@ -231,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 ()
@@ -276,33 +276,33 @@ 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)) cl_abort();
+               if (!(x.ring() == this)) throw runtime_exception();
                return _ldegree(x);
        }
        const cl_UP monomial (const cl_ring_element& x, uintL e)
@@ -311,7 +311,7 @@ public:
        }
        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)
@@ -320,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.
@@ -340,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()
@@ -351,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.
@@ -389,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.
@@ -457,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)) {}
@@ -546,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);
        }
@@ -554,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);
        }