Browse Source

tested stuff

master
Joshua 15 years ago
parent
commit
3ffe76cf2c
  1. 38
      attractors/testAttractor.stf
  2. 5
      kernels/Logistic.cpp
  3. 12
      kernels/Polynomial.cpp
  4. 1
      kernels/Polynomial.hpp
  5. 32
      main.cpp

38
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<char, std::char_traits<char>, std::allocator<char> >’ to ‘const char*’ for argument ‘1’ to ‘double atof(const char*)’|

5
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();
}

12
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() {

1
kernels/Polynomial.hpp

@ -2,6 +2,7 @@
#define POLYNOMIAL_HPP
#include <cassert>
#include <iostream>
#include "../AttractorKernel.hpp"

32
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();
}