From 7b5959dd61e9171297b0f3301e9d27a69e17bde2 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 13 Nov 2023 22:45:56 +0900 Subject: [PATCH 1/4] update test cases --- test/test_ChangeBasis.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_ChangeBasis.jl b/test/test_ChangeBasis.jl index 13986ae53..197050bbf 100644 --- a/test/test_ChangeBasis.jl +++ b/test/test_ChangeBasis.jl @@ -123,13 +123,14 @@ _P8 = BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector(-[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 7, 7])) test_changebasis_I(_P7, _P8) + # (2,2)-element is stored, but it is zero. Q1 = BSplineSpace{1, Int64, KnotVector{Int64}}(KnotVector([2, 2, 4, 4, 6, 6])) Q2 = BSplineSpace{3, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 2, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7])) test_changebasis_I(Q1, Q2; check_zero=false) Q3 = BSplineSpace{4, Int64, KnotVector{Int64}}(KnotVector([1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 7])) Q4 = BSplineSpace{5, Int64, KnotVector{Int64}}(KnotVector([1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4, 4, 4, 5, 6])) - test_changebasis_I(Q3, Q4; check_zero=false) + test_changebasis_I(Q3, Q4) end @testset "changebasis_sim" begin From 4c2601f442078579d8b0585b5d424688815f280b Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 13 Nov 2023 23:03:40 +0900 Subject: [PATCH 2/4] update tests for `changebasis_R` --- test/test_ChangeBasis.jl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/test_ChangeBasis.jl b/test/test_ChangeBasis.jl index 197050bbf..a9e6be67f 100644 --- a/test/test_ChangeBasis.jl +++ b/test/test_ChangeBasis.jl @@ -1,20 +1,30 @@ @testset "ChangeBasis" begin ε = 1e-13 function test_changebasis_R(P,P′) + # The test case must hold `P ⊆ P′` @test P ⊆ P′ - A = @inferred changebasis(P,P′) + # Test type stability + A = @inferred changebasis_R(P,P′) + # Test output type @test A isa SparseMatrixCSC + # Zeros must not be stored @test !any(iszero.(A.nzval)) - @test A == BasicBSpline._changebasis_R(P,P′) == changebasis_R(P,P′) + # Test the size of `A` n = dim(P) n′ = dim(P′) @test size(A) == (n,n′) + # Elements must not be stored for degenerate row/col + for j in 1:n′ + @test any(Base.isstored.(Ref(A), 1:n, j)) == isnondegenerate_R(P2, j) + end + for i in 1:n + @test any(Base.isstored.(Ref(A), i, 1:n′)) == isnondegenerate_R(P1, i) + end + # B_{(i,p,k)} = ∑ⱼ A_{i,j} B_{(j,p′,k′)} ts = range(extrema(knotvector(P)+knotvector(P′))..., length=20) for t in ts @test norm(bsplinebasis.(P,1:n,t) - A*bsplinebasis.(P′,1:n′,t), Inf) < ε end - @test iszero(view(A, findall(BasicBSpline._iszeros_R(P)), :)) - @test iszero(view(A, :, findall(BasicBSpline._iszeros_R(P′)))) end function test_changebasis_I(P1, P2; check_zero=true) From 1b62f2e185d3fa596a096bfc98d22338d0d1aee4 Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 13 Nov 2023 23:19:39 +0900 Subject: [PATCH 3/4] update tests for `changebasis_R` --- test/test_ChangeBasis.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_ChangeBasis.jl b/test/test_ChangeBasis.jl index a9e6be67f..2edeb4cba 100644 --- a/test/test_ChangeBasis.jl +++ b/test/test_ChangeBasis.jl @@ -1,7 +1,7 @@ @testset "ChangeBasis" begin ε = 1e-13 function test_changebasis_R(P,P′) - # The test case must hold `P ⊆ P′` + # The test case must hold P ⊆ P′ @test P ⊆ P′ # Test type stability A = @inferred changebasis_R(P,P′) @@ -9,7 +9,7 @@ @test A isa SparseMatrixCSC # Zeros must not be stored @test !any(iszero.(A.nzval)) - # Test the size of `A` + # Test the size of A n = dim(P) n′ = dim(P′) @test size(A) == (n,n′) From 891f24bbdec4f68340bc9058a19d83ba15227fcd Mon Sep 17 00:00:00 2001 From: hyrodium Date: Mon, 13 Nov 2023 23:20:55 +0900 Subject: [PATCH 4/4] update tests for `changebasis_R` --- test/test_ChangeBasis.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_ChangeBasis.jl b/test/test_ChangeBasis.jl index 2edeb4cba..a254dee4e 100644 --- a/test/test_ChangeBasis.jl +++ b/test/test_ChangeBasis.jl @@ -15,10 +15,10 @@ @test size(A) == (n,n′) # Elements must not be stored for degenerate row/col for j in 1:n′ - @test any(Base.isstored.(Ref(A), 1:n, j)) == isnondegenerate_R(P2, j) + @test any(Base.isstored.(Ref(A), 1:n, j)) == isnondegenerate_R(P′, j) end for i in 1:n - @test any(Base.isstored.(Ref(A), i, 1:n′)) == isnondegenerate_R(P1, i) + @test any(Base.isstored.(Ref(A), i, 1:n′)) == isnondegenerate_R(P, i) end # B_{(i,p,k)} = ∑ⱼ A_{i,j} B_{(j,p′,k′)} ts = range(extrema(knotvector(P)+knotvector(P′))..., length=20)