Skip to content

Commit ab352af

Browse files
lkdvosclaude
andcommitted
Simplify _zeroblock signature and drop explanatory comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6e75e44 commit ab352af

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎src/tensors/abstractblocktensor/abstracttensormap.jl‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function _block(t::AbstractBlockTensorMap, entries, c::Sector)
6767
_cachedblock(entries[I], c)
6868
else
6969
i, j = Tuple(CartesianIndices(allblocks)[k])
70-
_zeroblock(eltype(t), rowdims[i], coldims[j], () -> eachspace(t)[I], c)
70+
_zeroblock(t, I, rowdims[i], coldims[j], c)
7171
end
7272
end
7373
return mortar(allblocks, rowdims, coldims)
@@ -86,9 +86,9 @@ _blockcache(x::AbstractTensorMap) = (b = TK.blocks(x); b isa TK.BlockIterator ?
8686
_cachedblock(x, c::Sector) = block(x, c)
8787
_cachedblock(b::TK.BlockIterator, c::Sector) = b[c]
8888

89-
function _zeroblock(::Type{TT}, d₁::Int, d₂::Int, getspace, c::Sector) where {TT <: AbstractTensorMap}
90-
TT <: TensorMap || return block(zerovector!(similar(TT, getspace())), c)
91-
data = zerovector!(similar(storagetype(TT), d₁ * d₂))
89+
function _zeroblock(t::AbstractBlockTensorMap, I, d₁::Int, d₂::Int, c::Sector)
90+
eltype(t) <: TensorMap || return block(zerovector!(similar(eltype(t), eachspace(t)[I])), c)
91+
data = zerovector!(similar(storagetype(t), d₁ * d₂))
9292
return reshape(view(data, 1:(d₁ * d₂)), (d₁, d₂))
9393
end
9494

‎src/tensors/vectorinterface.jl‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ end
5151
_newblock(t::AbstractBlockTensorMap, I, allocator = TO.DefaultAllocator()) =
5252
TO.tensoralloc(eltype(t), eachspace(t)[I], Val(false), allocator)
5353

54-
# `t[I] = f(t[I], β)`, where missing entries are allocated uninitialized and passed `Zero()`
5554
@propagate_inbounds function _addblock!(
5655
f, t::AbstractBlockTensorMap, I::CartesianIndex, β::Number = One(), allocator = TO.DefaultAllocator()
5756
)
@@ -62,7 +61,6 @@ end
6261
_prescale!(t::AbstractBlockTensorMap, β::Number) =
6362
isone(β) ? t : iszero(β) ? zerovector!(t) : scale!(t, β)
6463

65-
# scale the entries of `t` that no entry of `tsrc` is mapped onto by `Imap`
6664
function _scale_untouched!(t::AbstractBlockTensorMap, tsrc::AbstractTensorMap, β::Number, Imap = identity)
6765
(issparse(tsrc) && !isone(β)) || return t
6866
touched = Set(Imap(I) for I in nonzero_keys(tsrc))

0 commit comments

Comments
 (0)