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 cl_boolean 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 cl_boolean 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 cl_boolean cl_I_p (const cl_number& x)
87 ? x.nonpointer_tag() == cl_FN_tag
88 : x.pointer_type() == &cl_class_bignum
92 static cl_ring_setops I_setops = {
96 static cl_ring_addops I_addops = {
103 static cl_ring_mulops I_mulops = {
111 static cl_number_ring_ops<cl_I> I_ops = {
123 class cl_heap_integer_ring : public cl_heap_number_ring {
124 SUBCLASS_cl_heap_ring()
127 cl_heap_integer_ring ()
128 : cl_heap_number_ring (&I_setops,&I_addops,&I_mulops,
129 (cl_number_ring_ops<cl_number>*) &I_ops)
130 { type = &cl_class_integer_ring; }
132 ~cl_heap_integer_ring () {}
135 static void cl_integer_ring_destructor (cl_heap* pointer)
137 (*(cl_heap_integer_ring*)pointer).~cl_heap_integer_ring();
140 static void cl_integer_ring_dprint (cl_heap* pointer)
143 fprint(cl_debugout, "(cl_integer_ring) cl_I_ring");
146 cl_class cl_class_integer_ring = {
147 cl_integer_ring_destructor,
148 cl_class_flags_number_ring,
149 cl_integer_ring_dprint
154 inline cl_integer_ring::cl_specialized_number_ring ()
155 : cl_number_ring (new cl_heap_integer_ring()) {}
157 const cl_integer_ring cl_I_ring;
161 CL_PROVIDE_END(cl_I_ring)