@@ -13,26 +13,26 @@ colors = matrix_colors(tril(sparsity))
1313ncolors = maximum (colors)
1414D = hcat ([float .(i .== colors) for i in 1 : ncolors]. .. )
1515buffer = similar (D)
16- G = zero (x)
17- dG = zero (x)
16+ G1 = zero (x)
17+ G2 = zero (x)
1818
1919buffers_tup = SparseDiffTools. make_hessian_buffers (colors, x)
2020@test buffers_tup. ncolors == ncolors
2121@test buffers_tup. D == D
2222@test size (buffers_tup. buffer) == size (buffer)
2323@test eltype (buffers_tup. buffer) == eltype (buffer)
2424@test typeof (buffers_tup. buffer) == typeof (buffer)
25- @test size (buffers_tup. G ) == size (G )
26- @test eltype (buffers_tup. G ) == eltype (G )
27- @test size (buffers_tup. dG ) == size (dG )
28- @test eltype (buffers_tup. dG ) == eltype (dG )
25+ @test size (buffers_tup. G1 ) == size (G1 )
26+ @test eltype (buffers_tup. G1 ) == eltype (G1 )
27+ @test size (buffers_tup. G2 ) == size (G2 )
28+ @test eltype (buffers_tup. G2 ) == eltype (G2 )
2929
3030
3131gconfig = ForwardDiff. GradientConfig (fscalar, x)
3232g (x) = ForwardDiff. gradient (fscalar, x) # allocating
3333g! (G, x, gconfig) = ForwardDiff. gradient! (G, fscalar, x, gconfig) # non-allocating
3434
35- hescache1 = ForwardColorHesCache (sparsity, colors, ncolors, D, buffer, g!, gconfig, G, dG )
35+ hescache1 = ForwardColorHesCache (sparsity, colors, ncolors, D, buffer, g!, gconfig, G1, G2 )
3636hescache2 = ForwardColorHesCache (fscalar, x, colors, sparsity, g!)
3737hescache3 = ForwardColorHesCache (fscalar, x, colors, sparsity)
3838# custom gradient function
@@ -53,7 +53,7 @@ for name in [:sparsity, :colors, :ncolors, :D]
5353 # hescache5 is the default dense version, so only first axis will match
5454 @eval @test size (hescache1.$ name, 1 ) == size (hescache5.$ name, 1 )
5555end
56- for name in [:buffer , :G , :dG ]
56+ for name in [:buffer , :G1 , :G2 ]
5757 @eval @test size (hescache1.$ name) == size (hescache2.$ name)
5858 @eval @test size (hescache1.$ name) == size (hescache3.$ name)
5959 @eval @test size (hescache1.$ name) == size (hescache4.$ name)
@@ -71,9 +71,9 @@ for (i, hescache) in enumerate([hescache1, hescache2, hescache3, hescache4, hesc
7171 H = numauto_color_hessian (fscalar, x, colors, sparsity)
7272 H1 = numauto_color_hessian (fscalar, x, hescache)
7373 H2 = numauto_color_hessian (fscalar, x)
74- @test all (isapprox .(Hforward, H, rtol= 1e-4 ))
75- @test all (isapprox .(H, H1, rtol= 1e-4 ))
76- @test all (isapprox .(H2, H1, rtol= 1e-4 ))
74+ @test all (isapprox .(Hforward, H, rtol= 1e-6 ))
75+ @test all (isapprox .(H, H1, rtol= 1e-6 ))
76+ @test all (isapprox .(H2, H1, rtol= 1e-6 ))
7777
7878 H1 = similar (H)
7979 numauto_color_hessian! (H1, fscalar, x, collect (hescache. colors), hescache. sparsity)
0 commit comments