diff --git a/Attractor.cpp b/Attractor.cpp index 67b913c..422d014 100644 --- a/Attractor.cpp +++ b/Attractor.cpp @@ -10,19 +10,19 @@ #include "Projector.hpp" -Attractor::Attractor(const std::string& filename) { +Attractor::Attractor(const std::string& filename) : kernel(0), projector(0) { // opening file LogInfo("Reading file '%s'...\n", filename.c_str()); stfu::node system; system.read(filename.c_str()); - stfu::node attractor = system.getChild("AttractorKernel"); - myAttractor = AttractorKernel::createAttractorKernel(attractor); + kernel = AttractorKernel::createAttractorKernel(system.getChild("AttractorKernel")); + projector = Projector::createProjector(system.getChild(system.getChild("Projector")), system); } Attractor::~Attractor(){ - delete myAttractor; + delete kernel; } @@ -33,26 +33,21 @@ void Attractor::init_range() { iterate(); } - // initialize projectors with dimension and first point - const unsigned int dimension = myAttractor->getDimension(); - const double * point = myAttractor->vector(); - for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { - (*it)->extern_dim = dimension; - (*it)->intern_dim = 3; - (*it)->init(point); - } + // initialize projector with dimension and first point + const unsigned int dimension = kernel->getDimension(); + const double * point = kernel->vector(); + + projector->extern_dim = dimension; + projector->intern_dim = 3; + projector->init(point); // update ranges for ( unsigned int i = 0; i < 500000; i++ ) { iterate(); - for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { - (*it)->update_range(point); - } - } - for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { - (*it)->finish_range(); + projector->update_range(point); } + projector->finish_range(); } @@ -83,14 +78,12 @@ bool Attractor::is_chaos() { } void Attractor::iterate() { - (*myAttractor)(); + (*kernel)(); } void Attractor::plot() { - for ( std::vector::iterator it = projectors.begin(); it != projectors.end(); it++ ) { - const double * point = myAttractor->vector(); - (*it)->plot(point); - } + const double * point = kernel->vector(); + projector->plot(point); } @@ -98,8 +91,8 @@ void Attractor::plot() { IO & control */ void Attractor::output() { - const unsigned int dimension = myAttractor->getDimension(); - const double * point = myAttractor->vector(); + const unsigned int dimension = kernel->getDimension(); + const double * point = kernel->vector(); for ( unsigned int i = 0; i < dimension; i++ ) { LogMoreInfo("%f, ", point[i]); diff --git a/Attractor.hpp b/Attractor.hpp index c487563..7b12e67 100644 --- a/Attractor.hpp +++ b/Attractor.hpp @@ -10,12 +10,12 @@ class AttractorKernel; class Attractor { private: - AttractorKernel * myAttractor; + AttractorKernel * kernel; public: // should be private really - std::vector projectors; + Projector* projector; Attractor(const std::string& filename); ~Attractor(); @@ -27,6 +27,8 @@ public: void plot(); void output(); + friend std::ostream& operator<<(std::ostream& os, Attractor const& x); + }; #endif // ATTRACTOR_HPP diff --git a/AttractorKernel.cpp b/AttractorKernel.cpp index e4080de..445ac9d 100644 --- a/AttractorKernel.cpp +++ b/AttractorKernel.cpp @@ -19,8 +19,7 @@ numberOfParameters(numberOfParameters), dimension(dimension){ try { allocate(); - } - catch (std::exception& e) { + } catch (std::exception& e) { LogError("Couldn't construct Attractorkernel: %s\n", e.what()); dealloc(); } diff --git a/AttractorKernel.hpp b/AttractorKernel.hpp index fe48bef..886b231 100644 --- a/AttractorKernel.hpp +++ b/AttractorKernel.hpp @@ -46,5 +46,6 @@ public: }; + #endif // ATTRACTORKERNEL_HPP diff --git a/AwesomeAttractor.cbp b/AwesomeAttractor.cbp index 6e9f950..e38f0a7 100644 --- a/AwesomeAttractor.cbp +++ b/AwesomeAttractor.cbp @@ -7,8 +7,8 @@