My old project for strange attractors
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 

81 lines
1.7 KiB

#ifndef ATTRACTOR_HPP
#define ATTRACTOR_HPP
#include "Logger.hpp"
#include <iostream>
#include <fstream>
#include <string>
#include "AttractorKernel.hpp"
#include "Projector.hpp"
class Attractor {
public:
// should be private really
Projector* projector;
Attractor(const std::string& filename) {
LogInfo("Reading file '%s'...\n", filename.c_str());
stfu::node system;
if(!system.read(filename.c_str())){
std::cerr << "Couldn't open file(" << filename << ") for reading\n";
exit(-1);
}
kernel = AttractorKernel::createAttractorKernel(system.getChild("AttractorKernel"));
projector = Projector::createProjector(system.getChild(system.getValue("Projector")), kernel->getDimension());
}
Attractor();
~Attractor() {
delete kernel;
}
void init_range() {
for(unsigned int i = 0; i < 1000000; i++) {
iterate();
if(kernel->convergent() || kernel->divergent()){
kernel->generate_random_parameters();
LogDebug("Generating new parameters.\n");
i = 0;
}
}
}
void iterate() {
(*kernel)();
}
void plot() {
projector->plot(kernel->vector());
}
void output() {
const unsigned int dimension = kernel->getDimension();
const double* point = kernel->vector();
for(unsigned int i = 0; i < dimension; i++) {
LogMoreInfo("%f, ", point[i]);
}
LogMoreInfo("\n");
}
stfu::node stf_output(){
stfu::node kernel_node = kernel-> stf_output();
stfu::node projector_node;/* = projector->stf_output();*/
stfu::node system;
system.addChild("AttractorKernel", kernel_node);
system.addChild("Projector", projector_node);
return system;
}
friend std::ostream& operator<<(std::ostream& os, Attractor const& x);
private:
AttractorKernel* kernel;
};
#endif // ATTRACTOR_HPP