Browse Source

applied basicKernel everywhere

master
Joshua 15 years ago
parent
commit
9c88de6cc9
  1. 19
      AwesomeAttractor.cbp
  2. 15
      defines.hpp
  3. 5
      kernels/BasicKernel.cpp
  4. 10
      kernels/BasicKernel.h
  5. 19
      kernels/Logistic.cpp
  6. 24
      kernels/Logistic.hpp
  7. 17
      kernels/Lorenz3D.cpp
  8. 23
      kernels/Lorenz3D.hpp
  9. 20
      kernels/Polynomial.cpp
  10. 26
      kernels/Polynomial.hpp
  11. 16
      kernels/PolynomialA3D.cpp
  12. 26
      kernels/PolynomialA3D.hpp
  13. 16
      kernels/Unravel3D.cpp
  14. 26
      kernels/Unravel3D.hpp
  15. 10
      main.cpp

19
AwesomeAttractor.cbp

@ -12,18 +12,36 @@
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-pg" />
<Add option="-g" />
</Compiler>
<Linker>
<Add option="-pg" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin/Release/AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-fexpensive-optimizations" />
<Add option="-O3" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
<Target title="UniRelease">
<Option output="bin/UniRelease/AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/UniRelease/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-fexpensive-optimizations" />
<Add option="-O3" />
<Add option="-msse4.1" />
<Add option="-DUNI_BUILD" />
</Compiler>
<Linker>
<Add option="-s" />
@ -49,6 +67,7 @@
<Unit filename="attractors/testLorenz.stf" />
<Unit filename="attractors/testPolynomial.stf" />
<Unit filename="attractors/testUnravel.stf" />
<Unit filename="defines.hpp" />
<Unit filename="kernels/BasicKernel.cpp" />
<Unit filename="kernels/BasicKernel.h" />
<Unit filename="kernels/Logistic.cpp" />

15
defines.hpp

@ -0,0 +1,15 @@
//TODO: do this with files
#define ATTRACTOR_FILE "attractors/testPolynomial.stf"
#ifdef UNI_BUILD
#warning Building for the RU, are you sure?
#define WIDTH 8000
#define HEIGHT 8000
#define ITERATIONS 800000000
#else
#define WIDTH 800
#define HEIGHT 800
#define ITERATIONS 200000
#endif

5
kernels/BasicKernel.cpp

@ -1,6 +1,9 @@
#include "BasicKernel.h"
BasicKernel::BasicKernel():
myParameters(NULL), vectorNew(NULL), vectorOld(NULL) {
}
double * & BasicKernel::parameters() {
return myParameters;
}

10
kernels/BasicKernel.h

@ -1,11 +1,15 @@
#ifndef BASICKERNEL_HPP
#define BASICKERNEL_HPP
#include <cassert>
#include <iostream>
#include "../AttractorKernel.hpp"
/*
A basic abstract implementatoin of the AttractorKernel, should
be used to avoid copying the same stuff in all attractorKernels
*/
class BasicKernel : public AttractorKernel {
protected:
@ -16,6 +20,8 @@ class BasicKernel : public AttractorKernel {
public:
BasicKernel();
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
virtual double& parameter(const unsigned int index);
@ -27,5 +33,5 @@ class BasicKernel : public AttractorKernel {
};
#endif // POLYNOMIAL_HPP
#endif

19
kernels/Logistic.cpp

@ -9,14 +9,14 @@
#include "Logistic.hpp"
Logistic::Logistic():
myParameters(NULL), vectorNew(NULL), vectorOld(NULL) {
BasicKernel() {
dimension = 3;
init();
}
Logistic::Logistic(const unsigned int dimension):
myParameters(NULL), vectorNew(NULL), vectorOld(NULL), dimension(dimension) {
BasicKernel(), dimension(dimension) {
init();
}
@ -76,22 +76,7 @@ void Logistic::setProperty(const string identifier, const void * _value) {
}
}
double * & Logistic::parameters() {
return myParameters;
}
double & Logistic::parameter(const unsigned int index) {
return myParameters[index];
}
unsigned int Logistic::getNumberOfParameters() {
return dimension;
}
double * & Logistic::vector() {
return vectorNew;
}
double * & Logistic::previousVector() {
return vectorOld;
}

24
kernels/Logistic.hpp

@ -4,12 +4,9 @@
#include <cassert>
#include "../AttractorKernel.hpp"
#include "BasicKernel.h"
class Logistic : public AttractorKernel {
double * myParameters;
double * vectorNew;
double * vectorOld;
class Logistic : public BasicKernel {
unsigned int dimension;
@ -20,26 +17,13 @@ class Logistic : public AttractorKernel {
Logistic();
Logistic(const unsigned int dimension);
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
virtual double& parameter(const unsigned int index);
virtual double*& parameters();
virtual unsigned int getNumberOfParameters();
virtual void iterate();
// get properties of the attractor
// such as the dimension
// you should delete the void pointer if you used it
virtual void * getProperty(const string identifier);
virtual void setProperty(const string identifier, const void * value);
virtual unsigned int getNumberOfParameters();
// iterate his formula
// vector pointers will be swapped! so new remains new and old remains old
virtual void iterate();
// getter functions for teh resulta
virtual double * & vector();
virtual double * & previousVector();
};
#endif // LOGISTIC_HPP

17
kernels/Lorenz3D.cpp

@ -57,24 +57,7 @@ void Lorenz3D::setProperty(const string identifier, const void * value) {
return;
}
//double * & Lorenz3D::parameters() {
// return myParameters;
//}
//
//double & Lorenz3D::parameter(const unsigned int index) {
// return myParameters[index];
//}
unsigned int Lorenz3D::getNumberOfParameters() {
return numberOfParameters;
}
//double * & Lorenz3D::vector() {
// return vectorNew;
//}
//
//double * & Lorenz3D::previousVector() {
// return vectorOld;
//}

23
kernels/Lorenz3D.hpp

@ -12,11 +12,6 @@ using namespace std;
class Lorenz3D : public BasicKernel {
// double * myParameters;
//
// double * vectorNew;
// double * vectorOld;
void init();
public:
@ -24,26 +19,12 @@ class Lorenz3D : public BasicKernel {
Lorenz3D();
Lorenz3D(const unsigned int dimensions);
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
// virtual double& parameter(const unsigned int index);
// virtual double*& parameters();
virtual unsigned int getNumberOfParameters();
virtual void iterate();
// get properties of the attractor
// such as the dimension
// you should delete the void pointer if you used it
virtual void * getProperty(const string identifier);
virtual void setProperty(const string identifier, const void * value);
// iterate his formula
// vector pointers will be swapped! so new remains new and old remains old
virtual void iterate();
// getter functions for teh resulta
// virtual double * & vector();
// virtual double * & previousVector();
virtual unsigned int getNumberOfParameters();
};

20
kernels/Polynomial.cpp

@ -11,7 +11,7 @@
using namespace std;
Polynomial::Polynomial():
myParameters(NULL), vectorNew(NULL), vectorOld(NULL) {
BasicKernel() {
dimension = 3;
orde = 2;
@ -19,7 +19,7 @@ Polynomial::Polynomial():
}
Polynomial::Polynomial(const unsigned int dimension, const unsigned int orde):
myParameters(NULL), vectorNew(NULL), vectorOld(NULL), dimension(dimension), orde(orde) {
BasicKernel(), dimension(dimension), orde(orde) {
init();
}
@ -124,22 +124,6 @@ void Polynomial::setProperty(const string identifier, const void * _value) {
}
}
double * & Polynomial::parameters() {
return myParameters;
}
double & Polynomial::parameter(const unsigned int index) {
return myParameters[index];
}
unsigned int Polynomial::getNumberOfParameters() {
return numberOfParameters;
}
double * & Polynomial::vector() {
return vectorNew;
}
double * & Polynomial::previousVector() {
return vectorOld;
}

26
kernels/Polynomial.hpp

@ -5,13 +5,9 @@
#include <iostream>
#include "../AttractorKernel.hpp"
#include "BasicKernel.h"
class Polynomial : public AttractorKernel {
double * myParameters;
double * vectorNew;
double * vectorOld;
class Polynomial : public BasicKernel {
unsigned int dimension;
unsigned int orde;
@ -26,26 +22,12 @@ class Polynomial : public AttractorKernel {
Polynomial();
Polynomial(const unsigned int dimensions, const unsigned int orde);
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
virtual double& parameter(const unsigned int index);
virtual double*& parameters();
virtual unsigned int getNumberOfParameters();
virtual void iterate();
// get properties of the attractor
// such as the dimension
// you should delete the void pointer if you used it
virtual void * getProperty(const string identifier);
virtual void setProperty(const string identifier, const void * value);
// iterate his formula
// vector pointers will be swapped! so new remains new and old remains old
virtual void iterate();
// getter functions for teh resulta
virtual double * & vector();
virtual double * & previousVector();
virtual unsigned int getNumberOfParameters();
};

16
kernels/PolynomialA3D.cpp

@ -60,22 +60,6 @@ void PolynomialA3D::setProperty(const string identifier, const void * _value) {
}
double * & PolynomialA3D::parameters() {
return myParameters;
}
double & PolynomialA3D::parameter(const unsigned int index) {
return myParameters[index];
}
unsigned int PolynomialA3D::getNumberOfParameters() {
return numberOfParameters;
}
double * & PolynomialA3D::vector() {
return vectorNew;
}
double * & PolynomialA3D::previousVector() {
return vectorOld;
}

26
kernels/PolynomialA3D.hpp

@ -4,41 +4,23 @@
#include <cassert>
#include "../AttractorKernel.hpp"
#include "BasicKernel.h"
class PolynomialA3D : public AttractorKernel {
class PolynomialA3D : public BasicKernel {
// of course this can be seen as a subclasse of Polynomial
double * myParameters;
double * vectorNew;
double * vectorOld;
void init();
public:
PolynomialA3D();
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
virtual double& parameter(const unsigned int index);
virtual double*& parameters();
virtual unsigned int getNumberOfParameters();
virtual void iterate();
// get properties of the attractor
// such as the dimension
// you should delete the void pointer if you used it
virtual void * getProperty(const string identifier);
virtual void setProperty(const string identifier, const void * value);
// iterate his formula
// vector pointers will be swapped! so new remains new and old remains old
virtual void iterate();
// getter functions for teh resulta
virtual double * & vector();
virtual double * & previousVector();
virtual unsigned int getNumberOfParameters();
};

16
kernels/Unravel3D.cpp

@ -57,22 +57,6 @@ void Unravel3D::setProperty(const string identifier, const void * value) {
return;
}
double * & Unravel3D::parameters() {
return myParameters;
}
double & Unravel3D::parameter(const unsigned int index) {
return myParameters[index];
}
unsigned int Unravel3D::getNumberOfParameters() {
return numberOfParameters;
}
double * & Unravel3D::vector() {
return vectorNew;
}
double * & Unravel3D::previousVector() {
return vectorOld;
}

26
kernels/Unravel3D.hpp

@ -9,13 +9,9 @@
using namespace std;
#include "../AttractorKernel.hpp"
#include "BasicKernel.h"
class Unravel3D : public AttractorKernel {
double * myParameters;
double * vectorNew;
double * vectorOld;
class Unravel3D : public BasicKernel {
void init();
@ -24,26 +20,12 @@ class Unravel3D : public AttractorKernel {
Unravel3D();
Unravel3D(const unsigned int dimensions);
// parameters are stored in a array of doubles
// if you want to use other types, use the properties
virtual double& parameter(const unsigned int index);
virtual double*& parameters();
virtual unsigned int getNumberOfParameters();
virtual void iterate();
// get properties of the attractor
// such as the dimension
// you should delete the void pointer if you used it
virtual void * getProperty(const string identifier);
virtual void setProperty(const string identifier, const void * value);
// iterate his formula
// vector pointers will be swapped! so new remains new and old remains old
virtual void iterate();
// getter functions for teh resulta
virtual double * & vector();
virtual double * & previousVector();
virtual unsigned int getNumberOfParameters();
};

10
main.cpp

@ -6,15 +6,17 @@ using namespace std;
#include "Canvas.hpp"
#include "Projector.hpp"
#include "defines.hpp"
int main(int argc, char *argv[]) {
clock_t start, end;
double totalTime, totalIterations;
// initialising stuff
Attractor myAttractor("attractors/testPolynomial.stf");
Attractor myAttractor(ATTRACTOR_FILE);
Projector projection;
Canvas canvas(8000, 8000, 3);
Canvas canvas(WIDTH, HEIGHT, 3);
projection.canvas = &canvas;
myAttractor.projectors.push_back(&projection);
@ -22,8 +24,7 @@ int main(int argc, char *argv[]) {
projection.output();
// iterating 4 evah
unsigned int iterations = 800000000; // acht honderd miljoen
unsigned int iterations = ITERATIONS;
start = clock();
for ( unsigned int j = 1; j <= 100; j++ ) {
for ( unsigned int i = 0; i <= iterations; i++ ) {
@ -49,6 +50,7 @@ int main(int argc, char *argv[]) {
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));
printf("total clock time for writing png: %f\n", totalTime );
printf("\n Awesome Attractor, version %s\n", __DATE__);
/*if ( argc <= 2 ) {
cout << endl << "nothing to do..." << endl;