|
Post by ZeroVash on May 6, 2013 5:06:03 GMT -5
So i supposed this is for a side project. I stumbled myself upon this fun/boring problem. And this being a C++ thread and in order to raise some discussion across the boards i'll post what i was doing (instead of just wasting time doing it myself xD ) So yeah the problem is pretty simple: You'll have 3 variables. We can call them A,B and C for the moment. Their purpose is to be sent as function parameters to plot a control systems feedback output.(Not relevant for the time) So what is the problem after all? Each variable can take 4 forms: i) Either a small positive number (lets say 5) , ii) A small negative number (f.ex: -5), iii) A giant negative number (f.ex: -1000) and iv) A giant positive number (f.ex: 1000). You'll have to go trough every single possibility and send it trough to be plotted. Boring i know. But optimizing it for fast performances shall be fun I have a function handle called plot which basically sends the variables A,B,C and plots the current control system i'm looking at. So a basic algorithm for it would be: A=5; B=5; C=5; plot_C(A,B,C); C=1000; plot_C(A,B,C); B=100; C=5; plot_C(A,B,C);. The plot handle can change like if you wanna work with pointers or something like that ^_^ Or try and work with arrays but i doubt that would be the best approach :> Can't wait to hear your responses guys
|
|
|
Post by matheuslps on May 6, 2013 23:12:25 GMT -5
I do not think if I understand well, but my first shot is something like (obvius one):
for (a=-1000;a<=1000;a++) { for (b=-1000;b<=1000;b++) { for (c=-1000;c<=1000;c++) { plot_C(A,B,C); } } }
With this way, I cover all possibilities. But do not think if it is fast....
bye
|
|
|
Post by ZeroVash on May 7, 2013 4:14:04 GMT -5
Ahah you misunderstood The variables can only take fixed values. So A,B,C can only be either -1000,-5,5,1000 .
|
|
|
Post by matheuslps on May 7, 2013 15:14:07 GMT -5
Well, I know a bit of programming, but do not know how to to it in a fast way. You said that work with arrays is not the best aproach. Why?
a = [-1000,-5,5,1000] b = [-1000,-5,5,1000] c = [-1000,-5,5,1000]
for (i=0;i<4;i++) { for (j=0;j<4;j++) { for (k=0;k<4;k++) { plot_C(A[i],B[j],C[k]); } } }
bye
|
|
alpha
New Member
1st year in computer engineering.
Posts: 5
|
Post by alpha on Jun 12, 2013 11:02:24 GMT -5
Hi,
I would really like to help you but i don't understand what are you trying to accomplish? (not a much difference, but you try to do this in C or C++)
|
|