1 // Simple vectors of rational numbers.
2
3 #ifndef _CL_SV_RATIONAL_H
4 #define _CL_SV_RATIONAL_H
5
6 #include "cln/number.h"
7 #include "cln/SV_real.h"
8 #include "cln/rational_class.h"
9 #include "cln/io.h"
10
11 namespace cln {
12
13 // A vector of rational numbers is just a normal vector of real numbers.
14
15 typedef cl_heap_SV<cl_RA> cl_heap_SV_RA;
16
17 struct cl_SV_RA : public cl_SV<cl_RA,cl_SV_R> {
18 public:
19 // Constructors.
cl_SV_RAcl_SV_RA20 cl_SV_RA () : cl_SV<cl_RA,cl_SV_R> ((cl_heap_SV_RA*) (cl_heap_SV_number*) cl_null_SV_number) {};
21 cl_SV_RA (const cl_SV_RA&);
cl_SV_RAcl_SV_RA22 explicit cl_SV_RA (std::size_t len) : cl_SV<cl_RA,cl_SV_R> ((cl_heap_SV_RA*) cl_make_heap_SV_number(len)) {};
23 // Assignment operators.
24 cl_SV_RA& operator= (const cl_SV_RA&);
25 // Private pointer manipulations.
cl_SV_RAcl_SV_RA26 cl_SV_RA (cl_heap_SV_RA* p) : cl_SV<cl_RA,cl_SV_R> (p) {}
cl_SV_RAcl_SV_RA27 cl_SV_RA (cl_private_thing p) : cl_SV<cl_RA,cl_SV_R> (p) {}
28 };
cl_SV_RA(const cl_SV_RA & x)29 inline cl_SV_RA::cl_SV_RA (const cl_SV_RA& x) : cl_SV<cl_RA,cl_SV_R> (as_cl_private_thing(x)) {}
CL_DEFINE_ASSIGNMENT_OPERATOR(cl_SV_RA,cl_SV_RA)30 CL_DEFINE_ASSIGNMENT_OPERATOR(cl_SV_RA,cl_SV_RA)
31
32 // Copy a simple vector.
33 inline const cl_SV_RA copy (const cl_SV_RA& vector)
34 {
35 return The(cl_SV_RA) (copy((const cl_SV_R&) vector));
36 }
37
38 // Output.
fprint(std::ostream & stream,const cl_SV_RA & x)39 inline void fprint (std::ostream& stream, const cl_SV_RA& x)
40 {
41 extern cl_print_flags default_print_flags;
42 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_SV_number& vector);
43 extern void print_rational (std::ostream& stream, const cl_print_flags& flags, const cl_RA& z);
44 print_vector(stream, default_print_flags,
45 (void (*) (std::ostream&, const cl_print_flags&, const cl_number&))
46 (void (*) (std::ostream&, const cl_print_flags&, const cl_RA&))
47 &print_rational,
48 x);
49 }
50 CL_DEFINE_PRINT_OPERATOR(cl_SV_RA)
51
52 } // namespace cln
53
54 #endif /* _CL_SV_RAATIONAL_H */
55