Skip to content

Commit 171b208

Browse files
committed
improve coverage
1 parent 05333f3 commit 171b208

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

src/LinearMaps.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ LinearMap(f, M::Int; kwargs...) = LinearMap{Float64}(f, M; kwargs...)
284284
LinearMap(f, M::Int, N::Int; kwargs...) = LinearMap{Float64}(f, M, N; kwargs...)
285285
LinearMap(f, fc, M::Int; kwargs...) = LinearMap{Float64}(f, fc, M; kwargs...)
286286
LinearMap(f, fc, M::Int, N::Int; kwargs...) = LinearMap{Float64}(f, fc, M, N; kwargs...)
287-
LinearMap::Number, M::Int, N::Int) = LinearMap(λ, (M, N))
287+
LinearMap::Number, M::Int, N::Int) = FillMap(λ, (M, N))
288288
LinearMap::Number, dims::Dims{2}) = FillMap(λ, dims)
289289

290290
LinearMap{T}(A::MapOrMatrix; kwargs...) where {T} = WrappedMap{T}(A; kwargs...)

test/fillmap.jl

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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))
3039
end

test/numbertypes.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ using Test, LinearMaps, LinearAlgebra, Quaternions
4545
@test M == (L * L * γ) * β == (L * L * α) * β == (L * L * α) * β.λ
4646
@test length(M.maps) == 3
4747
@test M.maps[1].λ == γ*β.λ
48+
@test γ*LinearMap(γ, (3, 4)) == LinearMap^2, (3, 4)) == LinearMap(γ, (3, 4))*γ
4849

4950
# exercise non-RealOrComplex scalar operations
5051
@test Array* (L'*L)) γ * (A'*A) # CompositeMap

0 commit comments

Comments
 (0)