randomness almost done?
This commit is contained in:
parent
de5d99a3bf
commit
0ab0acd86b
6 changed files with 44 additions and 13 deletions
|
@ -22,8 +22,36 @@ Attractor::Attractor(const std::string& filename) : kernel(0), projector(0) {
|
|||
}
|
||||
|
||||
Attractor::Attractor(){
|
||||
LogError("Not implemented yet (random attractor)\n");
|
||||
exit(1);
|
||||
stfu::node kernel_node;
|
||||
switch(rand()%5){
|
||||
case 0:
|
||||
kernel_node.value("type") = "lorenz";
|
||||
kernel_node.value("dimensions") = "3";
|
||||
break;
|
||||
case 1:
|
||||
kernel_node.value("type") = "polynomial";
|
||||
kernel_node.value("dimensions") = std::string() + (char)(rand()%3 + '2');
|
||||
break;
|
||||
case 2:
|
||||
kernel_node.value("type") = "polynomial a";
|
||||
kernel_node.value("dimensions") = "3";
|
||||
break;
|
||||
case 3:
|
||||
kernel_node.value("type") = "logistic";
|
||||
kernel_node.value("dimensions") = std::string() + (char)(rand()%3 + '2');
|
||||
break;
|
||||
case 4:
|
||||
kernel_node.value("type") = "unravel";
|
||||
kernel_node.value("dimensions") = "3";
|
||||
break;
|
||||
}
|
||||
|
||||
kernel = AttractorKernel::createAttractorKernel(kernel_node);
|
||||
|
||||
stfu::node projector_node;
|
||||
projector_node.value("dimensions") = "2";
|
||||
|
||||
projector = Projector::createProjector(projector_node, projector_node);
|
||||
}
|
||||
|
||||
Attractor::~Attractor() {
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
<Add option="-Wall" />
|
||||
<Add option="-Wno-unknown-pragmas" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add library="png" />
|
||||
</Linker>
|
||||
<Unit filename="Attractor.cpp" />
|
||||
<Unit filename="Attractor.hpp" />
|
||||
<Unit filename="AttractorKernel.cpp" />
|
||||
|
@ -67,9 +70,7 @@
|
|||
<Unit filename="attractors/testLorenz.stf" />
|
||||
<Unit filename="attractors/testPolynomial.stf" />
|
||||
<Unit filename="attractors/testUnravel.stf" />
|
||||
<Unit filename="canvae/PNG.cpp">
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
<Unit filename="canvae/PNG.cpp" />
|
||||
<Unit filename="canvae/PNG.hpp">
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
|
@ -89,9 +90,7 @@
|
|||
<Unit filename="main.cpp" />
|
||||
<Unit filename="myMath.hpp" />
|
||||
<Unit filename="ostream_helpers.h" />
|
||||
<Unit filename="pngwriter/pngwriter.cc">
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
<Unit filename="pngwriter/pngwriter.cc" />
|
||||
<Unit filename="pngwriter/pngwriter.h">
|
||||
<Option target="<{~None~}>" />
|
||||
</Unit>
|
||||
|
|
|
@ -15,7 +15,7 @@ extern int verbose;
|
|||
if ( verbose >= 1 ) printf(s, ##__VA_ARGS__);
|
||||
|
||||
#define LogError(s, ...) \
|
||||
if ( verbose >= 0 ) { printf("%s, %d: ", __FILE__, __LINE__); printf(s, ##__VA_ARGS__); }
|
||||
if ( verbose >= 0 ) { printf("%s, %s(), %d: ", __FILE__, __func__, __LINE__); printf(s, ##__VA_ARGS__); }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -53,8 +53,11 @@ void Projector::plot(const double* point) {
|
|||
|
||||
#include "projectors/Normalizer.hpp"
|
||||
|
||||
Projector* Projector::createProjector(stfu::node const& projector, stfu::node const& system) {
|
||||
Projector* output = new Normalizer(3);
|
||||
Projector* Projector::createProjector(stfu::node& projector, stfu::node& system) {
|
||||
const std::string attractorDimension = projector.getValue("dimensions");
|
||||
const unsigned int dimension = atoi(attractorDimension.c_str());
|
||||
|
||||
Projector* output = new Normalizer(dimension);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
void plot(const double* point);
|
||||
|
||||
// factory function
|
||||
static Projector* createProjector(stfu::node const& projector, stfu::node const& system);
|
||||
static Projector* createProjector(stfu::node& projector, stfu::node& system);
|
||||
};
|
||||
|
||||
#endif // PROJECTOR_HPP
|
||||
|
|
3
main.cpp
3
main.cpp
|
@ -1,8 +1,8 @@
|
|||
#include "Logger.hpp"
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <valarray>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "Attractor.hpp"
|
||||
#include "Canvas.hpp"
|
||||
|
@ -40,6 +40,7 @@ int main(int argc, char* argv[]) {
|
|||
unsigned int iterations = DEFAULT_ITERATIONS;
|
||||
unsigned int width = DEFAULT_WIDTH;
|
||||
unsigned int height = DEFAULT_HEIGHT;
|
||||
srand(time(0));
|
||||
|
||||
if(argc <= 1) {
|
||||
showHelpText();
|
||||
|
|
Reference in a new issue