Skip to content

Commit

Permalink
Fix for Julia v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 12, 2019
1 parent 54ebc04 commit a8521cf
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,24 @@ end
function Base.Matrix(x::LinearAlgebra.LowerTriangular{T}) where T<:AbstractMutable
return Matrix{promote_type(promote_operation(zero, T), T)}(x)
end

# Needed for Julia v1.1 only. If `parent(A)` is for instance `Diagonal`, the
# `eltype` of `B` might be different form the `eltype` of `A`.
function Matrix(A::LinearAlgebra.Symmetric{<:AbstractMutable})
B = LinearAlgebra.copytri!(convert(Matrix, copy(A.data)), A.uplo)
for i = 1:size(A, 1)
# `B[i, i]` is used instead of `A[i, i]` on Julia v1.1 hence the need
# to overwrite it for `AbstractMutable`.
B[i,i] = LinearAlgebra.symmetric(A[i,i], LinearAlgebra.sym_uplo(A.uplo))::LinearAlgebra.symmetric_type(eltype(A.data))
end
return B
end
function Matrix(A::LinearAlgebra.Hermitian{<:AbstractMutable})
B = LinearAlgebra.copytri!(convert(Matrix, copy(A.data)), A.uplo, true)
for i = 1:size(A, 1)
# `B[i, i]` is used instead of `A[i, i]` on Julia v1.1 hence the need
# to overwrite it for `AbstractMutable`.
B[i,i] = LinearAlgebra.hermitian(A[i,i], LinearAlgebra.sym_uplo(A.uplo))::LinearAlgebra.hermitian_type(eltype(A.data))
end
return B
end

2 comments on commit a8521cf

@blegat
Copy link
Member Author

@blegat blegat commented on a8521cf Dec 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/6614

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" a8521cf69b8e2a904c16ecff06f3d7bc8410d2d1
git push origin v0.1.0

Please sign in to comment.