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.
73 lines
1.8 KiB
73 lines
1.8 KiB
#include "Lorenz.hpp"
|
|
|
|
Lorenz::Lorenz() {
|
|
init();
|
|
}
|
|
|
|
void Lorenz::init() {
|
|
// allocation
|
|
myParameters = new double[4];
|
|
vectorNew = new double[3];
|
|
vectorOld = new double[3];
|
|
|
|
// initialisation
|
|
assert(myParameters != NULL);
|
|
assert(vectorNew != NULL);
|
|
assert(vectorOld != NULL);
|
|
for ( unsigned int i = 0; i < 4; i++ ) {
|
|
myParameters[i] = 0.0;
|
|
}
|
|
for ( unsigned int i = 0; i < 3; i++ ) {
|
|
vectorNew[i] = vectorOld[i] = 1.0;
|
|
}
|
|
}
|
|
|
|
// the main function
|
|
void Lorenz::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 * Lorenz::getProperty(const string identifier) {
|
|
if ( identifier == "dimension" ) {
|
|
unsigned int * _return = new unsigned int;
|
|
*_return = 3;
|
|
return _return;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void Lorenz::setProperty(const string identifier, const void * value) {
|
|
return;
|
|
}
|
|
|
|
double * & Lorenz::parameters() {
|
|
return myParameters;
|
|
}
|
|
|
|
double & Lorenz::parameter(const unsigned int index) {
|
|
return myParameters[index];
|
|
}
|
|
|
|
double * & Lorenz::vector() {
|
|
return vectorNew;
|
|
}
|
|
|
|
double * & Lorenz::previousVector() {
|
|
return vectorOld;
|
|
}
|
|
|
|
|
|
|