@@ -453,28 +453,35 @@ blocks(t::TensorMap) = BlockIterator(t, fusionblockstructure(t).blockstructure)
453453function blocktype (:: Type{TT} ) where {TT <: TensorMap }
454454 A = storagetype (TT)
455455 T = eltype (A)
456- return Base. ReshapedArray{T, 2 , SubArray{T, 1 , A, Tuple{UnitRange{Int}}, true }, Tuple{}}
456+ @static if isdefined (Core, :Memory ) # StridedViews normalizes parent types!
457+ if A <: Vector{T}
458+ A = GenericMemory{T}
459+ end
460+ end
461+ return StridedView{T, 2 , A, typeof (identity)}
457462end
458463
459464function Base. iterate (iter:: BlockIterator{<:TensorMap} , state... )
460465 next = iterate (iter. structure, state... )
461466 isnothing (next) && return next
462- (c, (sz, r )), newstate = next
463- return c => reshape ( view ( iter. t. data, r), sz ), newstate
467+ (c, (sz, str, offset )), newstate = next
468+ return c => StridedView ( iter. t. data, sz, str, offset ), newstate
464469end
465470
466471function Base. getindex (iter:: BlockIterator{<:TensorMap} , c:: Sector )
467472 sectortype (iter. t) === typeof (c) || throw (SectorMismatch ())
468- (d₁, d₂), r = get (iter. structure, c) do
469- # is s is not a key, at least one of the two dimensions will be zero:
473+ (d₁, d₂), (s₁, s₂), offset = get (iter. structure, c) do
474+ # is c is not a key, at least one of the two dimensions will be zero:
470475 # it then does not matter where exactly we construct a view in `t.data`,
471476 # as it will have length zero anyway
472477 d₁′ = blockdim (codomain (iter. t), c)
473478 d₂′ = blockdim (domain (iter. t), c)
474- l = d₁′ * d₂′
475- return (d₁′, d₂′), 1 : l
479+ s₁ = 1
480+ s₂ = 0
481+ offset = 0
482+ return (d₁′, d₂′), (s₁, s₂), offset
476483 end
477- return reshape ( view ( iter. t. data, r ), (d ₁, d₂) )
484+ return StridedView ( iter. t. data, (d₁, d₂ ), (s ₁, s₂), offset )
478485end
479486
480487# Getting and setting the data at the subblock level
0 commit comments