1+ using LinearAlgebra, OrdinaryDiffEq, Test, PreallocationTools, ForwardDiff, LabelledArrays, RecursiveArrayTools
2+
3+ # Base Array tests
4+ chunk_size = 5
5+ u0_B = ones (5 , 5 )
6+ dual_B = zeros (ForwardDiff. Dual{ForwardDiff. Tag{typeof (something), Float64}, Float64, chunk_size}, 2 , 2 )
7+ cache_B = dualcache (u0_B, chunk_size)
8+ tmp_du_BA = get_tmp (cache_B, u0_B)
9+ tmp_dual_du_BA = get_tmp (cache_B, dual_B)
10+ tmp_du_BN = get_tmp (cache_B, u0_B[1 ])
11+ tmp_dual_du_BN = get_tmp (cache_B, dual_B[1 ])
12+ @test size (tmp_du_BA) == size (u0_B)
13+ @test typeof (tmp_du_BA) == typeof (u0_B)
14+ @test eltype (tmp_du_BA) == eltype (u0_B)
15+ @test size (tmp_dual_du_BA) == size (u0_B)
16+ @test typeof (tmp_dual_du_BA) == typeof (dual_B)
17+ @test eltype (tmp_dual_du_BA) == eltype (dual_B)
18+ @test size (tmp_du_BN) == size (u0_B)
19+ @test typeof (tmp_du_BN) == typeof (u0_B)
20+ @test eltype (tmp_du_BN) == eltype (u0_B)
21+ @test size (tmp_dual_du_BN) == size (u0_B)
22+ @test typeof (tmp_dual_du_BN) == typeof (dual_B)
23+ @test eltype (tmp_dual_du_BN) == eltype (dual_B)
24+
25+ # LArray tests
26+ chunk_size = 4
27+ u0_L = LArray ((2 ,2 ); a= 1.0 , b= 1.0 , c= 1.0 , d= 1.0 )
28+ zerodual = zero (ForwardDiff. Dual{ForwardDiff. Tag{typeof (something), Float64}, Float64, chunk_size})
29+ dual_L = LArray ((2 ,2 ); a= zerodual, b= zerodual, c= zerodual, d= zerodual)
30+ cache_L = dualcache (u0_L, chunk_size)
31+ tmp_du_LA = get_tmp (cache_L, u0_L)
32+ tmp_dual_du_LA = get_tmp (cache_L, dual_L)
33+ tmp_du_LN = get_tmp (cache_L, u0_L[1 ])
34+ tmp_dual_du_LN = get_tmp (cache_L, dual_L[1 ])
35+ @test size (tmp_du_LA) == size (u0_L)
36+ @test typeof (tmp_du_LA) == typeof (u0_L)
37+ @test eltype (tmp_du_LA) == eltype (u0_L)
38+ @test size (tmp_dual_du_LA) == size (u0_L)
39+ @test typeof (tmp_dual_du_LA) == typeof (dual_L)
40+ @test eltype (tmp_dual_du_LA) == eltype (dual_L)
41+ @test size (tmp_du_LN) == size (u0_L)
42+ @test typeof (tmp_du_LN) == typeof (u0_L)
43+ @test eltype (tmp_du_LN) == eltype (u0_L)
44+ @test size (tmp_dual_du_LN) == size (u0_L)
45+ @test typeof (tmp_dual_du_LN) == typeof (dual_L)
46+ @test eltype (tmp_dual_du_LN) == eltype (dual_L)
47+
48+ # ArrayPartition tests
49+ u0_AP = ArrayPartition (ones (2 ,2 ), ones (3 ,3 ))
50+ dual_a = zeros (ForwardDiff. Dual{ForwardDiff. Tag{typeof (something), Float64}, Float64, chunk_size}, 2 , 2 )
51+ dual_b = zeros (ForwardDiff. Dual{ForwardDiff. Tag{typeof (something), Float64}, Float64, chunk_size}, 3 , 3 )
52+ dual_AP = ArrayPartition (dual_a, dual_b)
53+ cache_AP = dualcache (u0_AP, chunk_size)
54+ tmp_du_APA = get_tmp (cache_AP, u0_AP)
55+ tmp_dual_du_APA = get_tmp (cache_AP, dual_AP)
56+ tmp_du_APN = get_tmp (cache_AP, u0_AP[1 ])
57+ tmp_dual_du_APN = get_tmp (cache_AP, dual_AP[1 ])
58+ @test size (tmp_du_APA) == size (u0_AP)
59+ @test typeof (tmp_du_APA) == typeof (u0_AP)
60+ @test eltype (tmp_du_APA) == eltype (u0_AP)
61+ @test size (tmp_dual_du_APA) == size (u0_AP)
62+ @test typeof (tmp_dual_du_APA) == typeof (dual_AP)
63+ @test eltype (tmp_dual_du_APA) == eltype (dual_AP)
64+ @test size (tmp_du_APN) == size (u0_AP)
65+ @test typeof (tmp_du_APN) == typeof (u0_AP)
66+ @test eltype (tmp_du_APN) == eltype (u0_AP)
67+ @test size (tmp_dual_du_APN) == size (u0_AP)
68+ @test typeof (tmp_dual_du_APN) == typeof (dual_AP)
69+ @test eltype (tmp_dual_du_APN) == eltype (dual_AP)
0 commit comments