You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.8 KiB

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. #ifdef HAVE_TEMPLATE_NULL
  12. template <>
  13. #endif
  14. struct cl_heap_GV<cl_I> : cl_heap {
  15. cl_GV_inner<cl_I> v;
  16. // here room for the elements
  17. sintL maxbits () const;
  18. };
  19. typedef cl_heap_GV<cl_I> cl_heap_GV_I;
  20. struct cl_GV_I : public cl_GV<cl_I,cl_GV_RA> {
  21. public:
  22. // Constructors.
  23. cl_GV_I ();
  24. cl_GV_I (const cl_GV_I&);
  25. // Create a vector of unconstrained integers.
  26. explicit cl_GV_I (uintL len);
  27. // Create a vector of m-bit integers (>=0, <2^m).
  28. cl_GV_I (uintL len, sintL m);
  29. // Assignment operators.
  30. cl_GV_I& operator= (const cl_GV_I&);
  31. // Number m of bits allowed per element (-1 if unconstrained).
  32. sintL maxbits () const
  33. {
  34. return ((const cl_heap_GV_I *) pointer)->maxbits();
  35. }
  36. // Private pointer manipulations.
  37. cl_GV_I (cl_heap_GV_I* p) : cl_GV<cl_I,cl_GV_RA> (p) {}
  38. cl_GV_I (cl_private_thing p) : cl_GV<cl_I,cl_GV_RA> (p) {}
  39. };
  40. inline cl_GV_I::cl_GV_I (const cl_GV_I& x) : cl_GV<cl_I,cl_GV_RA> (as_cl_private_thing(x)) {}
  41. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_I,cl_GV_I)
  42. extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len);
  43. inline cl_GV_I::cl_GV_I (uintL len)
  44. : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len)) {}
  45. extern cl_heap_GV_I* cl_make_heap_GV_I (uintL len, sintL m);
  46. inline cl_GV_I::cl_GV_I (uintL len, sintL m)
  47. : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len,m)) {}
  48. // Private pointer manipulations. Never throw away a `struct cl_heap_GV_I *'!
  49. extern const cl_GV_I cl_null_GV_I;
  50. inline cl_GV_I::cl_GV_I ()
  51. : cl_GV<cl_I,cl_GV_RA> ((cl_heap_GV_I*) cl_null_GV_I) {}
  52. CL_REQUIRE(cl_GV_I)
  53. // Copy a vector.
  54. extern const cl_GV_I copy (const cl_GV_I&);
  55. // Output.
  56. inline void fprint (std::ostream& stream, const cl_GV_I& x)
  57. {
  58. extern cl_print_flags default_print_flags;
  59. 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);
  60. extern void print_integer (std::ostream& stream, const cl_print_flags& flags, const cl_I& z);
  61. print_vector(stream, default_print_flags,
  62. (void (*) (std::ostream&, const cl_print_flags&, const cl_number&))
  63. (void (*) (std::ostream&, const cl_print_flags&, const cl_I&))
  64. &print_integer,
  65. x);
  66. }
  67. CL_DEFINE_PRINT_OPERATOR(cl_GV_I)
  68. // Debugging support.
  69. #ifdef CL_DEBUG
  70. extern int cl_GV_I_debug_module;
  71. static void* const cl_GV_I_debug_dummy[] = { &cl_GV_I_debug_dummy,
  72. &cl_GV_I_debug_module
  73. };
  74. #endif
  75. } // namespace cln
  76. #endif /* _CL_GV_INTEGER_H */