Open Kolaru opened 5 years ago
Good point and good idea.
For ForwardDiff
I think we just need
import ForwardDiff
ForwardDiff.gradient(f, X::IntervalBox) = ForwardDiff.gradient(f, X.v)
ForwardDiff.jacobian(f, X::IntervalBox) = ForwardDiff.jacobian(f, X.v)
ForwardDiff.hessian(f, X::IntervalBox) = ForwardDiff.hessian(f, X.v)
Currently, the functions passed to
roots
must returnSVector
which has several drawbacks:IntervalBox
andSVector
work in a quite similar manner, but are not equivalent, which may cause unexpected bugs. For example consider the followingHere
isempty(IB)
evaluates totrue
whileisempty(SV)
evaluates tofalse
. This caused some of the bugs I'm trying to fix in #93 (an update is coming soon).Therefore, I advise that
SVector
should only be used whenForwardDiff
is directly involved, i.e. deep inside the contractors.It may be possible to support both the current behavior and function returning
IntervalBox
(converting to the latter internally) using fancy multiple dispatch, otherwise this would be a breaking change.