Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:30

0001 // General vectors of integers.
0002 
0003 #ifndef _CL_GV_INTEGER_H
0004 #define _CL_GV_INTEGER_H
0005 
0006 #include "cln/number.h"
0007 #include "cln/GV_rational.h"
0008 #include "cln/integer_class.h"
0009 #include "cln/io.h"
0010 
0011 namespace cln {
0012 
0013 // A vector of integers is *not* just a normal vector of numbers (the vectorops
0014 // support the maxbits() operation), but we treat can it like this nevertheless.
0015 
0016 template <>
0017 struct cl_heap_GV<cl_I> : cl_heap {
0018     cl_GV_inner<cl_I> v;
0019     // here room for the elements
0020     sintC maxbits () const;
0021 };
0022 typedef cl_heap_GV<cl_I> cl_heap_GV_I;
0023 
0024 struct cl_GV_I : public cl_GV<cl_I,cl_GV_RA> {
0025 public:
0026     // Constructors.
0027     cl_GV_I ();
0028     cl_GV_I (const cl_GV_I&);
0029     // Create a vector of unconstrained integers.
0030     explicit cl_GV_I (std::size_t len);
0031     // Create a vector of m-bit integers (>=0, <2^m).
0032     cl_GV_I (std::size_t len, sintC m);
0033     // Assignment operators.
0034     cl_GV_I& operator= (const cl_GV_I&);
0035     // Number m of bits allowed per element (-1 if unconstrained).
0036     sintC maxbits () const
0037     {
0038         return ((const cl_heap_GV_I *) pointer)->maxbits();
0039     }
0040     // Private pointer manipulations.
0041     cl_GV_I (cl_heap_GV_I* p) : cl_GV<cl_I,cl_GV_RA> (p) {}
0042     cl_GV_I (cl_private_thing p) : cl_GV<cl_I,cl_GV_RA> (p) {}
0043 };
0044 inline cl_GV_I::cl_GV_I (const cl_GV_I& x) : cl_GV<cl_I,cl_GV_RA> (as_cl_private_thing(x)) {}
0045 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_I,cl_GV_I)
0046 extern cl_heap_GV_I* cl_make_heap_GV_I (std::size_t len);
0047 inline cl_GV_I::cl_GV_I (std::size_t len)
0048     : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len)) {}
0049 extern cl_heap_GV_I* cl_make_heap_GV_I (std::size_t len, sintC m);
0050 inline cl_GV_I::cl_GV_I (std::size_t len, sintC m)
0051     : cl_GV<cl_I,cl_GV_RA> (cl_make_heap_GV_I(len,m)) {}
0052 
0053 // Private pointer manipulations. Never throw away a `struct cl_heap_GV_I *'!
0054 extern const cl_GV_I cl_null_GV_I;
0055 inline cl_GV_I::cl_GV_I ()
0056     : cl_GV<cl_I,cl_GV_RA> ((cl_heap_GV_I*) cl_null_GV_I) {}
0057 class cl_GV_I_init_helper
0058 {
0059     static int count;
0060 public:
0061     cl_GV_I_init_helper();
0062     ~cl_GV_I_init_helper();
0063 };
0064 static cl_GV_I_init_helper cl_GV_I_init_helper_instance;
0065 
0066 // Copy a vector.
0067 extern const cl_GV_I copy (const cl_GV_I&);
0068 
0069 // Output.
0070 inline void fprint (std::ostream& stream, const cl_GV_I& x)
0071 {
0072     extern cl_print_flags default_print_flags;
0073     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);
0074     extern void print_integer (std::ostream& stream, const cl_print_flags& flags, const cl_I& z);
0075     print_vector(stream, default_print_flags,
0076                  (void (*) (std::ostream&, const cl_print_flags&, const cl_number&))
0077                  (void (*) (std::ostream&, const cl_print_flags&, const cl_I&))
0078                  &print_integer,
0079                  x);
0080 }
0081 CL_DEFINE_PRINT_OPERATOR(cl_GV_I)
0082 
0083 // Debugging support.
0084 #ifdef CL_DEBUG
0085 extern int cl_GV_I_debug_module;
0086 CL_FORCE_LINK(cl_GV_I_debug_dummy, cl_GV_I_debug_module)
0087 #endif
0088 
0089 }  // namespace cln
0090 
0091 #endif /* _CL_GV_INTEGER_H */