I have a numerical integrator (using RK4), that takes functions of one variable of any type and integrates them. The function that needs to be integrated is, and needs to be, of multiple variables. The issue then, is how to use this function as an argument to the integrator without the use of globals.
In pseudo-code:
1 2 3 4 5 6 7 8
g(x,a,b) {
...
}
f(a,b,c,d,n) {
g(x) = g(x,a,b); <<-- How do I dothis?
return integral(g(x),c,d,n);
}
A default value is not sufficient. I need to ether overload g with a one variable function declared in the same namespace as f or declare a new function of one variable (that is identical in content to g) in the namespace of f.
This is part of a larger project, so changing languages is extremely difficult if not entirely excluded. Incidentally, this is why globals are not an option.