Skip to content

Commit 2482e26

Browse files
perrutquistdkarrasch
authored andcommitted
bugfix: return correct size of BlockMap involving zero-size blocks (#70)
1 parent c435822 commit 2482e26

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/blockmap.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ function rowcolranges(maps, rows)::Tuple{Vector{UnitRange{Int}},Vector{UnitRange
4747
return rowranges, colranges
4848
end
4949

50-
function Base.size(A::BlockMap)
51-
return A.rowranges[end][end], A.colranges[end][end]
52-
end
50+
Base.size(A::BlockMap) = (last(A.rowranges[end]), last(A.colranges[end]))
5351

5452
############
5553
# hcat

test/blockmap.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ using Test, LinearMaps, LinearAlgebra
22

33
@testset "block maps" begin
44
@testset "hcat" begin
5-
for elty in (Float32, Float64, ComplexF64)
5+
for elty in (Float32, Float64, ComplexF64), n2 = (0, 20)
66
A11 = rand(elty, 10, 10)
7-
A12 = rand(elty, 10, 20)
7+
A12 = rand(elty, 10, n2)
88
L = @inferred hcat(LinearMap(A11), LinearMap(A12))
99
@test L isa LinearMaps.BlockMap{elty}
1010
A = [A11 A12]
11-
x = rand(30)
11+
x = rand(10+n2)
1212
@test size(L) == size(A)
1313
@test Matrix(L) A
1414
@test L * x A * x
@@ -22,7 +22,7 @@ using Test, LinearMaps, LinearAlgebra
2222
@test L isa LinearMaps.BlockMap{elty}
2323
@test L * x A * x
2424
A11 = rand(elty, 11, 10)
25-
A12 = rand(elty, 10, 20)
25+
A12 = rand(elty, 10, n2)
2626
@test_throws DimensionMismatch hcat(LinearMap(A11), LinearMap(A12))
2727
end
2828
end

0 commit comments

Comments
 (0)