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.

63 lines
2.0 KiB

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