@@ -123,22 +123,28 @@ similarstoragetype(::Type{D}, ::Type{T}) where {D <: AbstractDict{<:Sector, <:Ab
123123similarstoragetype (:: Type{T} ) where {T <: Number } = Vector{T}
124124
125125@doc """
126- promote_storagetype([T], A, B)
127- promote_storagetype([T], TA, TB)
126+ promote_storagetype([T], A, B, C... )
127+ promote_storagetype([T], TA, TB, TC... )
128128
129129Determine an appropriate storage type for the combination of tensors `A` and `B`, or tensors of type `TA` and `TB`.
130130Optionally, a scalartype `T` for the destination can be supplied that might differ from the inputs.
131131""" promote_storagetype
132132
133- promote_storagetype (A:: AbstractTensorMap , B:: AbstractTensorMap ) =
134- promote_storagetype (storagetype (A), storagetype (B))
135- promote_storagetype (:: Type{T} , A:: AbstractTensorMap , B:: AbstractTensorMap ) where {T <: Number } =
136- promote_storagetype (T, storagetype (A), storagetype (B))
133+ @inline promote_storagetype (A:: AbstractTensorMap , B:: AbstractTensorMap , Cs :: AbstractTensorMap... ) =
134+ promote_storagetype (storagetype (A), storagetype (B), map (storagetype, Cs) ... )
135+ @inline promote_storagetype (:: Type{T} , A:: AbstractTensorMap , B:: AbstractTensorMap , Cs :: AbstractTensorMap... ) where {T <: Number } =
136+ promote_storagetype (T, storagetype (A), storagetype (B), map (storagetype, Cs) ... )
137137
138- promote_storagetype (:: Type{A} , :: Type{B} ) where {A <: AbstractTensorMap , B <: AbstractTensorMap } =
139- promote_storagetype (storagetype (A), storagetype (B))
140- promote_storagetype (:: Type{T} , :: Type{A} , :: Type{B} ) where {T <: Number , A <: AbstractTensorMap , B <: AbstractTensorMap } =
141- promote_storagetype (similarstoragetype (A, T), similarstoragetype (B, T))
138+ @inline function promote_storagetype (
139+ :: Type{A} , :: Type{B} , Cs:: Type{C} ...
140+ ) where {A <: AbstractTensorMap , B <: AbstractTensorMap , C <: AbstractTensorMap }
141+ return promote_storagetype (storagetype (A), storagetype (B), map (storagetype, Cs)... )
142+ end
143+ @inline function promote_storagetype (
144+ :: Type{T} , :: Type{A} , :: Type{B} , Cs:: Type{C} ...
145+ ) where {T <: Number , A <: AbstractTensorMap , B <: AbstractTensorMap , C <: AbstractTensorMap }
146+ return promote_storagetype (similarstoragetype (A, T), similarstoragetype (B, T), map (Base. Fix2 (similarstoragetype, T), Cs)... )
147+ end
142148
143149# promotion system in the same spirit as base/promotion.jl
144150promote_storagetype (:: Type{Base.Bottom} , :: Type{Base.Bottom} ) = Base. Bottom
@@ -156,6 +162,9 @@ function promote_storagetype(::Type{T}, ::Type{S}) where {T, S}
156162 return promote_storage_result (T, S, promote_storage_rule (T, S), promote_storage_rule (S, T))
157163end
158164
165+ @inline promote_storagetype (T, S, U) = promote_storagetype (promote_storagetype (T, S), U)
166+ @inline promote_storagetype (T, S, U, V... ) = promote_storagetype (promote_storagetype (T, S), U, V... )
167+
159168@doc """
160169 promote_storage_rule(type1, type2)
161170
0 commit comments