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.

53 lines
1.5 KiB

25 years ago
25 years ago
25 years ago
  1. // General vectors of modular integers.
  2. #ifndef _CL_GV_MODINTEGER_H
  3. #define _CL_GV_MODINTEGER_H
  4. #include "cln/modinteger.h"
  5. #include "cln/GV_integer.h"
  6. namespace cln {
  7. // A vector of modular integers (over the same modular integer ring)
  8. // is just a normal vector of integers, with maxbits() operation.
  9. #ifdef HAVE_TEMPLATE_NULL
  10. template <>
  11. #endif
  12. struct cl_heap_GV<_cl_MI> : cl_heap {
  13. cl_GV_inner<_cl_MI> v;
  14. // here room for the elements
  15. };
  16. typedef cl_heap_GV<_cl_MI> cl_heap_GV_MI;
  17. struct cl_GV_MI : public cl_GV<_cl_MI,cl_GV_any> {
  18. public:
  19. // Constructors.
  20. cl_GV_MI ();
  21. cl_GV_MI (const cl_GV_MI&);
  22. // Create a vector of modular integers.
  23. cl_GV_MI (uintL len, cl_heap_modint_ring* R);
  24. // Assignment operators.
  25. cl_GV_MI& operator= (const cl_GV_MI&);
  26. // Number m of bits allowed per element (-1 if unconstrained).
  27. sintL maxbits () const
  28. {
  29. return ((const cl_heap_GV_I *) pointer)->maxbits();
  30. }
  31. };
  32. inline cl_GV_MI::cl_GV_MI (const cl_GV_MI& x) : cl_GV<_cl_MI,cl_GV_any> (as_cl_private_thing(x)) {}
  33. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_MI,cl_GV_MI)
  34. inline cl_GV_MI::cl_GV_MI ()
  35. : cl_GV<_cl_MI,cl_GV_any> ((cl_heap_GV_MI*) (cl_heap_GV_I*) cl_null_GV_I) {}
  36. inline cl_GV_MI::cl_GV_MI (uintL len, cl_heap_modint_ring* R)
  37. : cl_GV<_cl_MI,cl_GV_any> ((cl_heap_GV_MI*) cl_make_heap_GV_I(len,R->bits)) {}
  38. // Copy a vector.
  39. inline const cl_GV_MI copy (const cl_GV_MI& vector)
  40. {
  41. return The(cl_GV_MI) (copy((const cl_GV_I&) vector));
  42. }
  43. } // namespace cln
  44. #endif /* _CL_GV_MODINTEGER_H */