From 3ffe76cf2c5e87769efeabe4d5d29102b4f5381c Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 2 Apr 2010 17:18:05 +0200 Subject: [PATCH] tested stuff --- attractors/testAttractor.stf | 38 ++++++++++++++++++++++++++++++++++++ kernels/Logistic.cpp | 5 +++-- kernels/Polynomial.cpp | 12 ++++++++---- kernels/Polynomial.hpp | 1 + main.cpp | 32 +----------------------------- 5 files changed, 51 insertions(+), 37 deletions(-) create mode 100644 attractors/testAttractor.stf diff --git a/attractors/testAttractor.stf b/attractors/testAttractor.stf new file mode 100644 index 0000000..12a4673 --- /dev/null +++ b/attractors/testAttractor.stf @@ -0,0 +1,38 @@ + +input: "attractor" +output: "png" + +attractor: { + type: "polynomial" + dimensions: "3" + orde: "2" + + iterations: "1000000" + + parameters: { + :"1.0" + :"0.0" + :"2.0" + :"0.0" + } +} + +projector: { + type: "lineair map" + + domainDimension: "3" + codomainDimensions: "2" + + matrix : { + :{ :"1" :"0" :".2" } + :{ :"0" :"1" :".2" } + } +} + +png: { + width: "3200" + height: "3200" + +} + +/media/Data/Code/C/AwesomeAttractor/Attractor.cpp|80|error: cannot convert ‘std::basic_string, std::allocator >’ to ‘const char*’ for argument ‘1’ to ‘double atof(const char*)’| diff --git a/kernels/Logistic.cpp b/kernels/Logistic.cpp index 379561d..0623982 100644 --- a/kernels/Logistic.cpp +++ b/kernels/Logistic.cpp @@ -8,14 +8,15 @@ #include "Logistic.hpp" -Logistic::Logistic() { +Logistic::Logistic(): + myParameters(NULL), vectorNew(NULL), vectorOld(NULL) { dimension = 3; init(); } Logistic::Logistic(const unsigned int dimension): - dimension(dimension) { + myParameters(NULL), vectorNew(NULL), vectorOld(NULL), dimension(dimension) { init(); } diff --git a/kernels/Polynomial.cpp b/kernels/Polynomial.cpp index 35ca8d6..8faab07 100644 --- a/kernels/Polynomial.cpp +++ b/kernels/Polynomial.cpp @@ -8,7 +8,10 @@ #include "Polynomial.hpp" -Polynomial::Polynomial() { +using namespace std; + +Polynomial::Polynomial(): + myParameters(NULL), vectorNew(NULL), vectorOld(NULL) { dimension = 3; orde = 2; @@ -16,11 +19,11 @@ Polynomial::Polynomial() { } Polynomial::Polynomial(const unsigned int dimension, const unsigned int orde): - dimension(dimension), orde(orde) { + myParameters(NULL), vectorNew(NULL), vectorOld(NULL), dimension(dimension), orde(orde) { init(); } -void Polynomial::init(){ +void Polynomial::init() { calculateNumberOfParameters(); if ( myParameters != NULL ) { delete myParameters; @@ -48,13 +51,14 @@ void Polynomial::init(){ } } -void Polynomial::calculateNumberOfParameters(){ +void Polynomial::calculateNumberOfParameters() { double n_coef = orde + 1; for (unsigned int i = 2; i <= dimension; i++) { n_coef = n_coef*(orde + i)/(i - 1); } numberOfParameters = (unsigned int) n_coef; + cout << numberOfParameters << endl; } void Polynomial::iterate() { diff --git a/kernels/Polynomial.hpp b/kernels/Polynomial.hpp index 7ec2196..4325d63 100644 --- a/kernels/Polynomial.hpp +++ b/kernels/Polynomial.hpp @@ -2,6 +2,7 @@ #define POLYNOMIAL_HPP #include +#include #include "../AttractorKernel.hpp" diff --git a/main.cpp b/main.cpp index 5f16345..0c44d44 100644 --- a/main.cpp +++ b/main.cpp @@ -5,40 +5,10 @@ using namespace std; #include "Canvas.hpp" #include "Projector.hpp" -#include "AttractorKernel.hpp" -#include "kernels/Lorenz3D.hpp" - -// TODO : Allemaal files inlezen, voor makkelijker gebruik - int main(int argc, char *argv[]) { -/* - AttractorKernel * mijnAttractortje; - mijnAttractortje = new Lorenz3D(); - AttractorKernel &attractor = *mijnAttractortje; - - attractor.parameter(0) = 1.0; - attractor.parameter(2) = 2.0; - - double * & vector = attractor.vector(); - - unsigned int * _dimension = (unsigned int*)mijnAttractortje->getProperty("dimension"); - unsigned int dimension = *_dimension; - delete _dimension; - - cout << "Dimension = " << dimension << endl; - - for ( unsigned int i = 0; i < 20; i++ ) { - mijnAttractortje->iterate(); - cout << "vector = "; - for ( unsigned int i = 0; i < dimension; i++ ) { - cout << " " << vector[i]; - } - cout << endl; - } -*/ Attractor myAttractor("attractors/testAttractor.stf"); - for ( unsigned int i = 0; i < 20; i++ ) { + for ( unsigned int i = 0; i < 50; i++ ) { myAttractor.iterate(); myAttractor.output(); }