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