pass extra data to a function
I'm working on a project hence in urgent need of guides. The problem might be clarified by using a simple example (if in need, I'll spell out the whole picture, however the following is the barebone):
suppose I want to minimize a function f(a), the argument for the function is only 'a' from the optimizor's point of view. Hence the optimizor wants to find the 'a' that will minimize f().
However, f(.) itself is not a simple function of 'a', it is derived out of function
g(a,b) where b is a constant determined during the runtime (i.e., you cannot declare f(.) by specifying 'b' beforehand). Worse, 'b' might be an array of two dimension (think of importing data into the function g(.) and construct f(.)).
I tried declaring b as an external, defining g(a,b), and then used g(.) in the definition of f(.), but failed. The linker said the 'b' is undeclared.
Please anyone helps me out of this. I appreciate it very much...