diff --git a/src/operators/mpomultiline.jl b/src/operators/mpomultiline.jl index f50e231d..07fcaa86 100644 --- a/src/operators/mpomultiline.jl +++ b/src/operators/mpomultiline.jl @@ -13,9 +13,7 @@ See also: [`Multiline`](@ref), [`SparseMPO`](@ref), [`DenseMPO`](@ref) """ const MPOMultiline = Multiline{<:Union{SparseMPO,DenseMPO}} -function MPOMultiline(Os::AbstractMatrix{<:MPOTensor}) - return MPOMultiline(data, map(DenseMPO, eachrow(Os))) -end +MPOMultiline(Os::AbstractMatrix{<:MPOTensor}) = MPOMultiline(map(DenseMPO, eachrow(Os))) MPOMultiline(mpos::AbstractVector{<:Union{SparseMPO,DenseMPO}}) = Multiline(mpos) MPOMultiline(t::MPOTensor) = MPOMultiline(fill(t, 1, 1)) diff --git a/src/states/mpsmultiline.jl b/src/states/mpsmultiline.jl index dd1fbf8a..e8f0845d 100644 --- a/src/states/mpsmultiline.jl +++ b/src/states/mpsmultiline.jl @@ -18,7 +18,9 @@ See also: [`Multiline`](@ref) """ const MPSMultiline = Multiline{<:InfiniteMPS} MPSMultiline(mpss::AbstractVector{<:InfiniteMPS}) = Multiline(mpss) -function MPSMultiline(pspaces::AbstractMatrix{S}, Dspaces::AbstractMatrix{S}; kwargs...) where {S<:VectorSpace} +function MPSMultiline( + pspaces::AbstractMatrix{S}, Dspaces::AbstractMatrix{S}; kwargs... +) where {S<:VectorSpace} data = map(eachrow(pspaces), eachrow(Dspaces)) do (p, D) return InfiniteMPS(p, D; kwargs...) end @@ -30,8 +32,9 @@ function MPSMultiline(As::AbstractMatrix{T}; kwargs...) where {T<:GenericMPSTens end return MPSMultiline(data) end -function MPSMultiline(ALs::AbstractMatrix{<:GenericMPSTensor}, - C₀::AbstractVector{<:MPSBondTensor}; kwargs...) +function MPSMultiline( + ALs::AbstractMatrix{<:GenericMPSTensor}, C₀::AbstractVector{<:MPSBondTensor}; kwargs... +) data = map(eachrow(ALs), C₀) do ALrow, C₀row return InfiniteMPS(ALrow, C₀row; kwargs...) end diff --git a/src/utility/multiline.jl b/src/utility/multiline.jl index 93d51201..70e769fe 100644 --- a/src/utility/multiline.jl +++ b/src/utility/multiline.jl @@ -39,3 +39,4 @@ function Base.circshift(A::Multiline, shifts::Tuple{Int,Int}) return Multiline(circshift!(data′, shifts[1])) end Base.reverse(A::Multiline) = Multiline(reverse(parent(A))) +Base.only(A::Multiline) = only(parent(A)) diff --git a/src/utility/utility.jl b/src/utility/utility.jl index ce48b6de..1a9a1df4 100644 --- a/src/utility/utility.jl +++ b/src/utility/utility.jl @@ -142,4 +142,4 @@ end # check all elements are equal -> only defined in 1.8+ @static if !isdefined(Base, :allequal) allequal(itr) = isempty(itr) ? true : all(isequal(first(itr)), itr) -end \ No newline at end of file +end