From 615ad0385f171e75256df547fddd577c0d0f6eac Mon Sep 17 00:00:00 2001 From: Lucas Aschenbach <37406743+LucasAschenbach@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:14:34 +0200 Subject: [PATCH] Set jacobian of Fun to ZeroOperator (#909) * jacobian of Fun is ZeroOperator * Decrease maxiterations for independent variable newton test --- src/Extras/autodifferentiation.jl | 2 +- test/ExtrasTest.jl | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Extras/autodifferentiation.jl b/src/Extras/autodifferentiation.jl index 14476b6ec..a3f47c60f 100644 --- a/src/Extras/autodifferentiation.jl +++ b/src/Extras/autodifferentiation.jl @@ -61,7 +61,7 @@ last(d::DualFun) = DualFun(last(d.f),Evaluation(rangespace(d.J),rightendpoint)*d jacobian(d::DualFun) = d.J jacobian(a::Number) = zero(a) -jacobian(f::Fun) = Operator(I,space(f)) +jacobian(f::Fun) = zero(Operator(I,space(f))) promote_rule(::Type{DF},::Type{T}) where {DF<:DualFun,T<:Number}=DualFun convert(::Type{DualFun},b::Number) = DualFun(b,0) diff --git a/test/ExtrasTest.jl b/test/ExtrasTest.jl index 858087e20..f6b7ff144 100644 --- a/test/ExtrasTest.jl +++ b/test/ExtrasTest.jl @@ -123,8 +123,7 @@ include(joinpath(@__DIR__, "testutils.jl")) u2' - u2*u2; ] - # note takes a few more iterations to converge to accuracy - u1,u2 = newton(N_ind, [u1,u2], maxiterations=25) + u1,u2 = newton(N_ind, [u1,u2]) u1_exact = -1 / (x - 2) u2_exact = -1 / (x + 2)