Hello Emilien,
It took a while, but I finally understood what
salem c is saying. Although I see that as only part of the bigger problem.
No matching function for call to 'compute_yf' |
This should have been the first indication of the problem.
1 2
|
void compute_yn( // <--- Function definition.
compute_yf( // <--- Function call.
|
See a problem. Check your spelling. There is no function
compute_yf
.
Then there is the parameters for the function
1 2 3
|
(double(*f)(int, double, const vector<double> &), double x0,
double xf, const vector<double> &y0, int p, int N, vector<double> &x,
vector<double> &y)
|
This first part
(double(*f)(int, double, const vector<double> &),
looks to me to be a prototype. Not sure if it would even work like this, and it is not where I would put it, but I would refer to what
salem c said.
Then in the function call compute_yf(expon, x0, xf, y_o, p, eps, N, y_f);
^
|
The first parameter looks to be a call to the function "expon", but it is missing its parameters. Since the function is defined as
double expon(int i, double x, vector <double> y)
When I get to the third parameter I have no idea what should have been sent to the the function because "y" has no meaning to me. Maybe it does for you.
While talking about variable names please use something other than a single letter. The single letters make the program hard to understand and follow because someone other than you is always trying to figure what a single letter variable is for. This is more for your benefit in the future.
Your variable names of "x0", "xf", "p", "N" and the "y_"s and "x" may mean something to you, but for the rest of us thy are hard to follow. Using a good variable name in "main" can also be used in a function because it looses scope in main when the function is called and becomes a local variable in the function. This makes no difference if the variable is defined as a function parameter or between the {}s of the function.
As an example if you wrote the function definition as:
double expon(const vector<double>& y_o)
. It is easy to understand which vector is being used. Also as for now the first two parameters are not used. Passing the vector as a const reference means that you are not taking the time to make a copy of the vector and the "const" means that you can not change the vector.
In the function call
compute_yf(expon, x0, xf, y_o, p, eps, N, y_f);
. Since "expon" is a function that you are trying to call to use its return value for the "compute" function call "expon" would be called first and then its return value would be used a a parameter of the "compute" function call. But you would have to make it a true function call to use it. Or you could use
compute_yf(y_o[0], x0, xf, y_o, p, eps, N, y_f);
and do the same thing as the function just returns a value that can just as easily be done here. I used "y_o" as an example because I am not sure what vector yo want to use.
To jump back to something you first said:
I've defined two functions in a header |
As I understand this these functions should be in a ".cpp" file not a header file. The header file should contain the prototypes of the functions. The only exception I can think of is when you use a template on the prototypes and the function definition. These work best when they are in the same file.
Sorry to jump around, but
int main(int argc, const char * argv[])
. These parameters are not used in the program and do not need to be here unless yo have some use that you have not coded for yet.
int main()
is all you need.
There are still some things I need to test and check. If I find something else I will let you know.
Hope that helps,
Andy