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.

54 lines
1.8 KiB

25 years ago
  1. // General vectors of rational numbers.
  2. #ifndef _CL_GV_RATIONAL_H
  3. #define _CL_GV_RATIONAL_H
  4. #include "cl_number.h"
  5. #include "cl_GV_real.h"
  6. #include "cl_rational_class.h"
  7. #include "cl_io.h"
  8. // A vector of rational numbers is just a normal vector of real numbers.
  9. typedef cl_heap_GV<cl_RA> cl_heap_GV_RA;
  10. struct cl_GV_RA : public cl_GV<cl_RA,cl_GV_R> {
  11. public:
  12. // Constructors.
  13. cl_GV_RA ();
  14. cl_GV_RA (const cl_GV_RA&);
  15. explicit cl_GV_RA (uintL len);
  16. // Assignment operators.
  17. cl_GV_RA& operator= (const cl_GV_RA&);
  18. // Private pointer manipulations.
  19. cl_GV_RA (cl_heap_GV_RA* p) : cl_GV<cl_RA,cl_GV_R> (p) {}
  20. cl_GV_RA (cl_private_thing p) : cl_GV<cl_RA,cl_GV_R> (p) {}
  21. };
  22. inline cl_GV_RA::cl_GV_RA (const cl_GV_RA& x) : cl_GV<cl_RA,cl_GV_R> (as_cl_private_thing(x)) {}
  23. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_GV_RA,cl_GV_RA)
  24. inline cl_GV_RA::cl_GV_RA (uintL len)
  25. : cl_GV<cl_RA,cl_GV_R> ((cl_heap_GV_RA*) cl_make_heap_GV_number(len)) {}
  26. inline cl_GV_RA::cl_GV_RA ()
  27. : cl_GV<cl_RA,cl_GV_R> ((cl_heap_GV_RA*) (cl_heap_GV_number*) cl_null_GV_number) {}
  28. // Copy a vector.
  29. inline const cl_GV_RA copy (const cl_GV_RA& vector)
  30. {
  31. return The(cl_GV_RA) (copy((const cl_GV_R&) vector));
  32. }
  33. // Output.
  34. inline void fprint (cl_ostream stream, const cl_GV_RA& x)
  35. {
  36. extern cl_print_flags cl_default_print_flags;
  37. 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);
  38. extern void print_rational (cl_ostream stream, const cl_print_flags& flags, const cl_RA& z);
  39. print_vector(stream, cl_default_print_flags,
  40. (void (*) (cl_ostream, const cl_print_flags&, const cl_number&))
  41. (void (*) (cl_ostream, const cl_print_flags&, const cl_RA&))
  42. &print_rational,
  43. x);
  44. }
  45. CL_DEFINE_PRINT_OPERATOR(cl_GV_RA)
  46. #endif /* _CL_GV_RAATIONAL_H */