From afa6efea73da4f9f481a3045a6852a72ca5f31a1 Mon Sep 17 00:00:00 2001 From: Kanav Gupta Date: Sun, 12 Jul 2020 14:26:13 +0530 Subject: [PATCH 1/2] replace calculate_Ji calls --- src/jacobians.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jacobians.jl b/src/jacobians.jl index e4a60e9..0a5bff3 100644 --- a/src/jacobians.jl +++ b/src/jacobians.jl @@ -197,7 +197,7 @@ function finite_difference_jacobian( else @inbounds for color_i ∈ 1:maximum(colorvec) if sparsity isa Nothing - dx = calculate_Ji(color_i) + dx = calculate_Ji_forward(color_i) J = J + _make_Ji(J, eltype(x), dx, color_i, nrows, ncols) else tmp = norm(vecx .* (colorvec .== color_i)) @@ -232,7 +232,7 @@ function finite_difference_jacobian( else @inbounds for color_i ∈ 1:maximum(colorvec) if sparsity isa Nothing - dx = calculate_Ji(color_i) + dx = calculate_Ji_central(color_i) J = J + _make_Ji(J, eltype(x), dx, color_i, nrows, ncols) else tmp = norm(vecx1 .* (colorvec .== color_i)) From cb0c016ae9a52ce5ce01cf4ad006c2f84b562399 Mon Sep 17 00:00:00 2001 From: Kanav Gupta Date: Sun, 12 Jul 2020 14:58:43 +0530 Subject: [PATCH 2/2] fix jacobians of size 1x1 --- src/jacobians.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/jacobians.jl b/src/jacobians.jl index 0a5bff3..0b5d408 100644 --- a/src/jacobians.jl +++ b/src/jacobians.jl @@ -194,6 +194,9 @@ function finite_difference_jacobian( if jac_prototype isa Nothing && sparsity isa Nothing J = mapreduce(calculate_Ji_forward, hcat, 1:maximum(colorvec)) + if maximum(colorvec) == 1 + J = reshape(J, 1, 1) + end else @inbounds for color_i ∈ 1:maximum(colorvec) if sparsity isa Nothing @@ -229,6 +232,9 @@ function finite_difference_jacobian( if jac_prototype isa Nothing && sparsity isa Nothing J = mapreduce(calculate_Ji_central, hcat, 1:maximum(colorvec)) + if maximum(colorvec) == 1 + J = reshape(J, 1, 1) + end else @inbounds for color_i ∈ 1:maximum(colorvec) if sparsity isa Nothing @@ -263,6 +269,9 @@ function finite_difference_jacobian( if jac_prototype isa Nothing && sparsity isa Nothing J = mapreduce(calculate_Ji_complex, hcat, 1:maximum(colorvec)) + if maximum(colorvec) == 1 + J = reshape(J, 1, 1) + end else @inbounds for color_i ∈ 1:maximum(colorvec) if sparsity isa Nothing