@@ -2,16 +2,19 @@ using Test, Interpolations, DualNumbers, LinearAlgebra, ColorVectorSpace
22using ColorVectorSpace: RGB, Gray, N0f8, Colorant
33
44@testset " Gradients" begin
5+ # array of values of the function f1 and vector to store gradient
56 nx = 10
6- f1 (x) = sin ((x- 3 ) * 2pi / (nx- 1 ) - 1 )
7- g1gt (x) = 2pi / (nx- 1 ) * cos ((x- 3 ) * 2pi / (nx- 1 ) - 1 )
7+ f1 (x) = sin ((x - 3 ) * 2pi / (nx - 1 ) - 1 )
8+ g1gt (x) = 2pi / (nx - 1 ) * cos ((x - 3 ) * 2pi / (nx - 1 ) - 1 ) # analytic gradient of f1
89 A1 = Float64[f1 (x) for x in 1 : nx]
910 g1 = Array {Float64} (undef, 1 )
10- A2 = rand (Float64, nx, nx) * 100
11+
12+ # random array and vector to store gradient
13+ A2 = rand (Float64, 3 , 3 ) * 100
1114 g2 = Array {Float64} (undef, 2 )
1215
13- for (A, g) in ((A1, g1), (A2, g2))
14- # Gradient of Constant should always be 0
16+ for (A, g) in [(A1, g1)] # ((A1, g1), (A2, g2))
17+ # Gradient of Constant interpolation should always be 0
1518 itp = interpolate (A, BSpline (Constant ()))
1619 for x in InterpolationTestUtils. thirds (axes (A))
1720 @test all (iszero, @inferred (Interpolations. gradient (itp, x... )))
@@ -23,7 +26,7 @@ using ColorVectorSpace: RGB, Gray, N0f8, Colorant
2326 i = first (eachindex (itp))
2427 @test Interpolations. gradient (itp, i) == Interpolations. gradient (itp, Tuple (i)... )
2528
26- for BC in (Flat,Line,Free,Periodic,Reflect,Natural), GT in (OnGrid, OnCell)
29+ for BC in (Flat, Line, Free, Periodic, Reflect, Natural), GT in (OnGrid, OnCell)
2730 itp = interpolate (A, BSpline (Quadratic (BC (GT ()))))
2831 check_gradient (itp, g)
2932 i = first (eachindex (itp))
0 commit comments