diff --git a/REQUIRE b/REQUIRE index db757995..fc7174e4 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,6 +1,7 @@ julia 0.6- StaticArrays 0.5.0 -DiffBase 0.0.3 -Calculus 0.2.0 +DiffBase 0.2.0 NaNMath 0.2.2 SpecialFunctions 0.1.0 +RealInterface 0.0.2 +CommonSubexpressions 0.0.1 diff --git a/docs/_rst/source/contributing.rst b/docs/_rst/source/contributing.rst index 7de30bdc..35b5d105 100644 --- a/docs/_rst/source/contributing.rst +++ b/docs/_rst/source/contributing.rst @@ -12,68 +12,26 @@ If you're new GitHub, here's an outline of the workflow you should use: 3. Apply your code changes to the branch on your fork 4. When you're done, submit a PR to ForwardDiff to merge your fork into ForwardDiff's master branch. -Manually Optimizing Unary Functions ------------------------------------ +Adding New Derivative Definitions +--------------------------------- -To see a list of functions to pick from, look at ``ForwardDiff.AUTO_DEFINED_UNARY_FUNCS``: +In general, new derivative implementations for ``Dual`` are automatically defined via +simple symbolic rules. ForwardDiff accomplishes this by looping over the `the function names +listed in the RealInterface package`_, and for every function (and relevant arity), it +attempts to generate a ``Dual`` definition by applying the `symbolic rules provided by the +DiffBase package`_. Conveniently, these auto-generated definitions are also automatically +tested. -.. code-block:: julia +Thus, in order to add a new derivative implementation for ``Dual``, you should do the +following: - julia> import ForwardDiff +1. Make sure the name of the function is appropriately listed in the RealInterface package +2. Define the appropriate derivative rule(s) in DiffBase +3. Check that calling the function on ``Dual`` instances delivers the desired result. - julia> ForwardDiff.AUTO_DEFINED_UNARY_FUNCS - 57-element Array{Symbol,1}: - :sqrt - :cbrt - :abs2 - :inv - :log - :log10 - :log2 - :log1p - :exp - :exp2 - :expm1 - :sin - :cos - :tan - ⋮ +Depending on the arity of your function and its category in RealInterface, +ForwardDiff's auto-definition mechanism might need to be expanded to include it. +If this is the case, ForwardDiff's maintainers can help you out. -Some of these functions may have already been manually optimized. To see what functions have -already been done, go to ``src/dual.jl`` and scroll down to the ``Special Cases`` section. - -The functions in ``ForwardDiff.AUTO_DEFINED_UNARY_FUNCS`` are automatically tested as part -of ForwardDiff's test suite, so you don't need to write tests yourself. You can test your -changes by running ``Pkg.test("ForwardDiff")``. - -If everything passes, you can submit a PR to the ForwardDiff repository to share your work! - -Implementing New Functions --------------------------- - -Unary Functions Via Calculus.jl -+++++++++++++++++++++++++++++++ - -The easiest way to add support for a new function is actually to define a derivative rule -for the function in Calculus's `symbolic differentiation code`_, which ForwardDiff then uses -to generate the function's definition on ``Dual`` numbers. To accomplish this: - -1. Open an issue in ForwardDiff with the title "Supporting f(x)" (obviously replacing "f(x)"" with the function you wish to support). -2. Open a PR to Calculus that adds the relevant differentiation rule(s) and tests. In the PR's description, be sure to mention the relevant ForwardDiff issue such that GitHub links the two. -3. Once the PR to Calculus is accepted, we can check to make sure that the function works appropriately in ForwardDiff. If it does, then you're done, and the issue in ForwardDiff can be considered resolved! - -.. _`symbolic differentiation code`: https://github.com/johnmyleswhite/Calculus.jl/blob/master/src/differentiate.jl#L115 - -Manually Adding Functions to ForwardDiff -++++++++++++++++++++++++++++++++++++++++ - -Some functions aren't suitable for auto-definition via the Calculus package. An example of -such a function is the non-unary function ``atan2``, which is defined manually in -``ForwardDiff/src/dual.jl``. - -The process for manually adding functions to ForwardDiff without going through Calculus.jl -is essentially the same as the process for manually optimizing existing functions, with the -additional requirement that you'll have to write the tests yourself. New tests for ``Dual`` -numbers can be placed in `DualTest.jl`_. - -.. _`DualTest.jl`: https://github.com/JuliaDiff/ForwardDiff.jl/tree/master/test/DualTest.jl +.. _`the function names listed in the RealInterface package`: https://github.com/jrevels/RealInterface.jl +.. _`symbolic rules provided by the DiffBase package`: https://github.com/JuliaDiff/DiffBase.jl/blob/master/src/rules.jl diff --git a/docs/_sources/contributing.txt b/docs/_sources/contributing.txt index 7de30bdc..35b5d105 100644 --- a/docs/_sources/contributing.txt +++ b/docs/_sources/contributing.txt @@ -12,68 +12,26 @@ If you're new GitHub, here's an outline of the workflow you should use: 3. Apply your code changes to the branch on your fork 4. When you're done, submit a PR to ForwardDiff to merge your fork into ForwardDiff's master branch. -Manually Optimizing Unary Functions ------------------------------------ +Adding New Derivative Definitions +--------------------------------- -To see a list of functions to pick from, look at ``ForwardDiff.AUTO_DEFINED_UNARY_FUNCS``: +In general, new derivative implementations for ``Dual`` are automatically defined via +simple symbolic rules. ForwardDiff accomplishes this by looping over the `the function names +listed in the RealInterface package`_, and for every function (and relevant arity), it +attempts to generate a ``Dual`` definition by applying the `symbolic rules provided by the +DiffBase package`_. Conveniently, these auto-generated definitions are also automatically +tested. -.. code-block:: julia +Thus, in order to add a new derivative implementation for ``Dual``, you should do the +following: - julia> import ForwardDiff +1. Make sure the name of the function is appropriately listed in the RealInterface package +2. Define the appropriate derivative rule(s) in DiffBase +3. Check that calling the function on ``Dual`` instances delivers the desired result. - julia> ForwardDiff.AUTO_DEFINED_UNARY_FUNCS - 57-element Array{Symbol,1}: - :sqrt - :cbrt - :abs2 - :inv - :log - :log10 - :log2 - :log1p - :exp - :exp2 - :expm1 - :sin - :cos - :tan - ⋮ +Depending on the arity of your function and its category in RealInterface, +ForwardDiff's auto-definition mechanism might need to be expanded to include it. +If this is the case, ForwardDiff's maintainers can help you out. -Some of these functions may have already been manually optimized. To see what functions have -already been done, go to ``src/dual.jl`` and scroll down to the ``Special Cases`` section. - -The functions in ``ForwardDiff.AUTO_DEFINED_UNARY_FUNCS`` are automatically tested as part -of ForwardDiff's test suite, so you don't need to write tests yourself. You can test your -changes by running ``Pkg.test("ForwardDiff")``. - -If everything passes, you can submit a PR to the ForwardDiff repository to share your work! - -Implementing New Functions --------------------------- - -Unary Functions Via Calculus.jl -+++++++++++++++++++++++++++++++ - -The easiest way to add support for a new function is actually to define a derivative rule -for the function in Calculus's `symbolic differentiation code`_, which ForwardDiff then uses -to generate the function's definition on ``Dual`` numbers. To accomplish this: - -1. Open an issue in ForwardDiff with the title "Supporting f(x)" (obviously replacing "f(x)"" with the function you wish to support). -2. Open a PR to Calculus that adds the relevant differentiation rule(s) and tests. In the PR's description, be sure to mention the relevant ForwardDiff issue such that GitHub links the two. -3. Once the PR to Calculus is accepted, we can check to make sure that the function works appropriately in ForwardDiff. If it does, then you're done, and the issue in ForwardDiff can be considered resolved! - -.. _`symbolic differentiation code`: https://github.com/johnmyleswhite/Calculus.jl/blob/master/src/differentiate.jl#L115 - -Manually Adding Functions to ForwardDiff -++++++++++++++++++++++++++++++++++++++++ - -Some functions aren't suitable for auto-definition via the Calculus package. An example of -such a function is the non-unary function ``atan2``, which is defined manually in -``ForwardDiff/src/dual.jl``. - -The process for manually adding functions to ForwardDiff without going through Calculus.jl -is essentially the same as the process for manually optimizing existing functions, with the -additional requirement that you'll have to write the tests yourself. New tests for ``Dual`` -numbers can be placed in `DualTest.jl`_. - -.. _`DualTest.jl`: https://github.com/JuliaDiff/ForwardDiff.jl/tree/master/test/DualTest.jl +.. _`the function names listed in the RealInterface package`: https://github.com/jrevels/RealInterface.jl +.. _`symbolic rules provided by the DiffBase package`: https://github.com/JuliaDiff/DiffBase.jl/blob/master/src/rules.jl diff --git a/docs/contributing.html b/docs/contributing.html index 5a1973b7..9ed2601b 100644 --- a/docs/contributing.html +++ b/docs/contributing.html @@ -92,12 +92,7 @@
@@ -156,60 +151,24 @@To see a list of functions to pick from, look at ForwardDiff.AUTO_DEFINED_UNARY_FUNCS:
julia> import ForwardDiff
-
-julia> ForwardDiff.AUTO_DEFINED_UNARY_FUNCS
-57-element Array{Symbol,1}:
- :sqrt
- :cbrt
- :abs2
- :inv
- :log
- :log10
- :log2
- :log1p
- :exp
- :exp2
- :expm1
- :sin
- :cos
- :tan
- ⋮
-Some of these functions may have already been manually optimized. To see what functions have
-already been done, go to src/dual.jl and scroll down to the Special Cases section.
The functions in ForwardDiff.AUTO_DEFINED_UNARY_FUNCS are automatically tested as part
-of ForwardDiff’s test suite, so you don’t need to write tests yourself. You can test your
-changes by running Pkg.test("ForwardDiff").
If everything passes, you can submit a PR to the ForwardDiff repository to share your work!
- -The easiest way to add support for a new function is actually to define a derivative rule
-for the function in Calculus’s symbolic differentiation code, which ForwardDiff then uses
-to generate the function’s definition on Dual numbers. To accomplish this:
In general, new derivative implementations for Dual are automatically defined via
+simple symbolic rules. ForwardDiff accomplishes this by looping over the the function names
+listed in the RealInterface package, and for every function (and relevant arity), it
+attempts to generate a Dual definition by applying the symbolic rules provided by the
+DiffBase package. Conveniently, these auto-generated definitions are also automatically
+tested.
Thus, in order to add a new derivative implementation for Dual, you should do the
+following:
Dual instances delivers the desired result.Some functions aren’t suitable for auto-definition via the Calculus package. An example of
-such a function is the non-unary function atan2, which is defined manually in
-ForwardDiff/src/dual.jl.
The process for manually adding functions to ForwardDiff without going through Calculus.jl
-is essentially the same as the process for manually optimizing existing functions, with the
-additional requirement that you’ll have to write the tests yourself. New tests for Dual
-numbers can be placed in DualTest.jl.
Depending on the arity of your function and its category in RealInterface, +ForwardDiff’s auto-definition mechanism might need to be expanded to include it. +If this is the case, ForwardDiff’s maintainers can help you out.