JuliaNLSolvers / NLsolve.jl

Julia solvers for systems of nonlinear equations and mixed complementarity problems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detection of `inplace` for fixed point

jlperla opened this issue · comments

@pkofod and @arnavs

I am finding that the code using the fixedpoint and solve functions look uglier than they need to be when using inplace = false all over the place.

I think this could have an almost trivial change:
For the following:

and if you want to do it for the nlsolve interface:

CHange inplace = true
to something like

inplace = !applicable(f, initial_x)

that is, check if it can be called with just the initial condition... if so, then we can use inplace = false

Of course, there is a small chance that there is a method for both f(out, x) and f(x) for the same function (at which point this would choose the f(x) one by default)... but I doubt that would happen in practice. People are very careful to use the ! for modifying functions, so it is pretty rare to have both.

My guess is that checking that the typeof(f) <: Union{InplaceObjective, NotInplaceObjective} might also be important for the nlsolve case.. But if we only do this for fixedpoint that would be fine with me.

Is applicable a Base function?

Yeah

Opened #192 to incorporate this change (only for fixedpoint() for now). Also, it turns out it's actually just Base.applicable

Closing because the PR #192 has been merged.