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 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1 },
{ 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1 },
{ 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2 },
{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
});
#if USE_VIS
plot("inferno.pal");
#endif
return true;
}
bool TestMandelbrot() {
auto M = fractal();
Matrix<double> expected({ { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 },
{ 2, 3, 4, 4, 5, 0, 5, 4, 4, 3 },
{ 4, 4, 4, 5, 6, 0, 6, 5, 4, 4 },
{ 4, 4, 5, 8, 0, 0, 0, 8, 5, 4 },
{ 4, 5, 7, 9, 17, 0, 17, 9, 7, 5 },
{ 5, 7, 27, 0, 0, 0, 0, 0, 27, 7 },
{ 12, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 4, 6, 16, 0, 0, 13, 0, 0, 16, 6 },
{ 3, 4, 4, 4, 5, 5, 5, 4, 4, 4 } });
AssertEqual(M, expected);
#if USE_VIS
plot();
#endif
return true;
}
public:
virtual void run() {
TestNewton();
TestMandelbrot();
}
};
int main() {
FractalsTestCase().run();
return 0;
}
void AddData(const Matrix< double > &mat, const std::string &name)
Definition: Plot.h:451
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
Definition: Fractals.h:119