My omnium-gatherom of scripts and source code.
1#include <bits/stdc++.h>
2
3#include <algorithm>
4#include <bitmap_image.hpp>
5#include <cmath>
6#include <fstream>
7#include <vector>
8
9int main() {
10 const int canvasSize = 10000;
11 const int maxIteration = 255;
12 bitmap_image fractal(canvasSize, canvasSize);
13 fractal.clear();
14
15 constexpr double xFactor = (2.47 / canvasSize);
16 constexpr double yFactor = (1.12 / canvasSize);
17 std::vector<std::complex<double>> arrayCoordinates;
18 for (int i = 0; i < canvasSize; i++) {
19 for (int j = 0; j < canvasSize; j++) {
20 std::complex<double> vectorCoordinate =
21 std::complex<double>(fma(j, xFactor, -2.0), fma(i, yFactor, -0.56));
22 arrayCoordinates.push_back(vectorCoordinate);
23 // std::complex<double>(fma(j, xFactor, -2.0), fma(i, yFactor, -0.56))
24 }
25 }
26
27 int index = 0;
28 //#pragma omp parallel for
29 for (std::complex<double> coordinate : arrayCoordinates) {
30 double x = 0.0;
31 double y = 0.0;
32 double xSquared = 0.0;
33 double ySquared = 0.0;
34 int iteration = 0;
35
36 while (std::islessequal((xSquared + ySquared), 4) &&
37 (iteration < maxIteration)) {
38 y = 2 * fma(x, y, coordinate.imag());
39 x = xSquared - ySquared + coordinate.real();
40 xSquared = x * x;
41 ySquared = y * y;
42 iteration++;
43 }
44
45 const int xPixel = index % canvasSize;
46 const int yPixel = index / canvasSize;
47 index++;
48 fractal.set_pixel(xPixel, yPixel, iteration, iteration, iteration);
49 }
50
51 //fractal.save_image("mandelbrot.bmp");
52 return 0;
53}