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