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.

65 lines
2.0 KiB

25 years ago
25 years ago
25 years ago
25 years ago
25 years ago
  1. // Abstract class of complex numbers.
  2. #ifndef _CL_COMPLEX_CLASS_H
  3. #define _CL_COMPLEX_CLASS_H
  4. #include "cln/number.h"
  5. namespace cln {
  6. class cl_N : public cl_number {
  7. public:
  8. // Default constructor.
  9. cl_N ();
  10. // Copy constructor.
  11. cl_N (const cl_N&);
  12. // Converters.
  13. // Assignment operators.
  14. cl_N& operator= (const cl_N&);
  15. // Constructors and assignment operators from C numeric types.
  16. cl_N (const int); // |argument| must be < 2^29
  17. cl_N (const unsigned int); // argument must be < 2^29
  18. cl_N (const long);
  19. cl_N (const unsigned long);
  20. cl_N (const float);
  21. cl_N (const double);
  22. cl_N& operator= (const int); // |argument| must be < 2^29
  23. cl_N& operator= (const unsigned int); // argument must be < 2^29
  24. cl_N& operator= (const long);
  25. cl_N& operator= (const unsigned long);
  26. cl_N& operator= (const float);
  27. cl_N& operator= (const double);
  28. // Other constructors.
  29. cl_N (const char *);
  30. // Private constructor.
  31. cl_N (cl_private_thing);
  32. cl_N (struct cl_heap_complex *);
  33. public: // Ability to place an object at a given address.
  34. void* operator new (size_t size) { return malloc_hook(size); }
  35. void* operator new (size_t size, void* ptr) { (void)size; return ptr; }
  36. void operator delete (void* ptr) { free_hook(ptr); }
  37. private:
  38. // Friend declarations. They are for the compiler. Just ignore them.
  39. };
  40. // Private constructors.
  41. inline cl_N::cl_N (cl_private_thing ptr) : cl_number (ptr) {}
  42. // The assignment operators:
  43. CL_DEFINE_ASSIGNMENT_OPERATOR(cl_N, cl_N)
  44. // The default constructors.
  45. inline cl_N::cl_N ()
  46. : cl_number ((cl_private_thing) cl_combine(cl_FN_tag,0)) {}
  47. // The copy constructors.
  48. CL_DEFINE_COPY_CONSTRUCTOR2(cl_N,cl_number)
  49. // Constructors and assignment operators from C numeric types.
  50. CL_DEFINE_INT_CONSTRUCTORS(cl_N)
  51. CL_DEFINE_INT_ASSIGNMENT_OPERATORS(cl_N)
  52. CL_DEFINE_LONG_CONSTRUCTORS(cl_N)
  53. CL_DEFINE_LONG_ASSIGNMENT_OPERATORS(cl_N)
  54. // Constructors and assignment operators from C numeric types.
  55. CL_DEFINE_FLOAT_CONSTRUCTOR(cl_N)
  56. CL_DEFINE_DOUBLE_CONSTRUCTOR(cl_N)
  57. } // namespace cln
  58. #endif /* _CL_COMPLEX_CLASS_H */