From f0f3fc3adc1f3508cdfe471bae8268490159dc48 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Thu, 14 Nov 2024 21:40:32 -0500 Subject: [PATCH] Missing constructors --- src/tensors/blocktensor.jl | 20 ++++++++++---------- src/tensors/sparseblocktensor.jl | 12 +++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/tensors/blocktensor.jl b/src/tensors/blocktensor.jl index d37026c..17f63b9 100644 --- a/src/tensors/blocktensor.jl +++ b/src/tensors/blocktensor.jl @@ -26,12 +26,20 @@ struct BlockTensorMap{TT<:AbstractTensorMap,E,S,N₁,N₂,N} <: end end +function BlockTensorMap{TT,E,S,N₁,N₂,N}( + ::UndefInitializer, space::TensorMapSumSpace{S,N₁,N₂} +) where {TT,E,S,N₁,N₂,N} + tdst = BlockTensorMap{TT,E,S,N₁,N₂,N}(undef_blocks, space) + tdst.data .= similar.(TT, SumSpaceIndices(space)) + return tdst +end + # uninitialized constructor function BlockTensorMap{TT}( - ::UndefBlocksInitializer, space::TensorMapSumSpace{S,N₁,N₂} + u::Union{UndefBlocksInitializer,UndefInitializer}, space::TensorMapSumSpace{S,N₁,N₂} ) where {E,S,N₁,N₂,TT<:AbstractTensorMap{E,S,N₁,N₂}} N = N₁ + N₂ - return BlockTensorMap{TT,E,S,N₁,N₂,N}(undef_blocks, space) + return BlockTensorMap{TT,E,S,N₁,N₂,N}(u, space) end # constructor from data @@ -53,14 +61,6 @@ end # Constructors # ------------ -function BlockTensorMap{TT}( - ::UndefInitializer, space::TensorMapSumSpace{S,N₁,N₂} -) where {E,S,N₁,N₂,TT<:AbstractTensorMap{E,S,N₁,N₂}} - tdst = BlockTensorMap{TT}(undef_blocks, space) - tdst.data .= similar.(TT, SumSpaceIndices(space)) - return tdst -end - function BlockTensorMap{TT}( data::Union{Array{TT},UndefInitializer,UndefBlocksInitializer}, codom::ProductSumSpace{S,N₁}, diff --git a/src/tensors/sparseblocktensor.jl b/src/tensors/sparseblocktensor.jl index d2a684e..07c30be 100644 --- a/src/tensors/sparseblocktensor.jl +++ b/src/tensors/sparseblocktensor.jl @@ -26,9 +26,15 @@ struct SparseBlockTensorMap{TT<:AbstractTensorMap,E,S,N₁,N₂,N} <: end end +function SparseBlockTensorMap{TT,E,S,N₁,N₂,N}( + ::UndefInitializer, space::TensorMapSumSpace{S,N₁,N₂} +) where {E,S,N₁,N₂,N,TT<:AbstractTensorMap{E,S,N₁,N₂}} + return SparseBlockTensorMap{TT,E,S,N₁,N₂,N}(undef_blocks, space) +end + # uninitialized constructor function SparseBlockTensorMap{TT}( - ::UndefBlocksInitializer, space::TensorMapSumSpace{S,N₁,N₂} + ::Union{UndefBlocksInitializer,UndefInitializer}, space::TensorMapSumSpace{S,N₁,N₂} ) where {E,S,N₁,N₂,TT<:AbstractTensorMap{E,S,N₁,N₂}} N = N₁ + N₂ return SparseBlockTensorMap{TT,E,S,N₁,N₂,N}(undef_blocks, space) @@ -54,10 +60,6 @@ end # Constructors # ------------ -function SparseBlockTensorMap{TT}(::UndefInitializer, space::TensorMapSumSpace) where {TT} - return SparseBlockTensorMap{TT}(undef_blocks, space) -end - function SparseBlockTensorMap{TT}( data::Union{Array{TT},UndefInitializer,UndefBlocksInitializer}, codom::ProductSumSpace,