Generators.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef MANDEL_GENERATORS_H
  2. #define MANDEL_GENERATORS_H
  3. #include "MandelUtil.h"
  4. #include <vector>
  5. #include <map>
  6. #include <utility>
  7. namespace mnd
  8. {
  9. class Generator;
  10. class AdaptiveGenerator;
  11. enum class Precision : int
  12. {
  13. FLOAT,
  14. DOUBLE_FLOAT,
  15. DOUBLE,
  16. DOUBLE_DOUBLE,
  17. FLOAT128,
  18. FIXED64,
  19. FIXED128,
  20. QUAD_DOUBLE,
  21. FLOAT256,
  22. INF_PREC,
  23. };
  24. Real getPrecision(Precision p);
  25. template<typename T>
  26. Real getPrecision(void);
  27. template<> Real getPrecision<float>();
  28. template<> Real getPrecision<double>();
  29. template<> Real getPrecision<DoubleDouble>();
  30. template<> Real getPrecision<QuadDouble>();
  31. template<> Real getPrecision<Fixed64>();
  32. template<> Real getPrecision<Fixed128>();
  33. template<> Real getPrecision<Fixed512>();
  34. template<> Real getPrecision<Float128>();
  35. template<> Real getPrecision<Float256>();
  36. template<> Real getPrecision<Float512>();
  37. }
  38. class mnd::Generator
  39. {
  40. protected:
  41. Real precision;
  42. public:
  43. inline Generator(const Real& precision) :
  44. precision{ precision }
  45. {
  46. }
  47. virtual ~Generator(void);
  48. Generator(const Generator&) = delete;
  49. Generator& operator=(const Generator&) = delete;
  50. Generator(Generator&&) = default;
  51. Generator& operator=(Generator&&) = default;
  52. virtual void generate(const MandelInfo& info, float* data) = 0;
  53. virtual Real getPrecision(void) const;
  54. };
  55. class mnd::AdaptiveGenerator : public Generator
  56. {
  57. std::map<Real, Generator*, std::greater<Real>> generators;
  58. public:
  59. AdaptiveGenerator(void);
  60. AdaptiveGenerator(Generator* floatGen, Generator* doubleGen);
  61. virtual ~AdaptiveGenerator(void) = default;
  62. void addGenerator(const Real& precision, Generator& generator);
  63. void addGenerator(Precision p, Generator& generator);
  64. const std::map<Real, Generator*, std::greater<Real>>& getGenerators(void) const { return generators; }
  65. inline void clear(void) { generators.clear(); }
  66. virtual void generate(const MandelInfo& info, float* data) override;
  67. };
  68. #endif // MANDEL_GENERATORS_H