Skip to content

Commit

Permalink
clearer name for list of auto-defined unary functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Sep 18, 2015
1 parent 47cd559 commit 1745af3
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions docs/source/contributing.rst
Expand Up @@ -16,13 +16,13 @@ Manually Optimizing Unary Functions
1. Pick a function to optimize
++++++++++++++++++++++++++++++

To see a list of functions to pick from, look at ``ForwardDiff.supported_unary_funcs``:
To see a list of functions to pick from, look at ``ForwardDiff.auto_defined_unary_funcs``:

.. code-block:: julia
julia> using ForwardDiff
julia> ForwardDiff.supported_unary_funcs
julia> ForwardDiff.auto_defined_unary_funcs
57-element Array{Symbol,1}:
:sqrt
:cbrt
Expand Down Expand Up @@ -133,7 +133,7 @@ In ``src/TensorNumber.jl``, under the ``Special Cases``/``Manually Optimized`` s
4. Run Tests
++++++++++++

The functions in ``ForwardDiff.supported_unary_funcs`` are automatically tested as part of ForwardDiff.jl's test suite, so you don't need to write tests yourself. Go ahead and test your changes by running ``Pkg.test("ForwardDiff")``.
The functions in ``ForwardDiff.auto_defined_unary_funcs`` are automatically tested as part of ForwardDiff.jl's test suite, so you don't need to write tests yourself. Go ahead and test your changes by running ``Pkg.test("ForwardDiff")``.

If everything passes, you can submit a PR to the ForwardDiff.jl repository to share your work!

Expand Down
4 changes: 2 additions & 2 deletions src/ForwardDiff.jl
Expand Up @@ -14,9 +14,9 @@ module ForwardDiff
ctranspose, eltype, abs, abs2, start,
next, done, atan2

const supported_unary_funcs = map(first, Calculus.symbolic_derivatives_1arg())
const auto_defined_unary_funcs = map(first, Calculus.symbolic_derivatives_1arg())

for fsym in supported_unary_funcs
for fsym in auto_defined_unary_funcs
@eval import Base.$(fsym);
end

Expand Down
2 changes: 1 addition & 1 deletion src/GradientNumber.jl
Expand Up @@ -160,7 +160,7 @@ end

# Unary functions on GradientNumbers #
#------------------------------------#
for fsym in supported_unary_funcs
for fsym in auto_defined_unary_funcs
a = :a
new_a = :($(fsym)($a))
deriv = Calculus.differentiate(new_a, a)
Expand Down
6 changes: 3 additions & 3 deletions src/HessianNumber.jl
Expand Up @@ -241,13 +241,13 @@ end
# Unary functions on HessianNumbers #
#-----------------------------------#
# the second derivatives of functions in
# unsupported_unary_hess_funcs involves
# unsupported_unary_hess_funcs involve
# differentiating elementary functions
# that are unsupported by Calculus.jl
const unsupported_unary_hess_funcs = [:asec, :acsc, :asecd, :acscd, :acsch, :trigamma]
const unary_hess_funcs = filter!(sym -> !in(sym, unsupported_unary_hess_funcs), supported_unary_funcs)
const auto_defined_unary_hess_funcs = filter!(sym -> !in(sym, unsupported_unary_hess_funcs), auto_defined_unary_funcs)

for fsym in unary_hess_funcs
for fsym in auto_defined_unary_hess_funcs
a = :a
new_a = :($(fsym)($a))
deriv1 = Calculus.differentiate(new_a, a)
Expand Down
10 changes: 5 additions & 5 deletions src/TensorNumber.jl
Expand Up @@ -300,13 +300,13 @@ end

# Unary functions on TensorNumbers #
#----------------------------------#

# the third derivatives of functions in unsupported_unary_tens_funcs involves differentiating
# elementary functions that are unsupported by Calculus.jl
# the third derivatives of functions in unsupported_unary_tens_funcs
# involve differentiating elementary functions that are unsupported
# by Calculus.jl
const unsupported_unary_tens_funcs = [:digamma]
const unary_tens_funcs = filter!(sym -> !in(sym, unsupported_unary_tens_funcs), ForwardDiff.unary_hess_funcs)
const auto_defined_unary_tens_funcs = filter!(sym -> !in(sym, unsupported_unary_tens_funcs), ForwardDiff.auto_defined_unary_hess_funcs)

for fsym in unary_tens_funcs
for fsym in auto_defined_unary_tens_funcs
a = :a
new_a = :($(fsym)($a))
deriv1 = Calculus.differentiate(new_a, a)
Expand Down
2 changes: 1 addition & 1 deletion test/test_derivatives.jl
Expand Up @@ -29,7 +29,7 @@ function test_approx_deriv(a::Array, b::Array)
end
end

for fsym in ForwardDiff.supported_unary_funcs
for fsym in ForwardDiff.auto_defined_unary_funcs
func_expr = :($(fsym)(x) + 4^$(fsym)(x) - x * $(fsym)(x))
deriv = Calculus.differentiate(func_expr)
try
Expand Down
2 changes: 1 addition & 1 deletion test/test_hessians.jl
Expand Up @@ -236,7 +236,7 @@ end

chunk_sizes = (ForwardDiff.default_chunk_size, 2, Int(N/2), N)

for fsym in ForwardDiff.unary_hess_funcs
for fsym in ForwardDiff.auto_defined_unary_hess_funcs
testexpr = :($(fsym)(a) + $(fsym)(b) - $(fsym)(c) * $(fsym)(l) - $(fsym)(m) + $(fsym)(r))

@eval function testf(x::Vector)
Expand Down
2 changes: 1 addition & 1 deletion test/test_jacobians.jl
Expand Up @@ -33,7 +33,7 @@ end

chunk_sizes = (ForwardDiff.default_chunk_size, 1, Int(N/2), N)

for fsym in ForwardDiff.supported_unary_funcs
for fsym in ForwardDiff.auto_defined_unary_funcs
testexprs = [:($(fsym)(a) + $(fsym)(b)),
:(- $(fsym)(c)),
:(4 * $(fsym)(d)),
Expand Down
2 changes: 1 addition & 1 deletion test/test_tensors.jl
Expand Up @@ -253,7 +253,7 @@ function tens_test_x(fsym, N)
return rand(randrange, N)
end

for fsym in ForwardDiff.unary_tens_funcs
for fsym in ForwardDiff.auto_defined_unary_tens_funcs
testexpr = :($(fsym)(a) + $(fsym)(b) - $(fsym)(c) * $(fsym)(d))

@eval function testf(x::Vector)
Expand Down

0 comments on commit 1745af3

Please sign in to comment.