Skip to content

Commit

Permalink
Missing constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Nov 15, 2024
1 parent ff5a72d commit f0f3fc3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
20 changes: 10 additions & 10 deletions src/tensors/blocktensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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₁},
Expand Down
12 changes: 7 additions & 5 deletions src/tensors/sparseblocktensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit f0f3fc3

Please sign in to comment.