comparison test/SbpOperators/stencil_test.jl @ 826:4433be383840 operator_storage_array_of_table

Add stencil constructor to change the type of the weights along with a convert method
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 21 Dec 2021 16:30:16 +0100
parents 6114274447f5
children 313648b01504 11767fbb29f4
comparison
equal deleted inserted replaced
825:69700b0b1452 826:4433be383840
13 @test Stencil(1,2,3,4; center=2) == Stencil((-1, 2),(1,2,3,4)) 13 @test Stencil(1,2,3,4; center=2) == Stencil((-1, 2),(1,2,3,4))
14 @test Stencil(1,2,3,4; center=4) == Stencil((-3, 0),(1,2,3,4)) 14 @test Stencil(1,2,3,4; center=4) == Stencil((-3, 0),(1,2,3,4))
15 15
16 @test CenteredStencil(1,2,3,4,5) == Stencil((-2, 2), (1,2,3,4,5)) 16 @test CenteredStencil(1,2,3,4,5) == Stencil((-2, 2), (1,2,3,4,5))
17 @test_throws ArgumentError CenteredStencil(1,2,3,4) 17 @test_throws ArgumentError CenteredStencil(1,2,3,4)
18
19 # Changing the type of the weights
20 @test Stencil{Float64}(Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2)
21 @test Stencil{Float64}(CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.)
22 @test Stencil{Int}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2)
23 @test Stencil{Rational}(Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2)
24
25 @testset "convert" begin
26 @test convert(Stencil{Float64}, Stencil(1,2,3,4,5; center=2)) == Stencil(1.,2.,3.,4.,5.; center=2)
27 @test convert(Stencil{Float64}, CenteredStencil(1,2,3,4,5)) == CenteredStencil(1.,2.,3.,4.,5.)
28 @test convert(Stencil{Int}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1,2,3,4,5; center=2)
29 @test convert(Stencil{Rational}, Stencil(1.,2.,3.,4.,5.; center=2)) == Stencil(1//1,2//1,3//1,4//1,5//1; center=2)
30 end
18 end 31 end