@@ -99,6 +99,7 @@ derivative(O::Operation, idx) = derivative(O.op, (O.args...,), Val(idx))
99
99
# Pre-defined derivatives
100
100
import DiffRules, SpecialFunctions, NaNMath
101
101
for (modu, fun, arity) ∈ DiffRules. diffrules ()
102
+ fun in [:* , :+ ] && continue # special
102
103
for i ∈ 1 : arity
103
104
@eval function derivative (:: typeof ($ modu.$ fun), args:: NTuple{$arity,Any} , :: Val{$i} )
104
105
M, f = $ (modu, fun)
@@ -109,9 +110,8 @@ for (modu, fun, arity) ∈ DiffRules.diffrules()
109
110
end
110
111
end
111
112
112
- derivative (:: typeof (+ ), args:: NTuple{T,Operation} , :: Val{i} ) where {T,i} = args[i]
113
- derivative (:: typeof (+ ), args:: Tuple{Operation,Operation} , :: Val{1} ) = args[1 ]
114
- derivative (:: typeof (+ ), args:: Tuple{Operation,Operation} , :: Val{2} ) = args[2 ]
113
+ derivative (:: typeof (+ ), args:: NTuple{N,Any} , :: Val ) where {N} = 1
114
+ derivative (:: typeof (* ), args:: NTuple{N,Any} , :: Val{i} ) where {N,i} = Operation (* , deleteat! (collect (args), i))
115
115
116
116
function count_order (x)
117
117
@assert ! (x isa Symbol) " The variable $x must have an order of differentiation that is greater or equal to 1!"
0 commit comments