]> www.ginac.de Git - cln.git/blob - include/cl_GV_integer.h
b6f6acf107da783a929672965a9466ab11698222
[cln.git] / include / cl_GV_integer.h
1 // General vectors of integers.
2
3 #ifndef _CL_GV_INTEGER_H
4 #define _CL_GV_INTEGER_H
5
6 #include "cl_number.h"
7 #include "cl_GV_rational.h"
8 #include "cl_integer_class.h"
9 #include "cl_io.h"
10
11 // A vector of integers is *not* just a normal vector of numbers (the vectorops
12 // support the maxbits() operation), but we treat can it like this nevertheless.
13
14 #ifdef HAVE_TEMPLATE_NULL
15 template <>
16 #endif
17 struct cl_heap_GV<cl_I> : cl_heap {
18         cl_GV_inner<cl_I> v;
19         // here room for the elements
20         sintL maxbits () const;
21 };
22 typedef cl_heap_GV<cl_I> cl_heap_GV_I;
23
24 struct cl_GV_I : public cl_GV<cl_I,cl_GV_RA> {
25 public:
26         // Constructors.
27         cl_GV_I ();
28         cl_GV_I (const cl_GV_I&);
29         // Create a vector of unconstrained integers.
30         explicit cl_GV_I (uintL len);
31         // Create a vector of m-bit integers (>=0, <2^m).
32         cl_GV_I (uintL len, sintL m);
33         // Assignment operators.
34         cl_GV_I& operator= (const cl_GV_I&);
35         // Number m of bits allowed per element (-1 if unconstrained).
36         sintL maxbits () const
37         {
38                 return ((const cl_heap_GV_I *) pointer)->maxbits();
39         }
40         // Private pointer manipulations.
41         cl_GV_I (cl_heap_GV_I* p) : cl_GV<cl_I,cl_GV_RA> (p) {}
42         cl_GV_I (cl_private_thing p) : cl_GV<cl_I,cl_GV_RA> (p) {}
43 };
44 inline cl_GV_I::cl_GV_I (const cl_GV_I& x) : cl_GV<cl_I,cl_GV_RA> (as_cl_private_thing(x)) {}
45 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_I,cl_GV_I)
46 extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len);
47 inline cl_GV_I::cl_GV_I (uintL len)
48         : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len)) {}
49 extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len, sintL m);
50 inline cl_GV_I::cl_GV_I (uintL len, sintL m)
51         : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len,m)) {}
52
53 // Private pointer manipulations. Never throw away a `struct cl_heap_GV_I *'!
54 extern const cl_GV_I cl_null_GV_I;
55 inline cl_GV_I::cl_GV_I ()
56         : cl_GV<cl_I,cl_GV_RA> ((cl_heap_GV_I*) cl_null_GV_I) {}
57 CL_REQUIRE(cl_GV_I)
58
59 // Copy a vector.
60 extern const cl_GV_I copy (const cl_GV_I&);
61
62 // Output.
63 inline void fprint (cl_ostream stream, const cl_GV_I& x)
64 {
65         extern cl_print_flags cl_default_print_flags;
66         extern void print_vector (cl_ostream stream, const cl_print_flags& flags, void (* fun) (cl_ostream, const cl_print_flags&, const cl_number&), const cl_GV_number& vector);
67         extern void print_integer (cl_ostream stream, const cl_print_flags& flags, const cl_I& z);
68         print_vector(stream, cl_default_print_flags,
69                      (void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
70                      (void (*) (cl_ostream, const cl_print_flags&, const cl_I&))
71                      &print_integer,
72                      x);
73 }
74 CL_DEFINE_PRINT_OPERATOR(cl_GV_I)
75
76 // Debugging support.
77 #ifdef CL_DEBUG
78 extern int cl_GV_I_debug_module;
79 static void* const cl_GV_I_debug_dummy[] = { &cl_GV_I_debug_dummy,
80         &cl_GV_I_debug_module
81 };
82 #endif
83
84 #endif /* _CL_GV_INTEGER_H */