-
Notifications
You must be signed in to change notification settings - Fork 0
/
MipLA.h
70 lines (52 loc) · 1.84 KB
/
MipLA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
#include <imagina/evaluator.h>
#include <vector>
namespace MipLA {
using namespace Imagina;
inline real_sr magnitude(const complex_sr &z) {
//return std::abs(z);
return chebyshev_norm(z);
}
struct LAStep {
using real = real_sr;
using complex = complex_sr;
static constexpr real ValidRadiusScale = 0x1.0p-24;
static constexpr real InitialValidRadius = std::numeric_limits<real>::infinity();
complex A, B;
real ValidRadius, ValidRadiusC;
LAStep() = default;
LAStep(const LAStep &) = default;
LAStep(LAStep &&) = default;
explicit LAStep(complex z) : A(2.0 * z), B(1.0), ValidRadius(magnitude(z) * ValidRadiusScale), ValidRadiusC(InitialValidRadius) {}
LAStep &operator=(const LAStep &) = default;
LAStep &operator=(LAStep &&) = default;
LAStep Composite(const LAStep &step) const {
LAStep result;
result.ValidRadius = std::min(ValidRadius, step.ValidRadius / magnitude(A));
result.ValidRadiusC = std::min({ ValidRadiusC, step.ValidRadiusC, step.ValidRadius / magnitude(B) });
result.A = A * step.A;
result.B = B * step.A + step.B;
return result;
}
};
class MipLAEvaluator {
using real = real_sr;
using complex = complex_sr;
struct Output {
double Value;
};
StandardEvaluationParameters parameters;
uint64_t referenceLength;
complex *reference = nullptr;
std::vector<std::vector<LAStep>> LAData;
void ComputeOrbit(const real_hp &x, const real_hp &y, real_hr radius);
void CreateLAFromOrbit();
bool CreateNewLALevel();
std::pair<LAStep *, size_t> Lookup(size_t i, real norm_dz, real norm_dc);
public:
const PixelDataInfo *GetOutputInfo();
void Prepare(const real_hp &x, const real_hp &y, real_hr radius, const StandardEvaluationParameters ¶meters);
void Evaluate(IRasterizer rasterizer);
};
}
IMPLEMENT_INTERFACE(MipLA::MipLAEvaluator, Imagina::IEvaluator);