|
|
@ -1,5 +1,6 @@ |
|
|
|
#include <iostream> |
|
|
|
#include <ctime> |
|
|
|
#include <valarray> |
|
|
|
|
|
|
|
#include "Attractor.hpp" |
|
|
|
#include "Canvas.hpp" |
|
|
@ -7,11 +8,17 @@ |
|
|
|
|
|
|
|
#include "defines.hpp" |
|
|
|
|
|
|
|
/*
|
|
|
|
I compared the performance of C-style arrays with valarray. My conclusion is that accessing and setting elements makes no difference (sometimes C-syle array's were just 2% faster, but sometimes valarray was 2% faster (5000000 samples)). But the allocation and initialisation of the valrray was like 30% faster, so it might be a good idea to change my C-style array to valarray. It is also nicer in use, one can use functions like sum, etc. How valarray manages memory may also be more efficient, but all i know is that a valarray<double> is bigger than a double* (in means of sizeof()), but that is not really an issue. So valarray!!! |
|
|
|
*/ |
|
|
|
|
|
|
|
int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
clock_t start, end; |
|
|
|
double totalTime, totalIterations; |
|
|
|
|
|
|
|
bool verbose = false; |
|
|
|
|
|
|
|
// initialising stuff
|
|
|
|
Attractor myAttractor(ATTRACTOR_FILE); |
|
|
|
|
|
|
@ -31,16 +38,17 @@ int main(int argc, char *argv[]) { |
|
|
|
myAttractor.iterate(); |
|
|
|
myAttractor.plot(); |
|
|
|
} |
|
|
|
system("clear"); |
|
|
|
myAttractor.output(); |
|
|
|
std::cout << j << "% done" << std::endl; |
|
|
|
if (verbose) { |
|
|
|
myAttractor.output(); |
|
|
|
std::cout << j << "% done" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
|
end = clock(); |
|
|
|
|
|
|
|
totalIterations = 100.0*iterations; |
|
|
|
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC)); |
|
|
|
printf("\ntotal clock time: %f\n", totalTime ); |
|
|
|
printf("average iterations per second: %f\n\n", totalIterations/((double)(end-start)/(double)(CLOCKS_PER_SEC)) ); |
|
|
|
std::cout << std::endl << "total clock time: " << totalTime << std::endl; |
|
|
|
std::cout << "average iterations per second: " << totalIterations/((double)(end-start)/(double)(CLOCKS_PER_SEC)) << std::endl << std::endl; |
|
|
|
|
|
|
|
// saving output
|
|
|
|
start = clock(); |
|
|
@ -49,97 +57,8 @@ int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC)); |
|
|
|
|
|
|
|
printf("total clock time for writing png: %f\n", totalTime ); |
|
|
|
printf("\n Awesome Attractor, version %s\n", __DATE__); |
|
|
|
|
|
|
|
/*if ( argc <= 2 ) {
|
|
|
|
cout << endl << "nothing to do..." << endl; |
|
|
|
cout << "usage:" << endl; |
|
|
|
cout << " rendering to canvas: -a my_attractor.attr 500000000 my_attractor.canv 800 600 3" << endl; |
|
|
|
cout << " canvas to png: -c my_attractor.canv 800 600 3 my_atttractor.png" << endl << endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
int mode; |
|
|
|
string argv1 = argv[1]; |
|
|
|
if ( argv1 == "-a" ) { |
|
|
|
cout << "rendermode" << endl; |
|
|
|
mode = 1; |
|
|
|
} else if ( argv1 == "-c" ) { |
|
|
|
cout << "canvasmode" << endl; |
|
|
|
mode = 2; |
|
|
|
} else { |
|
|
|
cout << "i do.. i do... i do not understand... \"" << argv1 << "\""<< endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
switch ( mode ) { |
|
|
|
case 1: { |
|
|
|
if ( argc != 8 ) { |
|
|
|
cout << "all parameters must be set..." << endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
string attractorFile = argv[2]; |
|
|
|
unsigned int iterations = atoi(argv[3]); |
|
|
|
string canvasFile = argv[4]; |
|
|
|
unsigned int width = atoi(argv[5]); |
|
|
|
unsigned int height = atoi(argv[6]); |
|
|
|
unsigned int numColors = atoi(argv[7]); |
|
|
|
|
|
|
|
Attractor attract(attractorFile.c_str()); |
|
|
|
cout << attractorFile << " is read" << endl; |
|
|
|
|
|
|
|
Projector projection; |
|
|
|
Canvas canvas(width, height, numColors); |
|
|
|
projection.canvas = &canvas; |
|
|
|
|
|
|
|
attract.projectors.push_back(&projection); |
|
|
|
attract.init_range(); |
|
|
|
|
|
|
|
projection.output(); |
|
|
|
|
|
|
|
for ( unsigned int j = 1; j <= 100; j++ ) { |
|
|
|
for ( unsigned int i = 0; 100*i <= iterations; i++ ) { |
|
|
|
attract.iterate(); |
|
|
|
attract.plot(); |
|
|
|
} |
|
|
|
cout << j << "% done" << endl; |
|
|
|
} |
|
|
|
|
|
|
|
canvas.output_raw(canvasFile.c_str()); |
|
|
|
cout << canvasFile << " is outputted" << endl; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
case 2: { |
|
|
|
if ( argc != 7 ) { |
|
|
|
cout << "all parameters must be set..." << endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
string canvasFile = argv[2]; |
|
|
|
unsigned int width = atoi(argv[3]); |
|
|
|
unsigned int height = atoi(argv[4]); |
|
|
|
unsigned int numColors = atoi(argv[5]); |
|
|
|
string pngFile = argv[6]; |
|
|
|
|
|
|
|
Canvas canvas(width, height, numColors); |
|
|
|
canvas.input_raw(canvasFile.c_str()); |
|
|
|
cout << canvasFile << " is read" << endl; |
|
|
|
for ( double v = -1.5; v < 1.6; v += 1.5 ) { |
|
|
|
canvas.v = v; |
|
|
|
canvas.output_file(); |
|
|
|
} |
|
|
|
cout << pngFile << " was exported" << endl; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
default: { |
|
|
|
cout << "WTF" << endl; |
|
|
|
break; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
std::cout << "total clock time for writing png: " << totalTime << std::endl; |
|
|
|
std::cout << std::endl << "Awesome Attractor, version " << __DATE__ << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|