Skip to content

Commit

Permalink
Merge 78b95f4 into 2d81794
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasnoack committed Nov 2, 2020
2 parents 2d81794 + 78b95f4 commit 4b561cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# FiniteDiff

[![Build Status](https://travis-ci.org/JuliaDiff/FiniteDiff.jl.svg?branch=master)](https://travis-ci.org/JuliaDiff/FiniteDiff.jl)
[![codecov](https://codecov.io/gh/JuliaDiff/FiniteDiff.jl/branch/master/graph/badge.svg?token=PnBAscoOiU)](https://codecov.io/gh/JuliaDiff/FiniteDiff.jl)

This package is for calculating derivatives, gradients, Jacobians, Hessians,
etc. numerically. This library is for maximizing speed while giving a usable
Expand Down
4 changes: 2 additions & 2 deletions src/FiniteDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ _vec(x) = vec(x)
_vec(x::Number) = x

_mat(x::AbstractMatrix) = x
_mat(x::StaticVector) = reshape(x, (axes(x, 1), SOneTo(1)))
_mat(x::AbstractVector) = reshape(x, (axes(x, 1), OneTo(1)))
_mat(x::StaticVector) = reshape(x, (axes(x, 1), SOneTo(1)))
_mat(x::AbstractVector) = reshape(x, (axes(x, 1), Base.OneTo(1)))

include("iteration_utils.jl")
include("epsilons.jl")
Expand Down
21 changes: 9 additions & 12 deletions test/out_of_place_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ J = FiniteDiff.finite_difference_jacobian(f, x, Val{:forward}, eltype(x),
@test J second_derivative_stencil(30)
@test typeof(J) == typeof(spJ)

#1x1 SVector test
x = SVector{1}([1.])
f(x) = x
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:forward}, eltype(x))
@test J[1, 1] 1.0
@test J isa SMatrix{1,1}
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:central}, eltype(x))
@test J[1, 1] 1.0
@test J isa SMatrix{1,1}
J = FiniteDiff.finite_difference_jacobian(f, x, Val{:complex}, eltype(x))
@test J[1, 1] 1.0
@test J isa SMatrix{1,1}
f = x -> x
@testset "1x1 test of $x" for
(x, y) in ((SVector{1}([1.]), SMatrix{1,1}), ([1.0], Matrix)),
difftype in (:forward, :central, :complex)

J = FiniteDiff.finite_difference_jacobian(f, x, Val{difftype}, eltype(x))
@test J[1, 1] 1.0
@test J isa y
end

x = SVector{1}([1.])
f(x) = vcat(x, x)
Expand Down

0 comments on commit 4b561cc

Please sign in to comment.