Skip to content

Commit 3ac9c89

Browse files
mjp98dkarraschmzgubic
authored
Fix method ambiguity for * between Adjoint or Transpose and BlockDiagonal with different eltype (#122)
* Add erroring test * Edit comment * Add fix * Bump version * Avoid specifying type parameters where possible Co-authored-by: Daniel Karrasch <[email protected]> * Avoid specifying type parameters for `*Transpose` * Make issue description in comment more specific Co-authored-by: Miha Zgubic <[email protected]> Co-authored-by: Daniel Karrasch <[email protected]> Co-authored-by: Miha Zgubic <[email protected]>
1 parent 86c57e3 commit 3ac9c89

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BlockDiagonals"
22
uuid = "0a1fb500-61f7-11e9-3c65-f5ef3456f9f0"
33
authors = ["Invenia Technical Computing Corporation"]
4-
version = "0.1.39"
4+
version = "0.1.40"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/base_maths.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ function Base.:*(M::Diagonal{T}, B::BlockDiagonal{T2})::BlockDiagonal where {T,
162162
return A
163163
end
164164

165-
function Base.:*(vt::Adjoint{T,<: AbstractVector}, B::BlockDiagonal{T}) where {T}
165+
function Base.:*(vt::Adjoint{<:Any,<:AbstractVector}, B::BlockDiagonal)
166166
return (B' * parent(vt))'
167167
end
168168

169-
function Base.:*(vt::Transpose{T,<: AbstractVector}, B::BlockDiagonal{T}) where {T}
169+
function Base.:*(vt::Transpose{<:Any,<:AbstractVector}, B::BlockDiagonal)
170170
return transpose(transpose(B) * parent(vt))
171171
end
172172

test/base_maths.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ using Test
1919
b64 = BlockDiagonal([rand(rng, 2, 2), rand(rng, 2, 2)])
2020
b32 = BlockDiagonal([rand(rng, Float32, 2, 2), rand(rng, Float32, 2, 2)])
2121

22+
bi = BlockDiagonal([zeros(Int, N1, N1), zeros(Int, N2, N2), zeros(Int, N3, N3)])
23+
2224
bns = BlockDiagonal([rand(rng, N1, N2), rand(rng, N2, N3), rand(rng, N3, N1)])
2325

2426
@testset "Addition" begin
@@ -120,6 +122,8 @@ using Test
120122
@test transpose(a) * b1 isa Transpose{<:Number, <:Vector}
121123
@test a' * b1 a' * Matrix(b1)
122124
@test transpose(a) * b1 transpose(a) * Matrix(b1)
125+
# Method ambiguity with different eltypes https://github.com/invenia/BlockDiagonals.jl/issues/91
126+
@test a' * bi isa Adjoint{<:Number, <:Vector}
123127
end
124128

125129
@testset "BlockDiagonal * Matrix" begin

0 commit comments

Comments
 (0)