@@ -458,28 +458,35 @@ blocks(t::TensorMap) = BlockIterator(t, fusionblockstructure(t).blockstructure)
458458function blocktype (:: Type{TT} ) where {TT <: TensorMap }
459459 A = storagetype (TT)
460460 T = eltype (A)
461- return Base. ReshapedArray{T, 2 , SubArray{T, 1 , A, Tuple{UnitRange{Int}}, true }, Tuple{}}
461+ @static if isdefined (Core, :Memory ) # StridedViews normalizes parent types!
462+ if A <: Vector{T}
463+ A = GenericMemory{T}
464+ end
465+ end
466+ return StridedView{T, 2 , A, typeof (identity)}
462467end
463468
464469function Base. iterate (iter:: BlockIterator{<:TensorMap} , state... )
465470 next = iterate (iter. structure, state... )
466471 isnothing (next) && return next
467- (c, (sz, r )), newstate = next
468- return c => reshape ( view ( iter. t. data, r), sz ), newstate
472+ (c, (sz, str, offset )), newstate = next
473+ return c => StridedView ( iter. t. data, sz, str, offset ), newstate
469474end
470475
471476function Base. getindex (iter:: BlockIterator{<:TensorMap} , c:: Sector )
472477 sectortype (iter. t) === typeof (c) || throw (SectorMismatch ())
473- (d₁, d₂), r = get (iter. structure, c) do
474- # is s is not a key, at least one of the two dimensions will be zero:
478+ (d₁, d₂), (s₁, s₂), offset = get (iter. structure, c) do
479+ # is c is not a key, at least one of the two dimensions will be zero:
475480 # it then does not matter where exactly we construct a view in `t.data`,
476481 # as it will have length zero anyway
477482 d₁′ = blockdim (codomain (iter. t), c)
478483 d₂′ = blockdim (domain (iter. t), c)
479- l = d₁′ * d₂′
480- return (d₁′, d₂′), 1 : l
484+ s₁ = 1
485+ s₂ = 0
486+ offset = 0
487+ return (d₁′, d₂′), (s₁, s₂), offset
481488 end
482- return reshape ( view ( iter. t. data, r ), (d ₁, d₂) )
489+ return StridedView ( iter. t. data, (d₁, d₂ ), (s ₁, s₂), offset )
483490end
484491
485492# Getting and setting the data at the subblock level
0 commit comments