9 #include "cl_integer_ring.h"
14 #include "cl_integer.h"
15 #include "cl_integer_io.h"
18 static void I_fprint (cl_heap_ring* R, cl_ostream stream, const _cl_ring_element& x)
21 fprint(stream,The(cl_I)(x));
24 static cl_boolean I_equal (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
27 return cl_equal(The(cl_I)(x),The(cl_I)(y));
30 static const _cl_ring_element I_zero (cl_heap_ring* R)
32 return _cl_ring_element(R, (cl_I)0);
35 static cl_boolean I_zerop (cl_heap_ring* R, const _cl_ring_element& x)
38 return zerop(The(cl_I)(x));
41 static const _cl_ring_element I_plus (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
43 return _cl_ring_element(R, The(cl_I)(x) + The(cl_I)(y));
46 static const _cl_ring_element I_minus (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
48 return _cl_ring_element(R, The(cl_I)(x) - The(cl_I)(y));
51 static const _cl_ring_element I_uminus (cl_heap_ring* R, const _cl_ring_element& x)
53 return _cl_ring_element(R, - The(cl_I)(x));
56 static const _cl_ring_element I_one (cl_heap_ring* R)
58 return _cl_ring_element(R, (cl_I)1);
61 static const _cl_ring_element I_canonhom (cl_heap_ring* R, const cl_I& x)
63 return _cl_ring_element(R, (cl_I)x);
66 static const _cl_ring_element I_mul (cl_heap_ring* R, const _cl_ring_element& x, const _cl_ring_element& y)
68 return _cl_ring_element(R, The(cl_I)(x) * The(cl_I)(y));
71 static const _cl_ring_element I_square (cl_heap_ring* R, const _cl_ring_element& x)
73 return _cl_ring_element(R, square(The(cl_I)(x)));
76 static const _cl_ring_element I_expt_pos (cl_heap_ring* R, const _cl_ring_element& x, const cl_I& y)
78 return _cl_ring_element(R, expt_pos(The(cl_I)(x),y));
81 static cl_boolean cl_I_p (const cl_number& x)
85 ? x.nonpointer_tag() == cl_FN_tag
86 : 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
151 inline cl_integer_ring::cl_specialized_number_ring ()
152 : cl_number_ring (new cl_heap_integer_ring()) {}
154 const cl_integer_ring cl_I_ring;
156 CL_PROVIDE_END(cl_I_ring)