Browse Source

poly kernels

master
Joshua 15 years ago
parent
commit
03078a61ad
  1. 22
      Attractor.cpp
  2. 2
      AwesomeAttractor.cbp
  3. 8
      kernels/Polynomial.cpp
  4. 19
      kernels/PolynomialA3D.cpp

22
Attractor.cpp

@ -100,10 +100,6 @@ void Attractor::init(unsigned int dim_in, FormulaChoice formula_in, unsigned int
orde = orde_in; orde = orde_in;
switch (formula) { switch (formula) {
case POLY_A: {4
par = dim;
break;
}
case LOGISTIC: { case LOGISTIC: {
par = dim; par = dim;
break; break;
@ -213,10 +209,6 @@ void Attractor::iterate() {
// calculations // calculations
switch (formula) { switch (formula) {
case POLY_A:
poly_A();
break;
case LOGISTIC: case LOGISTIC:
logistic(); logistic();
break; break;
@ -241,20 +233,6 @@ void Attractor::iterate() {
#endif #endif
} }
void Attractor::poly_A() {
switch (dim) {
case 3:
new_point[0] = param[0] + point[1] - point[1]*point[2];
new_point[1] = param[1] + point[2] - point[2]*point[0];
new_point[2] = param[2] + point[0] - point[0]*point[1];
break;
default:
for ( unsigned int i = 0; i < dim; i++ ) {
new_point[i] = param[i] + point[(i+1) % dim] - point[(i+1) % dim]*point[(i+2) % dim];
}
break;
}
}
void Attractor::logistic() { void Attractor::logistic() {
for ( unsigned int i = 0; i < dim; i++ ) { for ( unsigned int i = 0; i < dim; i++ ) {

2
AwesomeAttractor.cbp

@ -50,6 +50,8 @@
<Unit filename="kernels/Lorenz3D.hpp" /> <Unit filename="kernels/Lorenz3D.hpp" />
<Unit filename="kernels/Polynomial.cpp" /> <Unit filename="kernels/Polynomial.cpp" />
<Unit filename="kernels/Polynomial.hpp" /> <Unit filename="kernels/Polynomial.hpp" />
<Unit filename="kernels/PolynomialA3D.cpp" />
<Unit filename="kernels/PolynomialA3D.hpp" />
<Unit filename="kernels/Unravel3D.cpp" /> <Unit filename="kernels/Unravel3D.cpp" />
<Unit filename="kernels/Unravel3D.hpp" /> <Unit filename="kernels/Unravel3D.hpp" />
<Unit filename="main.cpp" /> <Unit filename="main.cpp" />

8
kernels/Polynomial.cpp

@ -57,6 +57,8 @@ void Polynomial::calculateNumberOfParameters(){
} }
void Polynomial::iterate() { void Polynomial::iterate() {
swap(vectorNew, vectorOld);
unsigned int m = 0; unsigned int m = 0;
for ( unsigned int i = 0; i < dim; i++ ) { for ( unsigned int i = 0; i < dim; i++ ) {
@ -64,7 +66,7 @@ void Polynomial::iterate() {
cout << "Entering new dimension: " << i << " With m = " << m << endl; cout << "Entering new dimension: " << i << " With m = " << m << endl;
#endif #endif
new_point[i] = param[m]; vectorNew[i] = myParameters[m];
m++; m++;
recur(i, 0, 1, m); recur(i, 0, 1, m);
} }
@ -81,8 +83,8 @@ void Polynomial::recur(unsigned int curr_dimension, unsigned int prev_i, unsigne
cout << "Calculation in dimension: " << i << " With m = " << m << " And depth = " << n << endl; cout << "Calculation in dimension: " << i << " With m = " << m << " And depth = " << n << endl;
#endif #endif
product = prev_product * point[i]; product = prev_product * vectorOld[i];
new_point[curr_dimension] += param[m] * product; vectorNew[curr_dimension] += myParameters[m] * product;
m++; m++;
if (n < orde) { if (n < orde) {
recur(curr_dimension, i, n+1, m, product); recur(curr_dimension, i, n+1, m, product);

19
kernels/PolynomialA3D.cpp

@ -9,11 +9,11 @@
const static unsigned int dimension = 3; const static unsigned int dimension = 3;
const static unsigned int numberOfParameters = 3; const static unsigned int numberOfParameters = 3;
PolynomialA3D::PolynomialA3D(){ PolynomialA3D::PolynomialA3D() {
init(); init();
} }
void PolynomialA3D::init(){ void PolynomialA3D::init() {
myParameters = new double[numberOfParameters]; myParameters = new double[numberOfParameters];
vectorNew = new double[dimension]; vectorNew = new double[dimension];
vectorOld = new double[dimension]; vectorOld = new double[dimension];
@ -29,6 +29,21 @@ void PolynomialA3D::init(){
} }
} }
void PolynomialA3D::iterate() {
swap(vectorNew, vectorOld);
vectorNew[0] = myParameters[0] + vectorOld[1] - vectorOld[1]*vectorOld[2];
vectorNew[1] = myParameters[1] + vectorOld[2] - vectorOld[2]*vectorOld[0];
vectorNew[2] = myParameters[2] + vectorOld[0] - vectorOld[0]*vectorOld[1];
}
/*
N dimensional:
for ( unsigned int i = 0; i < dim; i++ ) {
new_point[i] = param[i] + point[(i+1) % dim] - point[(i+1) % dim]*point[(i+2) % dim];
}
*/
// setters, getters, all i/o to other classes/objects // setters, getters, all i/o to other classes/objects
void * PolynomialA3D::getProperty(const string identifier) { void * PolynomialA3D::getProperty(const string identifier) {
if ( identifier == "dimension" ) { if ( identifier == "dimension" ) {