File indexing completed on 2026-05-19 08:08:33
0001
0002
0003 #ifndef _CL_UNIVPOLY_REAL_H
0004 #define _CL_UNIVPOLY_REAL_H
0005
0006 #include "cln/ring.h"
0007 #include "cln/univpoly.h"
0008 #include "cln/number.h"
0009 #include "cln/real_class.h"
0010 #include "cln/integer_class.h"
0011 #include "cln/real_ring.h"
0012
0013 namespace cln {
0014
0015
0016
0017
0018 #ifdef notyet
0019
0020 typedef cl_UP_specialized<cl_R> cl_UP_R;
0021 typedef cl_univpoly_specialized_ring<cl_R> cl_univpoly_real_ring;
0022
0023
0024 #else
0025
0026 class cl_heap_univpoly_real_ring;
0027
0028 class cl_univpoly_real_ring : public cl_univpoly_ring {
0029 public:
0030
0031 cl_univpoly_real_ring () : cl_univpoly_ring () {}
0032
0033 cl_univpoly_real_ring (const cl_univpoly_real_ring&);
0034
0035 cl_univpoly_real_ring& operator= (const cl_univpoly_real_ring&);
0036
0037 cl_heap_univpoly_real_ring* operator-> () const
0038 { return (cl_heap_univpoly_real_ring*)heappointer; }
0039 };
0040
0041 CL_DEFINE_COPY_CONSTRUCTOR2(cl_univpoly_real_ring,cl_univpoly_ring)
0042 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_univpoly_real_ring,cl_univpoly_real_ring)
0043
0044 class cl_UP_R : public cl_UP {
0045 public:
0046 const cl_univpoly_real_ring& ring () const { return The(cl_univpoly_real_ring)(_ring); }
0047
0048 CL_DEFINE_CONVERTER(cl_ring_element)
0049
0050 void set_coeff (uintL index, const cl_R& y);
0051 void finalize();
0052
0053 const cl_R operator() (const cl_R& y) const;
0054 public:
0055 void* operator new (size_t size) { return malloc_hook(size); }
0056 void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
0057 void operator delete (void* ptr) { free_hook(ptr); }
0058 };
0059
0060 class cl_heap_univpoly_real_ring : public cl_heap_univpoly_ring {
0061 SUBCLASS_cl_heap_univpoly_ring()
0062
0063 void fprint (std::ostream& stream, const cl_UP_R& x)
0064 {
0065 cl_heap_univpoly_ring::fprint(stream,x);
0066 }
0067 bool equal (const cl_UP_R& x, const cl_UP_R& y)
0068 {
0069 return cl_heap_univpoly_ring::equal(x,y);
0070 }
0071 const cl_UP_R zero ()
0072 {
0073 return The2(cl_UP_R)(cl_heap_univpoly_ring::zero());
0074 }
0075 bool zerop (const cl_UP_R& x)
0076 {
0077 return cl_heap_univpoly_ring::zerop(x);
0078 }
0079 const cl_UP_R plus (const cl_UP_R& x, const cl_UP_R& y)
0080 {
0081 return The2(cl_UP_R)(cl_heap_univpoly_ring::plus(x,y));
0082 }
0083 const cl_UP_R minus (const cl_UP_R& x, const cl_UP_R& y)
0084 {
0085 return The2(cl_UP_R)(cl_heap_univpoly_ring::minus(x,y));
0086 }
0087 const cl_UP_R uminus (const cl_UP_R& x)
0088 {
0089 return The2(cl_UP_R)(cl_heap_univpoly_ring::uminus(x));
0090 }
0091 const cl_UP_R one ()
0092 {
0093 return The2(cl_UP_R)(cl_heap_univpoly_ring::one());
0094 }
0095 const cl_UP_R canonhom (const cl_I& x)
0096 {
0097 return The2(cl_UP_R)(cl_heap_univpoly_ring::canonhom(x));
0098 }
0099 const cl_UP_R mul (const cl_UP_R& x, const cl_UP_R& y)
0100 {
0101 return The2(cl_UP_R)(cl_heap_univpoly_ring::mul(x,y));
0102 }
0103 const cl_UP_R square (const cl_UP_R& x)
0104 {
0105 return The2(cl_UP_R)(cl_heap_univpoly_ring::square(x));
0106 }
0107 const cl_UP_R expt_pos (const cl_UP_R& x, const cl_I& y)
0108 {
0109 return The2(cl_UP_R)(cl_heap_univpoly_ring::expt_pos(x,y));
0110 }
0111 const cl_UP_R scalmul (const cl_R& x, const cl_UP_R& y)
0112 {
0113 return The2(cl_UP_R)(cl_heap_univpoly_ring::scalmul(cl_ring_element(cl_R_ring,x),y));
0114 }
0115 sintL degree (const cl_UP_R& x)
0116 {
0117 return cl_heap_univpoly_ring::degree(x);
0118 }
0119 sintL ldegree (const cl_UP_R& x)
0120 {
0121 return cl_heap_univpoly_ring::ldegree(x);
0122 }
0123 const cl_UP_R monomial (const cl_R& x, uintL e)
0124 {
0125 return The2(cl_UP_R)(cl_heap_univpoly_ring::monomial(cl_ring_element(cl_R_ring,x),e));
0126 }
0127 const cl_R coeff (const cl_UP_R& x, uintL index)
0128 {
0129 return The(cl_R)(cl_heap_univpoly_ring::coeff(x,index));
0130 }
0131 const cl_UP_R create (sintL deg)
0132 {
0133 return The2(cl_UP_R)(cl_heap_univpoly_ring::create(deg));
0134 }
0135 void set_coeff (cl_UP_R& x, uintL index, const cl_R& y)
0136 {
0137 cl_heap_univpoly_ring::set_coeff(x,index,cl_ring_element(cl_R_ring,y));
0138 }
0139 void finalize (cl_UP_R& x)
0140 {
0141 cl_heap_univpoly_ring::finalize(x);
0142 }
0143 const cl_R eval (const cl_UP_R& x, const cl_R& y)
0144 {
0145 return The(cl_R)(cl_heap_univpoly_ring::eval(x,cl_ring_element(cl_R_ring,y)));
0146 }
0147 private:
0148
0149 cl_heap_univpoly_real_ring ();
0150 };
0151
0152
0153 inline const cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring& r)
0154 { return The(cl_univpoly_real_ring) (find_univpoly_ring((const cl_ring&)r)); }
0155 inline const cl_univpoly_real_ring find_univpoly_ring (const cl_real_ring& r, const cl_symbol& varname)
0156 { return The(cl_univpoly_real_ring) (find_univpoly_ring((const cl_ring&)r,varname)); }
0157
0158
0159
0160
0161 inline const cl_UP_R operator+ (const cl_UP_R& x, const cl_UP_R& y)
0162 { return x.ring()->plus(x,y); }
0163
0164
0165 inline const cl_UP_R operator- (const cl_UP_R& x)
0166 { return x.ring()->uminus(x); }
0167
0168
0169 inline const cl_UP_R operator- (const cl_UP_R& x, const cl_UP_R& y)
0170 { return x.ring()->minus(x,y); }
0171
0172
0173 inline const cl_UP_R operator* (const cl_UP_R& x, const cl_UP_R& y)
0174 { return x.ring()->mul(x,y); }
0175
0176
0177 inline const cl_UP_R square (const cl_UP_R& x)
0178 { return x.ring()->square(x); }
0179
0180
0181 inline const cl_UP_R expt_pos (const cl_UP_R& x, const cl_I& y)
0182 { return x.ring()->expt_pos(x,y); }
0183
0184
0185 #if 0
0186 inline const cl_UP_R operator* (const cl_I& x, const cl_UP_R& y)
0187 { return y.ring()->mul(y.ring()->canonhom(x),y); }
0188 inline const cl_UP_R operator* (const cl_UP_R& x, const cl_I& y)
0189 { return x.ring()->mul(x.ring()->canonhom(y),x); }
0190 #endif
0191 inline const cl_UP_R operator* (const cl_I& x, const cl_UP_R& y)
0192 { return y.ring()->scalmul(x,y); }
0193 inline const cl_UP_R operator* (const cl_UP_R& x, const cl_I& y)
0194 { return x.ring()->scalmul(y,x); }
0195 inline const cl_UP_R operator* (const cl_R& x, const cl_UP_R& y)
0196 { return y.ring()->scalmul(x,y); }
0197 inline const cl_UP_R operator* (const cl_UP_R& x, const cl_R& y)
0198 { return x.ring()->scalmul(y,x); }
0199
0200
0201 inline const cl_R coeff (const cl_UP_R& x, uintL index)
0202 { return x.ring()->coeff(x,index); }
0203
0204
0205 inline void set_coeff (cl_UP_R& x, uintL index, const cl_R& y)
0206 { x.ring()->set_coeff(x,index,y); }
0207 inline void finalize (cl_UP_R& x)
0208 { x.ring()->finalize(x); }
0209 inline void cl_UP_R::set_coeff (uintL index, const cl_R& y)
0210 { ring()->set_coeff(*this,index,y); }
0211 inline void cl_UP_R::finalize ()
0212 { ring()->finalize(*this); }
0213
0214
0215 inline const cl_R cl_UP_R::operator() (const cl_R& y) const
0216 {
0217 return ring()->eval(*this,y);
0218 }
0219
0220
0221 inline const cl_UP_R deriv (const cl_UP_R& x)
0222 { return The2(cl_UP_R)(deriv((const cl_UP&)x)); }
0223
0224 #endif
0225
0226 }
0227
0228 #endif