9 #include "cln/integer_ring.h"
14 #include "cln/integer.h"
15 #include "cln/integer_io.h"
20 static void I_fprint (cl_heap_ring* R, std::ostream& stream, const _cl_ring_element& x)
23 fprint(stream,The(cl_I)(x));
26 static bool I_equal (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
29 return equal(The(cl_I)(x),The(cl_I)(y));
32 static const _cl_ring_element I_zero (cl_heap_ring* R)
34 return _cl_ring_element(R, (cl_I)0);
37 static bool I_zerop (cl_heap_ring* R, const _cl_ring_element& x)
40 return zerop(The(cl_I)(x));
43 static const _cl_ring_element I_plus (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
45 return _cl_ring_element(R, The(cl_I)(x) + The(cl_I)(y));
48 static const _cl_ring_element I_minus (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
50 return _cl_ring_element(R, The(cl_I)(x) - The(cl_I)(y));
53 static const _cl_ring_element I_uminus (cl_heap_ring* R, const _cl_ring_element& x)
55 return _cl_ring_element(R, - The(cl_I)(x));
58 static const _cl_ring_element I_one (cl_heap_ring* R)
60 return _cl_ring_element(R, (cl_I)1);
63 static const _cl_ring_element I_canonhom (cl_heap_ring* R, const cl_I& x)
65 return _cl_ring_element(R, (cl_I)x);
68 static const _cl_ring_element I_mul (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
70 return _cl_ring_element(R, The(cl_I)(x) * The(cl_I)(y));
73 static const _cl_ring_element I_square (cl_heap_ring* R, const _cl_ring_element& x)
75 return _cl_ring_element(R, square(The(cl_I)(x)));
78 static const _cl_ring_element I_expt_pos (cl_heap_ring* R, const _cl_ring_element& x, const cl_I& y)
80 return _cl_ring_element(R, expt_pos(The(cl_I)(x),y));
83 static bool cl_I_p (const cl_number& x)
85 return (!x.pointer_p()
86 ? x.nonpointer_tag() == cl_FN_tag
87 : x.pointer_type() == &cl_class_bignum);
90 static cl_ring_setops I_setops = {
94 static cl_ring_addops I_addops = {
101 static cl_ring_mulops I_mulops = {
109 static cl_number_ring_ops<cl_I> I_ops = {
121 class cl_heap_integer_ring : public cl_heap_number_ring {
122 SUBCLASS_cl_heap_ring()
125 cl_heap_integer_ring ()
126 : cl_heap_number_ring (&I_setops,&I_addops,&I_mulops,
127 (cl_number_ring_ops<cl_number>*) &I_ops)
128 { type = &cl_class_integer_ring; }
130 ~cl_heap_integer_ring () {}
133 static void cl_integer_ring_destructor (cl_heap* pointer)
135 (*(cl_heap_integer_ring*)pointer).~cl_heap_integer_ring();
138 static void cl_integer_ring_dprint (cl_heap* pointer)
141 fprint(cl_debugout, "(cl_integer_ring) cl_I_ring");
144 cl_class cl_class_integer_ring = {
145 cl_integer_ring_destructor,
146 cl_class_flags_number_ring,
147 cl_integer_ring_dprint
152 inline cl_integer_ring::cl_specialized_number_ring ()
153 : cl_number_ring (new cl_heap_integer_ring()) {}
155 const cl_integer_ring cl_I_ring;
159 CL_PROVIDE_END(cl_I_ring)