35#include "ramCanvas.hpp"
38typedef mjr::ramCanvas3c8b rcT;
42enum class whyStopNH { DIVZERO,
51 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
52 constexpr rcT::coordIntType IMXSIZ = 7680;
53 constexpr rcT::coordIntType IMYSIZ = 4320;
54 constexpr double MAXZ = -32.0;
55 constexpr int MAXITR = 64;
56 constexpr double ZROEPS = 0.0001;
57 constexpr int numToKeep = 5;
59 rcT::colorType aColor(255, 255, 255);
65 rcT theRamCanvas(std::max(IMXSIZ, IMYSIZ), std::max(IMXSIZ, IMYSIZ), 0.6, 1.1, -0.4, 0.4);
67# pragma omp parallel for schedule(static,1)
68 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
70 std::cout <<
"Line: " << y <<
" of " << theRamCanvas.getNumPixY() << std::endl;
71 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
72 std::complex<double> z = theRamCanvas.int2real(x, y);
74 std::vector<std::complex<double>> lastZs(numToKeep);
75 rcT::csIntType count = 0;
78 if (count >= MAXITR) {
79 why = whyStopNH::TOOLONG;
87 std::complex<double> cz = ((cos(z)-z*sin(z))*cos(z*cos(z)));
88 if(std::abs(cz) < ZROEPS) {
89 why = whyStopNH::DIVZERO;
98 double modz = std::abs(z);
99 lastZs[count%numToKeep] = z;
103 if(count >= numToKeep) {
104 bool allEqual =
true;
105 for(
int i=1; i<numToKeep; i++)
106 if(std::abs(lastZs[0]-lastZs[i])>ZROEPS) {
111 if(std::imag(z) > 0) {
113 why = whyStopNH::CONVERGEU;
115 why = whyStopNH::CONVERGEL;
120 if((MAXZ>0) && (modz>MAXZ)) {
121 why = whyStopNH::TOOBIG;
127 rcT::csIntType ccol = (2*4*count);
128 rcT::csIntType mcol = ((rcT::csIntType)(2*8*maxMod));
130 case whyStopNH::TOOLONG : theRamCanvas.drawPoint(x, y, rcT::colorType::csCCwicM::c(mcol));
break;
131 case whyStopNH::CONVERGEU : theRamCanvas.drawPoint(x, y, rcT::colorType::csCCwicB::c(mcol+ccol));
break;
132 case whyStopNH::CONVERGEL : theRamCanvas.drawPoint(x, y, rcT::colorType::csCCwicR::c(mcol+ccol));
break;
133 case whyStopNH::TOOBIG : theRamCanvas.drawPoint(x, y, rcT::colorType(
"black"));
break;
134 case whyStopNH::DIVZERO : theRamCanvas.drawPoint(x, y, rcT::colorType::csCCwicC::c(mcol+ccol));
break;
138 theRamCanvas.writeTIFFfile(
"newton_half.tiff");
139 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
140 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])