@@ -77,9 +77,6 @@ passed as the third positional argument in the form of a `NamedTuple`.
7777""" select_algorithm
7878
7979function select_algorithm(f:: F , A, alg:: Alg = nothing ; kwargs... ) where {F,Alg}
80- return select_algorithm(f, typeof(A), alg; kwargs... )
81- end
82- function select_algorithm(f:: F , :: Type{A} , alg:: Alg = nothing ; kwargs... ) where {F,A,Alg}
8380 if isnothing(alg)
8481 return default_algorithm(f, A; kwargs... )
8582 elseif alg isa Symbol
@@ -193,10 +190,24 @@ macro functiondef(f)
193190 end
194191
195192 # define fallbacks for algorithm selection
196- @inline function select_algorithm(:: typeof ($ f), :: Type{A} , alg:: Alg ;
197- kwargs... ) where {Alg,A}
193+ @inline function select_algorithm(:: typeof ($ f), A, alg:: Alg ; kwargs... ) where {Alg}
198194 return select_algorithm($ f!, A, alg; kwargs... )
199195 end
196+ # define default algorithm fallbacks for out-of-place functions
197+ # in terms of the corresponding in-place function
198+ @inline function default_algorithm(:: typeof ($ f), A; kwargs... )
199+ return default_algorithm($ f!, A; kwargs... )
200+ end
201+ # define default algorithm fallbacks for out-of-place functions
202+ # in terms of the corresponding in-place function for types,
203+ # in principle this is covered by the definition above but
204+ # it is necessary to avoid ambiguity errors with the generic definitions:
205+ # ```julia
206+ # default_algorithm(f::F, A; kwargs...) where {F} = default_algorithm(f, typeof(A); kwargs...)
207+ # function default_algorithm(f::F, ::Type{T}; kwargs...) where {F,T}
208+ # throw(MethodError(default_algorithm, (f, T)))
209+ # end
210+ # ```
200211 @inline function default_algorithm(:: typeof ($ f), :: Type{A} ; kwargs... ) where {A}
201212 return default_algorithm($ f!, A; kwargs... )
202213 end
0 commit comments