You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.1 KiB
80 lines
2.1 KiB
#include "Lorenz3D.hpp"
|
|
|
|
const static unsigned int dimension = 3;
|
|
const static unsigned int numberOfParameters = 4;
|
|
|
|
Lorenz3D::Lorenz3D() {
|
|
init();
|
|
}
|
|
|
|
void Lorenz3D::init() {
|
|
// allocation
|
|
myParameters = new double[numberOfParameters];
|
|
vectorNew = new double[dimension];
|
|
vectorOld = new double[dimension];
|
|
|
|
// initialisation
|
|
assert(myParameters != NULL);
|
|
assert(vectorNew != NULL);
|
|
assert(vectorOld != NULL);
|
|
for ( unsigned int i = 0; i < numberOfParameters; i++ ) {
|
|
myParameters[i] = 0.0;
|
|
}
|
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
|
vectorNew[i] = vectorOld[i] = 1.0;
|
|
}
|
|
}
|
|
|
|
// the main function
|
|
void Lorenz3D::iterate() {
|
|
swap(vectorNew, vectorOld);
|
|
|
|
vectorNew[0] = vectorOld[0] + myParameters[0] * myParameters[1] * (vectorOld[1] - vectorOld[0]);
|
|
vectorNew[1] = vectorOld[1] + myParameters[0] * (vectorOld[0] * (myParameters[2] - vectorOld[2]) - vectorOld[1]);
|
|
vectorNew[2] = vectorOld[2] + myParameters[0] * (vectorOld[0] * vectorOld[1] - myParameters[3] * vectorOld[2]);
|
|
}
|
|
|
|
/*
|
|
4D:
|
|
new_point[0] = point[0] + param[0] * param[1] * (point[1] - point[0]);
|
|
new_point[1] = point[1] + param[0] * (point[0] * (param[2] - point[2]) - point[1] + point[3]);
|
|
new_point[2] = point[2] + param[0] * (point[0] * point[1] - param[3] * point[2]);
|
|
new_point[3] = point[3] - param[0] * param[4] * point[0];
|
|
break;
|
|
*/
|
|
|
|
// setters, getters, all i/o to other classes/objects
|
|
void * Lorenz3D::getProperty(const string identifier) {
|
|
if ( identifier == "dimension" ) {
|
|
unsigned int * _return = new unsigned int;
|
|
*_return = dimension;
|
|
return _return;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
|