-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
find and replace
MPOMultiline
with MultilineMPO
- Loading branch information
1 parent
9606248
commit ce46097
Showing
16 changed files
with
82 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# MultilineMPO | ||
# ------------ | ||
""" | ||
const MultilineMPO = Multiline{<:Union{SparseMPO,DenseMPO}} | ||
Type that represents multiple lines of `MPO` objects. | ||
# Constructors | ||
MultilineMPO(mpos::AbstractVector{<:Union{SparseMPO,DenseMPO}}) | ||
MultilineMPO(Os::AbstractMatrix{<:MPOTensor}) | ||
See also: [`Multiline`](@ref), [`SparseMPO`](@ref), [`DenseMPO`](@ref) | ||
""" | ||
const MultilineMPO = Multiline{<:AbstractMPO} | ||
|
||
function MultilineMPO(Os::AbstractMatrix{T}) where {T<:MPOTensor} | ||
return MultilineMPO(map(FiniteMPO, eachrow(Os))) | ||
end | ||
function MultilineMPO(Os::PeriodicMatrix{T}) where {T<:MPOTensor} | ||
return MultilineMPO(map(InfiniteMPO, eachrow(Os))) | ||
end | ||
MultilineMPO(mpos::AbstractVector{<:AbstractMPO}) = Multiline(mpos) | ||
MultilineMPO(t::MPOTensor) = MultilineMPO(PeriodicMatrix(fill(t, 1, 1))) | ||
|
||
# allow indexing with two indices | ||
Base.getindex(t::MultilineMPO, ::Colon, j::Int) = Base.getindex.(t.data, j) | ||
Base.getindex(t::MultilineMPO, i::Int, j) = Base.getindex(t[i], j) | ||
Base.getindex(t::MultilineMPO, I::CartesianIndex{2}) = t[I.I...] | ||
|
||
# converters | ||
Base.convert(::Type{MultilineMPO}, t::AbstractMPO) = Multiline([t]) | ||
Base.convert(::Type{DenseMPO}, t::MultilineMPO{<:DenseMPO}) = only(t) | ||
Base.convert(::Type{SparseMPO}, t::MultilineMPO{<:SparseMPO}) = only(t) | ||
Base.convert(::Type{FiniteMPO}, t::MultilineMPO{<:FiniteMPO}) = only(t) | ||
Base.convert(::Type{InfiniteMPO}, t::MultilineMPO{<:InfiniteMPO}) = only(t) | ||
|
||
function Base.:*(mpo::MultilineMPO, st::MultilineMPS) | ||
size(mpo) == size(st) || throw(ArgumentError("dimension mismatch")) | ||
return Multiline(map(*, zip(mpo, st))) | ||
end | ||
|
||
function Base.:*(mpo1::MultilineMPO, mpo2::MultilineMPO) | ||
size(mpo1) == size(mpo2) || throw(ArgumentError("dimension mismatch")) | ||
return Multiline(map(*, zip(mpo1, mpo2))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters