@@ -2,29 +2,38 @@ using LinearMaps, LinearAlgebra, Test
22
33@testset " filled maps" begin
44 M, N = 2 , 3
5- α = rand ()
6- β = rand ()
75 μ = rand ()
86 for λ in (true , false , 3 , μ, μ + 2im )
97 L = LinearMap (λ, (M, N))
8+ @test L == LinearMap (λ, M, N)
9+ @test LinearMaps. MulStyle (L) === LinearMaps. FiveArg ()
1010 A = fill (λ, (M, N))
1111 x = rand (typeof (λ) <: Real ? Float64 : ComplexF64, 3 )
12- X = rand (typeof (λ) <: Real ? Float64 : ComplexF64, 3 , 3 )
12+ X = rand (typeof (λ) <: Real ? Float64 : ComplexF64, 3 , 4 )
1313 w = similar (x, 2 )
14- W = similar (X, 2 , 3 )
14+ W = similar (X, 2 , 4 )
1515 @test size (L) == (M, N)
1616 @test adjoint (L) == LinearMap (adjoint (λ), (3 ,2 ))
1717 @test transpose (L) == LinearMap (λ, (3 ,2 ))
1818 @test Matrix (L) == A
1919 @test L * x ≈ A * x
2020 @test mul! (w, L, x) ≈ A * x
2121 @test mul! (W, L, X) ≈ A * X
22- @test mul! (copy (w), L, x, α, β) ≈ A * x * α + w * β
23- @test mul! (copy (W), L, X, α, β) ≈ A * X * α + W * β
22+ for α in (true , false , 1 , 0 , randn ()), β in (true , false , 1 , 0 , randn ())
23+ @test mul! (copy (w), L, x, α, β) ≈ fill (λ * sum (x) * α, M) + w * β
24+ @test mul! (copy (W), L, X, α, β) ≈ λ * reduce (vcat, sum (X, dims= 1 ) for _ in 1 : 2 ) * α + W * β
25+ end
2426 end
25- @test issymmetric (LinearMap (μ + 0im , (3 , 3 )))
27+ @test issymmetric (LinearMap (μ + 1im , (3 , 3 )))
28+ @test ishermitian (LinearMap (μ + 0im , (3 , 3 )))
29+ @test isposdef (LinearMap (μ, (1 ,1 ))) == isposdef (μ)
30+ @test ! isposdef (LinearMap (μ, (3 ,3 )))
31+ α = rand ()
32+ β = rand ()
2633 @test LinearMap (μ, (M, N)) + LinearMap (α, (M, N)) == LinearMap (μ + α, (M, N))
2734 @test LinearMap (μ, (M, N)) - LinearMap (α, (M, N)) == LinearMap (μ - α, (M, N))
2835 @test α* LinearMap (μ, (M, N)) == LinearMap (α * μ, (M, N))
2936 @test LinearMap (μ, (M, N))* α == LinearMap (μ * α, (M, N))
37+ @test LinearMap (μ, (M, N))* LinearMap (μ, (N, M)) == LinearMap (μ^ 2 * N, (M, M))
38+ @test Matrix (LinearMap (μ, (M, N))* LinearMap (μ, (N, M))) == fill (μ, (M, N))* fill (μ, (N, M))
3039end
0 commit comments