47#include "ramCanvas.hpp"
50typedef mjr::ramCanvas1c16b rcCNT;
51typedef mjr::ramCanvas1c8b rcM8;
52typedef mjr::ramCanvas3c8b rcC8;
56 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
57 rcC8::colorType aColor;
59 const rcCNT::colorChanType MAXITR = rcCNT::colorType::maxChanVal/1 - 2;
60 const int MCSIZE = 7680;
62 const int CSIZE = MCSIZE/CSIZEF;
63 const double MAXZSQ = 4.0;
64 const double MAXZSQU = MAXZSQ + 0.1;
65 rcC8 theRamCanvas(CSIZE, CSIZE, -2.1, 0.75, -1.4, 1.4);
66 rcCNT perRamCanvas(CSIZE, CSIZE, -2.1, 0.75, -1.4, 1.4);
67 rcCNT stbRamCanvas(CSIZE, CSIZE, -2.1, 0.75, -1.4, 1.4);
68 rcM8 noeRamCanvas(CSIZE, CSIZE, -2.1, 0.75, -1.4, 1.4);
69 rcCNT escRamCanvas(CSIZE, CSIZE, -2.1, 0.75, 1.4, 1.4);
71#pragma omp parallel for schedule(static,1)
72 for(
int y=0;y<perRamCanvas.getNumPixY();y++) {
73 rcCNT::colorChanType maxCheckpointITR = 0;
74 double meanCheckpointITR = 0;
75 std::vector<std::complex<double>> lastZs(MAXITR);
76 std::chrono::time_point<std::chrono::system_clock> rowStartTime = std::chrono::system_clock::now();
78 for(
int x=0;x<perRamCanvas.getNumPixX();x++) {
79 std::complex<double> c(perRamCanvas.int2realX(x), perRamCanvas.int2realY(y));
80 std::complex<double> z(0.0, 0.0);
81 rcCNT::colorChanType count = 1;
82 bool seekingUnderstanding =
true;
83 rcCNT::colorChanType checkpointITR = 1024*8;
85 while(seekingUnderstanding) {
86 if ((MAXITR - checkpointITR) < checkpointITR)
87 checkpointITR = MAXITR;
91 if (maxCheckpointITR < checkpointITR)
92 maxCheckpointITR = checkpointITR;
94 while((std::norm(z)<MAXZSQU) && (count<checkpointITR)) {
100 if (std::norm(z)>MAXZSQ) {
101 escRamCanvas.drawPoint(x, y, count);
102 seekingUnderstanding =
false;
104 for(rcCNT::colorChanType period=1; period<(checkpointITR-2); period++) {
105 if(std::abs(z-lastZs[checkpointITR-1-period])<1e-7) {
106 rcCNT::colorChanType stab;
107 for(stab=0; stab<(checkpointITR-period); stab++) {
108 if(std::abs(lastZs[checkpointITR-1-stab]-lastZs[checkpointITR-1-period-stab])>1e-7) {
113 stbRamCanvas.drawPoint(x, y, checkpointITR-stab);
114 perRamCanvas.drawPoint(x, y, period);
115 noeRamCanvas.drawPoint(x, y,
"white");
116 seekingUnderstanding =
false;
121 if (seekingUnderstanding && (checkpointITR == MAXITR)) {
122 noeRamCanvas.drawPoint(x, y,
"white");
123 seekingUnderstanding =
false;
128 meanCheckpointITR += checkpointITR /
static_cast<double>(CSIZE);
131 std::chrono::duration<double> rowRunTime = std::chrono::system_clock::now() - rowStartTime;
132 std::cout <<
"my: " << CSIZE <<
" y: " << y <<
" max: " << maxCheckpointITR <<
" mean: " << meanCheckpointITR <<
" secs: " << rowRunTime.count() << std::endl;
135 perRamCanvas.writeTIFFfile(
"mandelbrot_precompPER.tiff");
136 stbRamCanvas.writeTIFFfile(
"mandelbrot_precompSTB.tiff");
137 escRamCanvas.writeTIFFfile(
"mandelbrot_precompESC.tiff");
138 noeRamCanvas.writeTIFFfile(
"mandelbrot_precompNOE.tiff");
145 for(
int y=0;y<theRamCanvas.getNumPixY();y++) {
146 for(
int x=0;x<theRamCanvas.getNumPixX();x++) {
147 auto period = perRamCanvas.getPxColorNC(x, y).getC0();
151 if (period > (rcC8::colorType::csCBDark2::maxNumC-1)) {
152 theRamCanvas.drawPoint(x, y,
"red");
154 theRamCanvas.drawPoint(x, y, rcC8::colorType::csCBDark2::c(period));
158 if (noeRamCanvas.getPxColorNC(x, y).getC0() > 0) {
159 theRamCanvas.drawPoint(x, y,
"green");
162 rcC8::csFltType c =
static_cast<rcC8::csFltType
>(escRamCanvas.getPxColorNC(x, y).getC0()) / MAXITR;
163 theRamCanvas.drawPoint(x, y, rcC8::colorType::csCCdiag01::c(c*30));
170 theRamCanvas.drawString(
"1", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.1500, 0.0000,
"black", 6.0/CSIZEF, 20);
171 theRamCanvas.drawString(
"2", mjr::hershey::font::ROMAN_SL_SANSERIF, -1.0000, 0.0000,
"black", 6.0/CSIZEF, 20);
173 theRamCanvas.drawString(
"3", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.1200, 0.7400,
"black", 6.0/CSIZEF, 20);
174 theRamCanvas.drawString(
"3", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.1200, -0.7400,
"black", 6.0/CSIZEF, 20);
175 theRamCanvas.drawString(
"3", mjr::hershey::font::ROMAN_SL_SANSERIF, -1.758, 0.0000,
"black", 1.0/CSIZEF, 20);
177 theRamCanvas.drawString(
"4", mjr::hershey::font::ROMAN_SL_SANSERIF, -1.3100, 0.0000,
"black", 6.0/CSIZEF, 20);
178 theRamCanvas.drawString(
"4", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.2800, 0.5320,
"black", 6.0/CSIZEF, 20);
179 theRamCanvas.drawString(
"4", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.2800, -0.5320,
"black", 6.0/CSIZEF, 20);
181 theRamCanvas.drawString(
"5", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.5060, -0.5620,
"black", 4.0/CSIZEF, 20);
182 theRamCanvas.drawString(
"5", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3780, -0.3370,
"black", 4.0/CSIZEF, 20);
183 theRamCanvas.drawString(
"5", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.5060, 0.5620,
"black", 4.0/CSIZEF, 20);
184 theRamCanvas.drawString(
"5", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3780, 0.3370,
"black", 4.0/CSIZEF, 20);
186 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3890, -0.2150,
"black", 2.0/CSIZEF, 20);
187 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.1140, -0.8620,
"black", 4.0/CSIZEF, 20);
188 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, -1.1370, -0.2390,
"black", 4.0/CSIZEF, 20);
189 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3890, 0.2150,
"black", 2.0/CSIZEF, 20);
190 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.1140, 0.8620,
"black", 4.0/CSIZEF, 20);
191 theRamCanvas.drawString(
"6", mjr::hershey::font::ROMAN_SL_SANSERIF, -1.1370, 0.2390,
"black", 4.0/CSIZEF, 20);
193 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.6220, -0.4240,
"black", 2.0/CSIZEF, 20);
194 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.1210, -0.6100,
"black", 2.0/CSIZEF, 20);
195 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3760, -0.1440,
"black", 1.0/CSIZEF, 20);
196 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, -0.6220, 0.4240,
"black", 2.0/CSIZEF, 20);
197 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.1210, 0.6100,
"black", 2.0/CSIZEF, 20);
198 theRamCanvas.drawString(
"7", mjr::hershey::font::ROMAN_SL_SANSERIF, 0.3760, 0.1440,
"black", 1.0/CSIZEF, 20);
200 theRamCanvas.writeTIFFfile(
"mandelbrot_precomp.tiff");
202 std::cout <<
"numConNoCyc ... " << numConNoCyc << std::endl;
203 std::cout <<
"numCyc ........ " << numCyc << std::endl;
204 std::cout <<
"numInSet ...... " << numConNoCyc+numCyc << std::endl;
205 std::cout <<
"numEsc ........ " << numEsc << std::endl;
206 std::cout <<
"numPts ........ " << numPts << std::endl;
207 std::cout <<
"maxPer ........ " << maxPer << std::endl;
209 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
210 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
int main(int argc, char *argv[])