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.

84 lines
2.7 KiB

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