From e335fa6ef9df03eaef697fdc97279d41ea4f8394 Mon Sep 17 00:00:00 2001 From: Andy Zhang <37402126+AnzhiZhang@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:57:47 +0100 Subject: [PATCH] test(matrices): add forsythe tests --- test/matrices/forsythe.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/matrices/forsythe.jl diff --git a/test/matrices/forsythe.jl b/test/matrices/forsythe.jl new file mode 100644 index 0000000..936519b --- /dev/null +++ b/test/matrices/forsythe.jl @@ -0,0 +1,18 @@ +# constructors +@test allequal([ + Forsythe(5), + Forsythe{Float64}(5), + Forsythe(5, sqrt(eps(Float64)), zero(Float64)), + Forsythe{Float64}(5, sqrt(eps(Float64)), zero(Float64)), +]) + +# linear algebra functions +test_linearalgrbra_functions(Forsythe.(1:5)) + +# eltype +@test test_matrix_elements(Forsythe{Float32}(5)) + +# content +@test Forsythe(5) ≈ [0.0 1.0 0.0 0.0 0.0; 0.0 0.0 1.0 0.0 0.0; 0.0 0.0 0.0 1.0 0.0; 0.0 0.0 0.0 0.0 1.0; 1.4901161193847656e-8 0.0 0.0 0.0 0.0] +@test Forsythe(5, 2, 3) ≈ [3.0 1.0 0.0 0.0 0.0; 0.0 3.0 1.0 0.0 0.0; 0.0 0.0 3.0 1.0 0.0; 0.0 0.0 0.0 3.0 1.0; 2.0 0.0 0.0 0.0 3.0] +@test Forsythe(5, 3, -5) ≈ [-5.0 1.0 0.0 0.0 0.0; 0.0 -5.0 1.0 0.0 0.0; 0.0 0.0 -5.0 1.0 0.0; 0.0 0.0 0.0 -5.0 1.0; 3.0 0.0 0.0 0.0 -5.0]