Generators.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 MandelGenerator;
  10. class JuliaGenerator;
  11. class AdaptiveGenerator;
  12. enum class Precision : int
  13. {
  14. FLOAT,
  15. DOUBLE_FLOAT,
  16. DOUBLE,
  17. DOUBLE_DOUBLE,
  18. FLOAT128,
  19. FIXED64,
  20. FIXED128,
  21. QUAD_DOUBLE,
  22. FLOAT256,
  23. INF_PREC,
  24. };
  25. Real getPrecision(Precision p);
  26. template<typename T>
  27. Real getPrecision(void);
  28. template<> Real getPrecision<float>();
  29. template<> Real getPrecision<double>();
  30. template<> Real getPrecision<DoubleDouble>();
  31. template<> Real getPrecision<QuadDouble>();
  32. template<> Real getPrecision<Fixed64>();
  33. template<> Real getPrecision<Fixed128>();
  34. template<> Real getPrecision<Fixed512>();
  35. template<> Real getPrecision<Float128>();
  36. template<> Real getPrecision<Float256>();
  37. template<> Real getPrecision<Float512>();
  38. }
  39. class mnd::MandelGenerator
  40. {
  41. protected:
  42. Real precision;
  43. public:
  44. inline MandelGenerator(const Real& precision) :
  45. precision{ precision }
  46. {
  47. }
  48. virtual ~MandelGenerator(void);
  49. MandelGenerator(const MandelGenerator&) = delete;
  50. MandelGenerator& operator=(const MandelGenerator&) = delete;
  51. MandelGenerator(MandelGenerator&&) = default;
  52. MandelGenerator& operator=(MandelGenerator&&) = default;
  53. virtual void generate(const MandelInfo& info, float* data) = 0;
  54. virtual Real getPrecision(void) const;
  55. };
  56. class mnd::JuliaGenerator : public MandelGenerator
  57. {
  58. public:
  59. inline JuliaGenerator(const Real& precision) :
  60. MandelGenerator{ precision }
  61. {
  62. }
  63. virtual ~JuliaGenerator(void);
  64. JuliaGenerator(const JuliaGenerator&) = delete;
  65. JuliaGenerator& operator=(const JuliaGenerator&) = delete;
  66. JuliaGenerator(JuliaGenerator&&) = default;
  67. JuliaGenerator& operator=(JuliaGenerator&&) = default;
  68. virtual void generate(const MandelInfo& info, float* data) = 0;
  69. };
  70. class mnd::AdaptiveGenerator : public MandelGenerator
  71. {
  72. std::map<Real, MandelGenerator*, std::greater<Real>> generators;
  73. public:
  74. AdaptiveGenerator(void);
  75. AdaptiveGenerator(MandelGenerator* floatGen, MandelGenerator* doubleGen);
  76. virtual ~AdaptiveGenerator(void) = default;
  77. void addGenerator(const Real& precision, MandelGenerator& generator);
  78. void addGenerator(Precision p, MandelGenerator& generator);
  79. const std::map<Real, MandelGenerator*, std::greater<Real>>& getGenerators(void) const { return generators; }
  80. inline void clear(void) { generators.clear(); }
  81. virtual void generate(const MandelInfo& info, float* data) override;
  82. };
  83. #endif // MANDEL_GENERATORS_H