|
|
@ -1,29 +1,16 @@ |
|
|
|
#include "Attractor.hpp" |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
/*
|
|
|
|
Constructors & initialisers |
|
|
|
*/ |
|
|
|
Attractor::Attractor() { |
|
|
|
|
|
|
|
myAttractor = new Lorenz3D(); |
|
|
|
|
|
|
|
// TODO: add default parameters
|
|
|
|
} |
|
|
|
|
|
|
|
Attractor::Attractor(const char* const fileName) { |
|
|
|
ifstream file(fileName); |
|
|
|
|
|
|
|
cout << "Reading file " << fileName << "..." << endl; |
|
|
|
|
|
|
|
if ( !file ) { |
|
|
|
cerr << " Error reading file '" << fileName << "' dying now..." << endl; |
|
|
|
exit(2); |
|
|
|
} |
|
|
|
|
|
|
|
// TODO : Use stfu
|
|
|
|
|
|
|
|
stfu::node system; |
|
|
|
system.read(file); |
|
|
|
system.read(fileName); |
|
|
|
stfu::node attractor = system.getChild("attractor"); |
|
|
|
|
|
|
|
string attractorType = attractor.getValue("type"); |
|
|
@ -72,7 +59,7 @@ Attractor::Attractor(const char* const fileName) { |
|
|
|
exit(3); |
|
|
|
} |
|
|
|
|
|
|
|
unsigned int numberOfParameters = myAttractor->getNumberOfParameters(); |
|
|
|
const unsigned int numberOfParameters = myAttractor->getNumberOfParameters(); |
|
|
|
double * & parameters = myAttractor->parameters(); |
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < numberOfParameters; i++ ) { |
|
|
@ -85,19 +72,18 @@ Attractor::Attractor(const char* const fileName) { |
|
|
|
} |
|
|
|
|
|
|
|
void Attractor::init_range() { |
|
|
|
/*
|
|
|
|
// stabilize attractor
|
|
|
|
for ( unsigned int i = 0; i < 100000; i++ ) { |
|
|
|
iterate(); |
|
|
|
if ( !is_chaos() ) { |
|
|
|
cout << "Attractor died after " << i << " iterations" << endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// initialize ranges
|
|
|
|
// initialize projectors with dimension and first point
|
|
|
|
const unsigned int* dim = (unsigned int*)myAttractor->getProperty("dimension"); |
|
|
|
const unsigned int dimension = *dim; |
|
|
|
delete dim; |
|
|
|
const double * point = myAttractor->vector(); |
|
|
|
for ( vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) { |
|
|
|
(*it)->extern_dim = dim; |
|
|
|
(*it)->extern_dim = dimension; |
|
|
|
(*it)->intern_dim = 2; |
|
|
|
(*it)->init(point); |
|
|
|
} |
|
|
@ -105,20 +91,15 @@ void Attractor::init_range() { |
|
|
|
// update ranges
|
|
|
|
for ( unsigned int i = 0; i < 100000; i++ ) { |
|
|
|
iterate(); |
|
|
|
if ( !is_chaos() ) { |
|
|
|
cout << "Attractor died after " << i << " iterations" << endl; |
|
|
|
exit(0); |
|
|
|
} |
|
|
|
|
|
|
|
for ( vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) { |
|
|
|
(*it)->update_range(point); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for ( vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) { |
|
|
|
(*it)->finish_range(); |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bool Attractor::is_chaos() { |
|
|
@ -164,12 +145,12 @@ void Attractor::plot() { |
|
|
|
*/ |
|
|
|
void Attractor::output() { |
|
|
|
const unsigned int* dim = (unsigned int*)myAttractor->getProperty("dimension"); |
|
|
|
const unsigned int dimension = *dim; |
|
|
|
delete dim; |
|
|
|
const double * point = myAttractor->vector(); |
|
|
|
|
|
|
|
for ( unsigned int i = 0; i < *dim; i++ ) { |
|
|
|
for ( unsigned int i = 0; i < dimension; i++ ) { |
|
|
|
cout << point[i] << " "; |
|
|
|
} |
|
|
|
cout << endl; |
|
|
|
|
|
|
|
delete dim; |
|
|
|
} |
|
|
|