Skip to content

Commit 632405b

Browse files
committed
Rewrap blockview of wrapped array
1 parent 10a6563 commit 632405b

File tree

1 file changed

+14
-0
lines changed
  • NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray

1 file changed

+14
-0
lines changed

NDTensors/src/lib/BlockSparseArrays/src/abstractblocksparsearray/views.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,17 @@ function BlockArrays.viewblock(
278278
) where {T,N}
279279
return view(viewblock(a, Block.(block)...), map(b -> only(b.indices), block)...)
280280
end
281+
282+
# migrate wrapper layer for viewing `adjoint` and `transpose`.
283+
for (f, F) in ((:adjoint, :Adjoint), (:transpose, :Transpose))
284+
@eval begin
285+
function Base.view(A::$F{<:Any,<:AbstractBlockSparseVector}, b::Block{1})
286+
return $f(view(parent(A), b))
287+
end
288+
289+
Base.view(A::$F{<:Any,<:AbstractBlockSparseMatrix}, b::Block{2}) = view(A, Tuple(b)...)
290+
function Base.view(A::$F{<:Any,<:AbstractBlockSparseMatrix}, b1::Block{1}, b2::Block{1})
291+
return $f(view(parent(A), b2, b1))
292+
end
293+
end
294+
end

0 commit comments

Comments
 (0)