File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
NDTensors/src/lib/BlockSparseArrays/src/blocksparsearrayinterface Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,13 @@ function map_stored_blocks(f, a::AbstractArray)
77 # TODO : `block_stored_indices` should output `Indices` storing
88 # the stored Blocks, not a `Dictionary` from cartesian indices
99 # to Blocks.
10- bs = block_stored_indices (a)
11- mapped_blocks = Dictionary (bs, map (b -> f (@view (a[b])), bs))
10+ bs = collect (block_stored_indices (a))
11+ ds = map (b -> f (@view (a[b])), bs)
12+ # We manually specify the block type using `Base.promote_op`
13+ # since `a[b]` may not be inferrable. For example, if `blocktype(a)`
14+ # is `Diagonal{Float64,Vector{Float64}}`, the non-stored blocks are `Matrix{Float64}`
15+ # since they can't necessarily by `Diagonal` if there are rectangular blocks.
16+ mapped_blocks = Dictionary {eltype(bs),eltype(ds)} (bs, ds)
1217 # TODO : Use `similartype(typeof(a), eltype(eltype(mapped_blocks)))(...)`.
1318 return BlockSparseArray (mapped_blocks, axes (a))
1419end
You can’t perform that action at this time.
0 commit comments