Skip to content

Commit 90c600d

Browse files
committed
add tests
1 parent 0bad761 commit 90c600d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/fillmap.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using LinearMaps, LinearAlgebra, Test
2+
3+
@testset "filled maps" begin
4+
M, N = 2, 3
5+
α = rand()
6+
β = rand()
7+
μ = rand()
8+
for λ in (true, false, 3, μ, μ + 2im)
9+
L = LinearMap(λ, (M, N))
10+
A = fill(λ, (M, N))
11+
x = rand(typeof(λ) <: Real ? Float64 : ComplexF64, 3)
12+
X = rand(typeof(λ) <: Real ? Float64 : ComplexF64, 3, 3)
13+
w = similar(x, 2)
14+
W = similar(X, 2, 3)
15+
@test size(L) == (M, N)
16+
@test adjoint(L) == LinearMap(adjoint(λ), (3,2))
17+
@test transpose(L) == LinearMap(λ, (3,2))
18+
@test Matrix(L) == A
19+
@test L * x A * x
20+
@test mul!(w, L, x) A * x
21+
@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 * β
24+
end
25+
@test issymmetric(LinearMap+ 0im, (3, 3)))
26+
@test LinearMap(μ, (M, N)) + LinearMap(α, (M, N)) == LinearMap+ α, (M, N))
27+
@test LinearMap(μ, (M, N)) - LinearMap(α, (M, N)) == LinearMap- α, (M, N))
28+
@test α*LinearMap(μ, (M, N)) == LinearMap* μ, (M, N))
29+
@test LinearMap(μ, (M, N))*α == LinearMap* α, (M, N))
30+
end

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ include("kronecker.jl")
3030
include("conversion.jl")
3131

3232
include("left.jl")
33+
34+
include("fillmap.jl")

0 commit comments

Comments
 (0)