basic kernel added, for more code reuse
This commit is contained in:
parent
f77daec80f
commit
1334e7e547
8 changed files with 86 additions and 31 deletions
|
@ -21,7 +21,9 @@
|
|||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
<Add option="-fexpensive-optimizations" />
|
||||
<Add option="-O3" />
|
||||
<Add option="-msse4.1" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -47,6 +49,8 @@
|
|||
<Unit filename="attractors/testLorenz.stf" />
|
||||
<Unit filename="attractors/testPolynomial.stf" />
|
||||
<Unit filename="attractors/testUnravel.stf" />
|
||||
<Unit filename="kernels/BasicKernel.cpp" />
|
||||
<Unit filename="kernels/BasicKernel.h" />
|
||||
<Unit filename="kernels/Logistic.cpp" />
|
||||
<Unit filename="kernels/Logistic.hpp" />
|
||||
<Unit filename="kernels/Lorenz3D.cpp" />
|
||||
|
|
|
@ -118,7 +118,7 @@ void Canvas::output_file(const char * filename){
|
|||
if ( max_int[i] < int_array[j+i*width*height] ) {
|
||||
max_int[i] = int_array[j+i*width*height];
|
||||
}
|
||||
if ( int_array[j+i*width*height] > 5 ) {
|
||||
if ( int_array[j+i*width*height] ) {
|
||||
cumulative += int_array[j+i*width*height];
|
||||
n++;
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ void Canvas::output_file(const char * filename){
|
|||
const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c];
|
||||
switch(c){
|
||||
case 0: {
|
||||
r = (pow(norm_value, power[c]))*3.0;
|
||||
r = (pow(norm_value, power[c]))*3.5;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
|
|
|
@ -93,10 +93,10 @@ void Projector::plot(const double * point) {
|
|||
|
||||
//cout << x << ", " << y << endl;
|
||||
|
||||
canvas->plot(x, y);
|
||||
if ( even(point[2]*4.0) )
|
||||
canvas->plot(x+0.01*rand()/(double)RAND_MAX-0.005, y+0.01*rand()/(double)RAND_MAX-0.005);
|
||||
if ( even(point[2]*17) )
|
||||
canvas->plot(x, y, 1);
|
||||
else
|
||||
if ( even(point[2]*17+0.6) )
|
||||
canvas->plot(x, y, 2);
|
||||
}
|
||||
|
||||
|
|
19
kernels/BasicKernel.cpp
Normal file
19
kernels/BasicKernel.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include "BasicKernel.h"
|
||||
|
||||
double * & BasicKernel::parameters() {
|
||||
return myParameters;
|
||||
}
|
||||
|
||||
double & BasicKernel::parameter(const unsigned int index) {
|
||||
return myParameters[index];
|
||||
}
|
||||
|
||||
double * & BasicKernel::vector() {
|
||||
return vectorNew;
|
||||
}
|
||||
|
||||
double * & BasicKernel::previousVector() {
|
||||
return vectorOld;
|
||||
}
|
||||
|
31
kernels/BasicKernel.h
Normal file
31
kernels/BasicKernel.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef BASICKERNEL_HPP
|
||||
#define BASICKERNEL_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include "../AttractorKernel.hpp"
|
||||
|
||||
class BasicKernel : public AttractorKernel {
|
||||
protected:
|
||||
|
||||
double * myParameters;
|
||||
|
||||
double * vectorNew;
|
||||
double * vectorOld;
|
||||
|
||||
public:
|
||||
|
||||
// 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();
|
||||
|
||||
// getter functions for teh resulta
|
||||
virtual double * & vector();
|
||||
virtual double * & previousVector();
|
||||
|
||||
};
|
||||
|
||||
#endif // POLYNOMIAL_HPP
|
||||
|
|
@ -57,24 +57,24 @@ 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];
|
||||
}
|
||||
//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;
|
||||
}
|
||||
//double * & Lorenz3D::vector() {
|
||||
// return vectorNew;
|
||||
//}
|
||||
//
|
||||
//double * & Lorenz3D::previousVector() {
|
||||
// return vectorOld;
|
||||
//}
|
||||
|
||||
|
||||
|
|
|
@ -8,13 +8,14 @@
|
|||
using namespace std;
|
||||
|
||||
#include "../AttractorKernel.hpp"
|
||||
#include "BasicKernel.h"
|
||||
|
||||
class Lorenz3D : public AttractorKernel {
|
||||
class Lorenz3D : public BasicKernel {
|
||||
|
||||
double * myParameters;
|
||||
|
||||
double * vectorNew;
|
||||
double * vectorOld;
|
||||
// double * myParameters;
|
||||
//
|
||||
// double * vectorNew;
|
||||
// double * vectorOld;
|
||||
|
||||
void init();
|
||||
|
||||
|
@ -25,8 +26,8 @@ class Lorenz3D : public AttractorKernel {
|
|||
|
||||
// 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 double& parameter(const unsigned int index);
|
||||
// virtual double*& parameters();
|
||||
|
||||
virtual unsigned int getNumberOfParameters();
|
||||
|
||||
|
@ -41,8 +42,8 @@ class Lorenz3D : public AttractorKernel {
|
|||
virtual void iterate();
|
||||
|
||||
// getter functions for teh resulta
|
||||
virtual double * & vector();
|
||||
virtual double * & previousVector();
|
||||
// virtual double * & vector();
|
||||
// virtual double * & previousVector();
|
||||
|
||||
};
|
||||
|
||||
|
|
4
main.cpp
4
main.cpp
|
@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
|
|||
Attractor myAttractor("attractors/testPolynomial.stf");
|
||||
|
||||
Projector projection;
|
||||
Canvas canvas(800, 800, 3);
|
||||
Canvas canvas(8000, 8000, 3);
|
||||
projection.canvas = &canvas;
|
||||
|
||||
myAttractor.projectors.push_back(&projection);
|
||||
|
@ -23,7 +23,7 @@ int main(int argc, char *argv[]) {
|
|||
projection.output();
|
||||
|
||||
// iterating 4 evah
|
||||
unsigned int iterations = 2000; // tweeduizend
|
||||
unsigned int iterations = 800000000; // acht honderd miljoen
|
||||
start = clock();
|
||||
for ( unsigned int j = 1; j <= 100; j++ ) {
|
||||
for ( unsigned int i = 0; i <= iterations; i++ ) {
|
||||
|
|
Reference in a new issue