JuliaDiff / JuliaDiff/ForwardDiff.jl

Support for function of arbitrary type (not just <:Real)

Open
#405 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
1k
Forks
160
PR merge metrics
No merged PRs in 30d

Description

I'm converting a C++ program that uses FADBAD++ to Julia and I've noticed that this library is restricted to only taking derivatives of functions of the form f(x::Real)::Union{Real,AbstractArray}. Specifically x::Real. Two questions:

  1. Is there a way to have JuliaDiff/ForwardDiff accept and evaluate functions for types other than Real, say custom type Affine http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.63.716&rep=rep1&type=pdf without changing the underlying source code? Below is the context.
  2. If not do you foresee any particular difficulties of changing types in the source code, provided operations for Real (i.e. one, iszero, zero, isfinite) are extended to these types?

Using FADBAD++ with other types than double
It is possible to change the underlying arithmetic type for all function and derivative calculations - also called the BaseType. Normally the underlying arithmetic type is double, but automatic differentiation is also very useful in the field of interval arithmetic. E.g. to obtain narrow enclosures by using the mean value form or in global optimization.
The templates that are defined in FADBAD++ requre that some standard operations are defined for the underlying type: comparison operators, simple operations "+", "-" "*", "/" and simple functions "sin", "cos", "exp", etc.

from http://www.fadbad.com/fadbad.html#AdvancedUse

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing ForwardDiff's handling of functions constrained to Real and the listed operations needed by a custom Affine type. Compare that behavior with the issue's FADBAD++ example and determine whether broader type support can be specified without source changes. Done means establishing a concrete supported approach or a scoped design for changing the type restrictions.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.