From d6c092d6d73be9b41b5b8fef30d882fdb63a8d20 Mon Sep 17 00:00:00 2001 From: Daniel Karrasch Date: Tue, 11 May 2021 22:39:26 +0200 Subject: [PATCH] Add a few tests for generic LinearAlgebra (#40794) --- stdlib/LinearAlgebra/test/generic.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdlib/LinearAlgebra/test/generic.jl b/stdlib/LinearAlgebra/test/generic.jl index f3ef87da83052..92baaa6363b4f 100644 --- a/stdlib/LinearAlgebra/test/generic.jl +++ b/stdlib/LinearAlgebra/test/generic.jl @@ -142,6 +142,10 @@ end @testset "Scaling with 5-argument mul!" begin @test mul!(copy(a), 5., a, 10, 100) == a*150 @test mul!(copy(a), a, 5., 10, 100) == a*150 + @test mul!(vec(copy(a)), 5., a, 10, 100) == vec(a*150) + @test mul!(vec(copy(a)), a, 5., 10, 100) == vec(a*150) + @test_throws DimensionMismatch mul!([vec(copy(a)); 0], 5., a, 10, 100) + @test_throws DimensionMismatch mul!([vec(copy(a)); 0], a, 5., 10, 100) @test mul!(copy(a), Diagonal([1.; 2.]), a, 10, 100) == 10a.*[1; 2] .+ 100a @test mul!(copy(a), Diagonal([1; 2]), a, 10, 100) == 10a.*[1; 2] .+ 100a @test mul!(copy(a), a, Diagonal(1.:an), 10, 100) == 10a.*Vector(1:an)' .+ 100a @@ -189,6 +193,7 @@ end @test det(a) == a @test norm(a) == abs(a) @test norm(a, 0) == 1 + @test norm(0, 0) == 0 end @test !issymmetric(NaN16) @@ -241,12 +246,14 @@ end rotate!(x, y, c, s) @test x ≈ c*x2 + s*y2 @test y ≈ -conj(s)*x2 + c*y2 + @test_throws DimensionMismatch rotate!([x; x], y, c, s) x3 = copy(x) y3 = copy(y) reflect!(x, y, c, s) @test x ≈ c*x3 + s*y3 @test y ≈ conj(s)*x3 - c*y3 + @test_throws DimensionMismatch reflect!([x; x], y, c, s) end @testset "LinearAlgebra.axp(b)y! for element type without commutative multiplication" begin @@ -270,6 +277,7 @@ end ry = [2 8] @test LinearAlgebra.axpy!(α, x, rx, y, ry) == [1 1 1 1; 11 1 1 26] end + @testset "norm and normalize!" begin vr = [3.0, 4.0] for Tr in (Float32, Float64)