Skip to content

Simplify and test dispatch.jl 🐉 🐉 🐉  #178

@odow

Description

@odow

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions