140 NewtonFractal(
double detailFactor = 1,
double _min = -1.0,
double _max = 1.0,
int _maxIter = 100,
double _tol = 1e-5)
159 auto M =
zeros(n, n);
160 std::vector<Matrix<double>> roots;
162 for(
size_t i = 0; i < n; ++i) {
163 for(
size_t j = 0; j < n; ++j) {
169 for(
size_t k = 0; k < roots.size(); ++k) {
170 if(
norm(res.first - roots[k]) <=
tol) { index = k; }
173 index = roots.size();
174 roots.push_back(res.first);
176 M(i, j) = (double)index;
197 return Matrix<double>({ {
pow(x(0, 0), 3) - 3 * x(0, 0) * x(1, 0) * x(1, 0) - 1 },
198 { -
pow(x(1, 0), 3) + 3 * x(0, 0) * x(0, 0) * x(1, 0) } });
213 return Matrix<double>({ { 3 * (x(0, 0) * x(0, 0) - x(1, 0) * x(1, 0)), -6 * x(0, 0) * x(1, 0) },
214 { 6 * x(0, 0) * x(1, 0), 3 * x(0, 0) * x(0, 0) - 3 * x(1, 0) * x(1, 0) } });
249 for(
size_t x = 0; x <
detail; ++x) {
250 for(
size_t y = 0; y <
detail; ++y) {
251 M(x, y) = (double)
fun((
startX + stepWidthX * (
double)x), (
startY + stepWidthY * (double)y));
252 if(M(x, y) == (double)
maxIters) { M(x, y) = 0; }
265 size_t fun(
const double& real_c,
const double& img_c) {
270 while(++iters <
maxIters && real * real + img * img < 4) {
272 real = real * real + real_c - img * img;
273 img = 2 * img * temp + img_c;
double pow(double x, int exponent)
Definition: Fractals.h:222
size_t maxIters
max number iterations for approximation of single value
Definition: Fractals.h:225
size_t detail
detail factor for approximation
Definition: Fractals.h:231
size_t fun(const double &real_c, const double &img_c)
Definition: Fractals.h:265
double endY
Definition: Fractals.h:229
Matrix< double > operator()()
Definition: Fractals.h:244
double startX
start and end value on x-axis
Definition: Fractals.h:227
Mandelbrot()
Definition: Fractals.h:237
double startY
start and end value on y-axis
Definition: Fractals.h:229
double endX
Definition: Fractals.h:227
constexpr Matrix< T > Transpose() const
Definition: Matrix.h:256
Definition: Fractals.h:119
double yMax
Definition: Fractals.h:126
int maxIter
max number iterations for newton algorithm
Definition: Fractals.h:128
NewtonFractal(double detailFactor=1, double _min=-1.0, double _max=1.0, int _maxIter=100, double _tol=1e-5)
Definition: Fractals.h:140
static Matrix< double > jac(const Matrix< double > &x)
Definition: Fractals.h:212
double tol
tolerance used for newton algorithm
Definition: Fractals.h:130
Matrix< double > operator()() const
Definition: Fractals.h:154
static Matrix< double > fun(const Matrix< double > &x)
Definition: Fractals.h:196
double xMin
start and end value on x-axis
Definition: Fractals.h:124
double xMax
Definition: Fractals.h:124
double detail
detail factor for approximation
Definition: Fractals.h:122
double yMin
start and end value on y-axis
Definition: Fractals.h:126
std::pair< Matrix< double >, int > newton(const LinearEquation &f, const Jacobian &Df, const Matrix< double > &x0, double TOL, int maxIter)
Definition: newton.h:32
double norm(const Matrix< double > &in)
Matrix< double > zeros(size_t rows, size_t columns, size_t elements=1)
Matrix< double > linspace(double start, double end, unsigned long num_elements)