Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify and test dispatch.jl 馃悏 馃悏 馃悏 #178

Open
odow opened this issue Nov 18, 2022 · 0 comments
Open

Simplify and test dispatch.jl 馃悏 馃悏 馃悏 #178

odow opened this issue Nov 18, 2022 · 0 comments

Comments

@odow
Copy link
Member

odow commented Nov 18, 2022

The dispatch.jl file is only 47% tested: https://app.codecov.io/gh/jump-dev/MutableArithmetics.jl/blob/master/src/dispatch.jl

We should go through, remove the old hacks

# 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 in 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 in 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

and add tests.

Once upon a time, I tried this #78.

My mistake was that I tried too much in one go and I got bogged down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant