NumbaMinpack
NumbaMinpack copied to clipboard
Support for external function call
Hi @Nicholaswogan,
I am interested in using your NumbaMinPack implementation for finding the roots of a non-linear problem.
At the moment I am using scipy's root
function for doing this but the thing is I need to apply this root finding routine while iterating over a sequence of points.
For a small number of points, I do not have that much of a problem but once the number is increased, scipy's standard root finding is not feasible anymore.
I was then searching for an alternative and found your project. The thing that I was wondering about is: How can I pass an argument which is a scipy function to the function for which I want to find the root.
The problem that I am trying to solve is somehow described as:
In where $\nabla H(\xi,\eta)$ is in fact a RectBivariateSpline
function.
Right now I am doing the following:
for i in range(0,self.N_total,1):
sol = optimize.root(xi_np1_3,x0=xi_n[i],args=(eta_n[i],h,xi_n[i],self.H_initial_sp))
self.xi_np1_eval[i] = sol.x
in where xi_np1_3
is given as:
def xi_np1_3(xi,eta,h,xi_n,H):
H_grad_y = H.ev(eta,xi,dx=1)
return (xi - xi_n + h*H_grad_y)
So in this case, everything would be a float (supported by Numba) except the Spline object (not supported by Numba) which is evaluated internally within the root finding calls.
Do you know what could I do in this case? Is there any way in which I can have a callback to the Spline ev
method and return directly a float to your root finding routine? I guess this could work and would be supported by Numba right?