...
 
Commits (6)
...@@ -16,7 +16,7 @@ float compute(float alpha, float beta, aligned_vector<float> seed_x, ...@@ -16,7 +16,7 @@ float compute(float alpha, float beta, aligned_vector<float> seed_x,
float d = 0.0; float d = 0.0;
for (int i = 0; i < num_iterations && d < threshold; i++) { for (int i = 0; i < num_iterations && d <= threshold; i++) {
#pragma omp simd aligned(xp, yp : 64) #pragma omp simd aligned(xp, yp : 64)
for (int s = 0; s < num_seeds; s++) { for (int s = 0; s < num_seeds; s++) {
yp[s] = yp[s] + beta * std::sin(TWO_PI * xp[s]); yp[s] = yp[s] + beta * std::sin(TWO_PI * xp[s]);
...@@ -75,12 +75,12 @@ void compute_all( ...@@ -75,12 +75,12 @@ void compute_all(
aligned_vector<float> y_start(num_seedpoints); aligned_vector<float> y_start(num_seedpoints);
for (int i = 1; i < num_seedpoints - seedpoints.size() + 1; ++i) { for (int i = 1; i < num_seedpoints - seedpoints.size() + 1; ++i) {
x_start[i - 1] = 0.5f * static_cast<float>(i) / (num_seedpoints - seedpoints.size() + 1); x_start[i - 1] = 0.5f * static_cast<float>(i) / (num_seedpoints - seedpoints.size() + 1);
y_start[i - 1] = 0; // y_start[i - 1] = 0;
std::cout << x_start[i - 1] << ", "; std::cout << x_start[i - 1] << ", ";
} }
for (int i = 0; i < seedpoints.size(); ++i) { for (int i = 0; i < seedpoints.size(); ++i) {
x_start[num_seedpoints - seedpoints.size() + i] = seedpoints[i]; x_start[num_seedpoints - seedpoints.size() + i] = seedpoints[i];
y_start[num_seedpoints - seedpoints.size() + i] = 0; // y_start[num_seedpoints - seedpoints.size() + i] = 0;
std::cout << x_start[num_seedpoints - seedpoints.size() + i] << ", "; std::cout << x_start[num_seedpoints - seedpoints.size() + i] << ", ";
} }
std::cout << '\n'; std::cout << '\n';
......
...@@ -13,18 +13,6 @@ ...@@ -13,18 +13,6 @@
#include "compute.hpp" #include "compute.hpp"
class ScrollBox : public Fl_Box {
Fl_Scroll *scroll;
public:
void SetScroll(Fl_Scroll *val) {
scroll = val;
}
ScrollBox(int x,int y,int w,int h,const char*l=0) : Fl_Box(x,y,w,h,l) {
color(FL_BLUE);
box(FL_FLAT_BOX);
}
};
class SimpleWindow : public Fl_Window { class SimpleWindow : public Fl_Window {
public: public:
...@@ -32,7 +20,9 @@ class SimpleWindow : public Fl_Window { ...@@ -32,7 +20,9 @@ class SimpleWindow : public Fl_Window {
~SimpleWindow(); ~SimpleWindow();
Fl_Scroll* scroll; Fl_Scroll* scroll;
ScrollBox* scrollbox; Fl_Box* imagebox;
Fl_Group* group;
Fl_PNG_Image* image; Fl_PNG_Image* image;
...@@ -47,6 +37,7 @@ class SimpleWindow : public Fl_Window { ...@@ -47,6 +37,7 @@ class SimpleWindow : public Fl_Window {
Fl_Value_Input* in_betamax; Fl_Value_Input* in_betamax;
Fl_Value_Input* in_beta_num_intervals; Fl_Value_Input* in_beta_num_intervals;
Fl_Value_Input* in_num_seedpoints; Fl_Value_Input* in_num_seedpoints;
Fl_Value_Input* in_special_seedpoint;
Fl_Check_Button* in_output_csv; Fl_Check_Button* in_output_csv;
private: private:
...@@ -56,7 +47,7 @@ class SimpleWindow : public Fl_Window { ...@@ -56,7 +47,7 @@ class SimpleWindow : public Fl_Window {
}; };
int main() { int main() {
SimpleWindow win(800,600,"Dynamic Systems"); SimpleWindow win(600,500,"Dynamic Systems");
return Fl::run(); return Fl::run();
} }
...@@ -65,25 +56,28 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title) ...@@ -65,25 +56,28 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title)
// between begin...end comes what to show in window // between begin...end comes what to show in window
this->begin(); // this-> is implicit this->begin(); // this-> is implicit
// Top: ScrollBox containing the picture // Top: scrolling box containing the picture
image = new Fl_PNG_Image("picture.png"); image = new Fl_PNG_Image("picture.png");
scroll = new Fl_Scroll(0,0,800,400); int scrollheight = 400;
scroll->begin(); int scrollwidth = 600;
scrollbox = new ScrollBox(0,0,800,400); scroll = new Fl_Scroll(0,0,600,400);
scrollbox->SetScroll(scroll);
scrollbox->image(image);
scroll->begin();
imagebox = new Fl_Box(0,0,image->w(),image->h());
imagebox->image(image);
scroll->end(); scroll->end();
// Bottom: inputboxes and button // Bottom: inputboxes and button
int boxwidth = 80; // width input boxes int boxwidth = 80; // width input boxes
int boxheight = 20; // height input boxes int boxheight = 20; // height input boxes
int firstrow = 450; int firstrow = scrollheight+1*boxheight;
int secondrow = 550; int secondrow = firstrow+2*boxheight;
int padding = 100; int padding = 100;
group = new Fl_Group(0,scrollheight,6*padding,100);
group->begin();
in_alphamin = new Fl_Value_Input(0*padding,firstrow,boxwidth,boxheight,"alpha_min"); in_alphamin = new Fl_Value_Input(0*padding,firstrow,boxwidth,boxheight,"alpha_min");
in_alphamin->align(FL_ALIGN_TOP); in_alphamin->align(FL_ALIGN_TOP);
in_alphamin->value(0.0); in_alphamin->value(0.0);
...@@ -95,6 +89,21 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title) ...@@ -95,6 +89,21 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title)
in_alpha_num_intervals = new Fl_Value_Input(2*padding,firstrow,boxwidth,boxheight,"width"); in_alpha_num_intervals = new Fl_Value_Input(2*padding,firstrow,boxwidth,boxheight,"width");
in_alpha_num_intervals->align(FL_ALIGN_TOP); in_alpha_num_intervals->align(FL_ALIGN_TOP);
in_alpha_num_intervals->value(400); in_alpha_num_intervals->value(400);
in_alpha_num_intervals->step(1);
in_num_iterations = new Fl_Value_Input(3*padding,firstrow,boxwidth,boxheight,"iterations");
in_num_iterations->align(FL_ALIGN_TOP);
in_num_iterations->value(100);
in_num_iterations->step(1);
in_threshold = new Fl_Value_Input(4*padding,firstrow,boxwidth,boxheight,"threshold");
in_threshold->align(FL_ALIGN_TOP);
in_threshold->value(1);
button_compute = new Fl_Button(5*padding,firstrow,boxwidth,boxheight,"compute");
button_compute->type(FL_NORMAL_BUTTON);
button_compute->color(FL_RED);
button_compute->callback(callback_compute,this);
in_betamin = new Fl_Value_Input(0*padding,secondrow,boxwidth,boxheight,"beta_min"); in_betamin = new Fl_Value_Input(0*padding,secondrow,boxwidth,boxheight,"beta_min");
in_betamin->align(FL_ALIGN_TOP); in_betamin->align(FL_ALIGN_TOP);
...@@ -107,28 +116,24 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title) ...@@ -107,28 +116,24 @@ SimpleWindow::SimpleWindow(int w, int h, const char* title):Fl_Window(w,h,title)
in_beta_num_intervals = new Fl_Value_Input(2*padding,secondrow,boxwidth,boxheight,"height"); in_beta_num_intervals = new Fl_Value_Input(2*padding,secondrow,boxwidth,boxheight,"height");
in_beta_num_intervals->align(FL_ALIGN_TOP); in_beta_num_intervals->align(FL_ALIGN_TOP);
in_beta_num_intervals->value(400); in_beta_num_intervals->value(400);
in_beta_num_intervals->step(1);
in_num_iterations = new Fl_Value_Input(3*padding,firstrow,boxwidth,boxheight,"iterations");
in_num_iterations->align(FL_ALIGN_TOP);
in_num_iterations->value(100);
in_threshold = new Fl_Value_Input(4*padding,firstrow,boxwidth,boxheight,"threshold"); in_num_seedpoints = new Fl_Value_Input(3*padding,secondrow,boxwidth,boxheight,"# seedpoints");
in_threshold->align(FL_ALIGN_TOP);
in_threshold->value(1);
in_num_seedpoints = new Fl_Value_Input(3*padding,secondrow,boxwidth,boxheight,"#seedpoints");
in_num_seedpoints->align(FL_ALIGN_TOP); in_num_seedpoints->align(FL_ALIGN_TOP);
in_num_seedpoints->value(8); in_num_seedpoints->value(8);
in_num_seedpoints->step(1);
button_compute = new Fl_Button(5*padding,firstrow,boxwidth,boxheight,"compute"); in_special_seedpoint = new Fl_Value_Input(4*padding,secondrow,boxwidth,boxheight,"special seed");
button_compute->type(FL_NORMAL_BUTTON); in_special_seedpoint->align(FL_ALIGN_TOP);
button_compute->color(FL_RED); in_special_seedpoint->value(0);
button_compute->callback(callback_compute,this);
in_output_csv = new Fl_Check_Button(5*padding,secondrow,boxwidth,boxheight,"csv output"); in_output_csv = new Fl_Check_Button(5*padding,secondrow,boxwidth,boxheight,"csv output");
group->end();
this->end(); this->end();
resizable(this); this->resizable(scroll);
this->show(); this->show();
} }
...@@ -144,7 +149,8 @@ void SimpleWindow::callback_compute(Fl_Widget* o, void* v) { ...@@ -144,7 +149,8 @@ void SimpleWindow::callback_compute(Fl_Widget* o, void* v) {
void SimpleWindow::callback_compute_il() { void SimpleWindow::callback_compute_il() {
std::cout << "start computation..." << std::endl; std::cout << "start computation..." << std::endl;
std::vector<float> seedpoints = {}; std::vector<float> seedpoints;
seedpoints.push_back(in_special_seedpoint->value());
compute_all( compute_all(
in_num_iterations->value(), in_num_iterations->value(),
...@@ -161,9 +167,9 @@ void SimpleWindow::callback_compute_il() { ...@@ -161,9 +167,9 @@ void SimpleWindow::callback_compute_il() {
); );
image = new Fl_PNG_Image("picture.png"); image = new Fl_PNG_Image("picture.png");
scrollbox->image(image); imagebox->image(image);
scrollbox->resize(0,0,image->w(),image->h()); imagebox->resize(0,0,image->w(),image->h());
redraw(); redraw();
std::cout << "done." << std::endl; std::cout << "finished computation." << std::endl;
} }