Generators.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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<Fixed128>();
  32. }
  33. class mnd::Generator
  34. {
  35. protected:
  36. Real precision;
  37. public:
  38. inline Generator(const Real& precision) :
  39. precision{ precision }
  40. {
  41. }
  42. virtual ~Generator(void);
  43. Generator(const Generator&) = delete;
  44. Generator& operator=(const Generator&) = delete;
  45. Generator(Generator&&) = default;
  46. Generator& operator=(Generator&&) = default;
  47. virtual void generate(const MandelInfo& info, float* data) = 0;
  48. virtual Real getPrecision(void) const;
  49. };
  50. class mnd::AdaptiveGenerator : public Generator
  51. {
  52. std::map<Real, Generator*, std::greater<Real>> generators;
  53. public:
  54. AdaptiveGenerator(void);
  55. AdaptiveGenerator(Generator* floatGen, Generator* doubleGen);
  56. virtual ~AdaptiveGenerator(void) = default;
  57. void addGenerator(const Real& precision, Generator& generator);
  58. void addGenerator(Precision p, Generator& generator);
  59. const std::map<Real, Generator*, std::greater<Real>>& getGenerators(void) const { return generators; }
  60. inline void clear(void) { generators.clear(); }
  61. virtual void generate(const MandelInfo& info, float* data) override;
  62. };
  63. #endif // MANDEL_GENERATORS_H