Use a class function in another function

Hello,
I have a problem in using the nlopt optimization library.

I have defined a class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

class GARCH
{
private:
//variables...

        vector<double> param(3);

public:
        //some functions....
   	void set_param(vector<double> &ext_param){param = ext_param;};
	double compute_log_likelihood();

};


My goal is to maximize with respect to param, the value returned by compute_log_likelihood(), which value depends on the param vector, set by the set_param().

Nlopt library provides a maximization algorithm.
In order to be applied I need a function of the type:

 
double myfuncv(const std::vector<double> &x, std::vector<double> &grad, void* myData)


Where x is the vector of parameters, grad is the vector of gradients (optional) and my data is a pointer to some external data.

My question is how I can build such a function that use my class. i.e maximize the value of compute_log_likelihood, by changing the param vector (through set_param().
The class contains also a vector of data which also affects the value of compute_log_likelihood().

Thank you


Topic archived. No new replies allowed.