Hello,
I ran into the problem implementing some C++ logic and I'm wondering whether my plan is possible in C++ at all. Thus I would like to ask you, as experts, what do you think about it.

My plan is to generate some kind of container for several benchmark functions (mathematic functions) and their constraints. Every element should contain the "range" (value1 < x1 < value2), a list of constraints, and a function which returns the value of the corresponding mathematic function ( f(x1, x2)). First I thought it could be a struct, but then it is not possible to have a return function in it. If I define a class, then I will have to define a separate class for every function ( to much code).
Now I have the idea to use #define FUNCTION_NAME(x1,x2) ( (pow(sin(2*PI*x), 3) * sin(2*PI*y))/ (pow(x, 3) * (x + y)) ) to put this statement at wished place within the code, but then I have to define benchmark functions, constraints and ranges separately and they are not connected anymore.
Perhaps it is even possible to store these containers in a text file or something else, to have some kind of database of functions, which could be also extended by the user, if he wants to use own function.

I need it to make contour plots of 3D surfaces and the data comes from the class below:

Qt Code:
  1. class SpectrogramData: public QwtRasterData
  2. {
  3. public:
  4. SpectrogramData():
  5. QwtRasterData(QwtDoubleRect(0.0, 0.0, 10.0, 10.0)) <<<<<<<<<<<should be dynamic
  6. {
  7. }
  8.  
  9. virtual QwtRasterData *copy() const
  10. {
  11. return new SpectrogramData();
  12. }
  13. virtual QwtDoubleInterval range() const <<<<<<<<<<<should be dynamic
  14. {
  15. return QwtDoubleInterval(0.0, 10.0);
  16. }
  17. virtual double value(double x, double y) const <<<<<<<<<<<should be dynamic
  18. {
  19. const double PI = 3.14159265358979323846;
  20. const double v1 = pow(sin(2*PI*x), 3) * sin(2*PI*y);
  21. const double v2 = pow(x, 3) * (x + y);
  22. return (v1/v2);
  23. }
  24. };
To copy to clipboard, switch view to plain text mode 


Could you give me please some ideas and hints, how my plan can be achieved?

Thank you.

best regards,

Vitali Anselm