Browse Source

better randomness

master
Joshua Moerman 14 years ago
parent
commit
ff02e8c0d7
  1. 14
      Attractor.cpp
  2. 4
      AttractorKernel.hpp
  3. 8
      kernels/Lorenz3D.hpp

14
Attractor.cpp

@ -24,25 +24,25 @@ Attractor::Attractor(const std::string& filename) : kernel(0), projector(0) {
Attractor::Attractor(){
stfu::node kernel_node;
switch(rand()%5){
switch(rand()%3){
case 0:
kernel_node.value("type") = "lorenz";
kernel_node.value("dimensions") = "3";
break;
case 1:
/*case 1:
kernel_node.value("type") = "polynomial";
kernel_node.value("dimensions") = std::string() + (char)(rand()%3 + '2');
kernel_node.value("orde") = std::string() + (char)(rand()%5 + '1');
break;
case 2:
break;*/
case 1:
kernel_node.value("type") = "polynomial a";
kernel_node.value("dimensions") = "3";
break;
case 3:
/*case 3:
kernel_node.value("type") = "logistic";
kernel_node.value("dimensions") = std::string() + (char)(rand()%3 + '2');
break;
case 4:
break;*/
case 2:
kernel_node.value("type") = "unravel";
kernel_node.value("dimensions") = "3";
break;

4
AttractorKernel.hpp

@ -69,9 +69,9 @@ public:
virtual void generate_random_parameters() {
for(unsigned int i = 0; i < numberOfParameters; ++i)
parameters[i] = 2.0 * rand() / double(RAND_MAX) - 1.0;
parameters[i] = 6.0 * rand() / double(RAND_MAX) - 3.0;
for(unsigned int i = 0; i < dimension; ++i)
vectorNew[i] = vectorOld[i] = 6.0 * rand() / double(RAND_MAX) - 3.0;
vectorNew[i] = vectorOld[i] = 2.0 * rand() / double(RAND_MAX) - 1.0;
}
#pragma mark -

8
kernels/Lorenz3D.hpp

@ -17,10 +17,10 @@ public:
}
virtual void generate_random_parameters() {
parameters[0] = rand() / double(RAND_MAX) * 0.01;
parameters[1] = rand() / double(RAND_MAX) * 10.0 + 23.0;
parameters[2] = rand() / double(RAND_MAX) * 4.0 + 8.0;
parameters[3] = rand() / double(RAND_MAX) * 1.5 + 2.0;
parameters[0] = rand() / double(RAND_MAX) * 0.02;
parameters[1] = rand() / double(RAND_MAX) * 4.0 + 8.0;
parameters[2] = rand() / double(RAND_MAX) * 10.0 + 23.0;
parameters[3] = rand() / double(RAND_MAX) * 4.0;
init();
}