22
22
@test π₯―[TaylorTangentIndex (2 )]. x == 10.0
23
23
end
24
24
25
- function double! (val:: MDemo1 )
26
- val. x *= 2.0
27
- return val
25
+ @testset " basis struct work" begin
26
+ function double! (val:: MDemo1 )
27
+ val. x *= 2.0
28
+ return val
29
+ end
30
+ function wrap_and_double (x)
31
+ val = MDemo1 (x)
32
+ double! (val)
33
+ end
34
+ # first derivative
35
+ π° = ββ {1} ()(ZeroBundle {1} (wrap_and_double), TaylorBundle {1} (1.5 , (1.0 ,)))
36
+ @test first_partial (π°) isa MutableTangent{MDemo1}
37
+ @test first_partial (π°). x == 2.0
38
+
39
+ # second derivative
40
+ π = ββ {2} ()(ZeroBundle {2} (wrap_and_double), TaylorBundle {2} (1.5 , (1.0 , 0.0 )))
41
+ @test π[TaylorTangentIndex (1 )] isa MutableTangent{MDemo1}
42
+ @test π[TaylorTangentIndex (1 )]. x == 2.0
43
+ @test π[TaylorTangentIndex (2 )] isa MutableTangent
44
+ @test π[TaylorTangentIndex (2 )]. x == 0.0 # returns 20
28
45
end
29
- function wrap_and_double (x)
30
- val = MDemo1 (x)
31
- double! (val)
32
- end
33
- π° = ββ {1} ()(ZeroBundle {1} (wrap_and_double), TaylorBundle {1} (1.5 , (1.0 ,)))
34
- @test first_partial (π°) isa MutableTangent{MDemo1}
35
- @test first_partial (π°). x == 2.0
36
-
37
- # second derivative
38
- π = ββ {2} ()(ZeroBundle {2} (wrap_and_double), TaylorBundle {2} (1.5 , (1.0 , 10.0 )))
39
- @test π[TaylorTangentIndex (1 )] isa MutableTangent{MDemo1}
40
- @test π[TaylorTangentIndex (1 )]. x == 2.0
41
- @test π[TaylorTangentIndex (2 )] isa MutableTangent
42
- @test π[TaylorTangentIndex (2 )] == 0.0 # returns 20
43
-
44
46
45
47
46
- foo (val) = val^ 2
47
- π₯ = ββ {2} ()(ZeroBundle {2} (foo), TaylorBundle {2} (1.0 , (0.0 , 10.0 )))
48
- π₯[TaylorTangentIndex (1 )] # returns 0
49
- π₯[TaylorTangentIndex (2 )] # returns 20
50
48
51
49
# end # module
0 commit comments