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