1
- struct Differential <: Expression
1
+ struct Differential <: Function
2
2
x:: Expression
3
3
order:: Int
4
4
end
@@ -8,31 +8,30 @@ Base.show(io::IO, D::Differential) = print(io,"($(D.x),$(D.order))")
8
8
Base. Expr (D:: Differential ) = :($ (Symbol (" D_$(D. x. name) _$(D. order) " )))
9
9
10
10
function Derivative end
11
- (D:: Differential )(x:: Operation ) = Operation (Derivative, Expression[x,D ])
11
+ (D:: Differential )(x:: Operation ) = Operation (D, Expression[x])
12
12
function (D:: Differential )(x:: Variable )
13
13
D. x === x && return Constant (1 )
14
14
has_dependent (x, D. x) || return Constant (0 )
15
15
return Variable (x,D)
16
16
end
17
17
Base.:(== )(D1:: Differential , D2:: Differential ) = D1. order == D2. order && D1. x == D2. x
18
18
19
- Variable (x:: Variable ,D:: Differential ) = Variable (x. name,x. value,x. value_type,
19
+ Variable (x:: Variable , D:: Differential ) = Variable (x. name,x. value,x. value_type,
20
20
x. subtype,D,x. dependents,x. description,x. flow,x. domain,
21
21
x. size,x. context)
22
22
23
23
function expand_derivatives (O:: Operation )
24
24
@. O. args = expand_derivatives (O. args)
25
25
26
- if O. op == Derivative
27
- D = O. args[ 2 ]
26
+ if O. op isa Differential
27
+ D = O. op
28
28
o = O. args[1 ]
29
29
return simplify_constants (sum (i-> Derivative (o,i)* expand_derivatives (D (o. args[i])),1 : length (o. args)))
30
30
end
31
31
32
32
return O
33
33
end
34
34
expand_derivatives (x:: Variable ) = x
35
- expand_derivatives (D:: Differential ) = D
36
35
37
36
# Don't specialize on the function here
38
37
function Derivative (O:: Operation ,idx)
0 commit comments