Skip to content

Commit

Permalink
add change of default AD backend
Browse files Browse the repository at this point in the history
  • Loading branch information
ocots committed Jun 20, 2024
1 parent fad9005 commit f2f8fbc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/CTBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ export Description, add, getFullDescription
export CTException, ParsingError, AmbiguousDescription, IncorrectMethod
export IncorrectArgument, IncorrectOutput, NotImplemented, UnauthorizedCall

# checking
# AD
export set_AD_backend

# functions
export Hamiltonian, HamiltonianVectorField, VectorField
Expand Down
10 changes: 9 additions & 1 deletion src/default.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#
global __default_AD_backend = AutoForwardDiff()

function set_AD_backend(AD)
global __default_AD_backend = AD
nothing
end

"""
$(TYPEDSIGNATURES)
Used to set the default value of Automatic Differentiation backend.
The default value is `AutoForwardDiff()`, that is the `ForwardDiff` package is used by default.
"""
__auto() = AutoForwardDiff() # default AD backend
__auto() = __default_AD_backend # default AD backend

"""
$(TYPEDSIGNATURES)
Expand Down
3 changes: 0 additions & 3 deletions test/test_description.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ descriptions = add(descriptions, (:b,))
@test descriptions[1] == (:a,)
@test descriptions[2] == (:b,)

# print a tuple of descriptions
@test display(descriptions) isa Nothing

# get the complete description of the chosen method
algorithmes = ()
algorithmes = add(algorithmes, (:descent, :bfgs, :bissection))
Expand Down

0 comments on commit f2f8fbc

Please sign in to comment.