84 lines
2.7 KiB

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