add optimized iteration algorithm

This commit is contained in:
Akos Horvath 2022-07-05 23:27:06 +02:00
parent c79412bdab
commit a2d5e86188

View File

@ -67,15 +67,15 @@ uint32_t Mandelbrotc::mandelbrot(const Vec2mp &n)
// y.setValue(0.0); // y.setValue(0.0);
mpreal x = mpreal(0.0); mpreal x = mpreal(0.0);
mpreal xtemp = mpreal(0.0);
mpreal y = mpreal(0.0); mpreal y = mpreal(0.0);
mpreal x2 = mpreal(0.0); mpreal x2 = mpreal(0.0);
mpreal y2 = mpreal(0.0); mpreal y2 = mpreal(0.0);
while (x*x + y*y <= 4 && iter < max_iter) { while (x2 + y2 <= 4 && iter < max_iter) {
xtemp = x*x - y*y + n.x; y = 2.0 * x * y + n.y;
y = 2*x*y+n.y; x = x2 - y2 + n.x;
x = xtemp; x2 = x * x;
y2 = y * y;
iter++; iter++;
} }