Jutho/TensorKit.jl

Feature request: `convert` methods for `AdjointTensorMap` -> `TensorMap` and changing `eltype`

mhauru opened this issue · 1 comments

Possible implementations:

Base.convert(::Type{TensorMap}, t::TensorKit.AdjointTensorMap) = copy(t)
function Base.convert(::Type{TensorMap{S, N1, N2, G, A, F1, F2}},
                      t::TensorKit.AdjointTensorMap{S, N1, N2, G, A, F1, F2}
                     ) where {S, N1, N2, G, A, F1, F2}
    return convert(TensorMap, t)
end

function Base.convert(::Type{TensorMap{S, N1, N2, G, Matrix{E1}, F1, F2}},
                      t::TensorMap{S, N1, N2, G, Matrix{E2}, F1, F2}
                     ) where {S, N1, N2, G, E1, E2, F1, F2}
    return copyto!(similar(t, E1), t)
end

function Base.convert(::Type{TensorMap{S, N1, N2, G, TensorKit.SectorDict{G, Matrix{E1}}, F1, F2}},
                      t::TensorMap{S, N1, N2, G, TensorKit.SectorDict{G, Matrix{E2}}, F1, F2}
                     ) where {S, N1, N2, G, E1, E2, F1, F2}
    return copyto!(similar(t, E1), t)
end
Jutho commented

This is now implemented, so I'll close