Skip to content

Commit 22ed84f

Browse files
committed
More progress
1 parent ea34937 commit 22ed84f

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/blocksparsearrayinterface/blocksparsearrayinterface.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,28 @@ end
145145
return (inds[1][I[1]], to_indices(a, Base.tail(inds), Base.tail(I))...)
146146
end
147147

148+
# a[mortar([Block(1)[1:2], Block(2)[1:3]]), mortar([Block(1)[1:2], Block(2)[1:3]])]
149+
# a[[Block(1)[1:2], Block(2)[1:3]], [Block(1)[1:2], Block(2)[1:3]]]
150+
@interface ::AbstractBlockSparseArrayInterface function Base.to_indices(
151+
a, inds, I::Tuple{BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexRange{1}}},Vararg{Any}}
152+
)
153+
# TODO: Use a type like `BlockSlice` to keep track of the blocks.
154+
# See https://github.com/JuliaArrays/BlockArrays.jl/pull/459.
155+
I1 = blockedunitrange_getindices(inds[1], I[1])
156+
return (I1, to_indices(a, Base.tail(inds), Base.tail(I))...)
157+
end
158+
159+
# a[mortar([Block(1)[1:2], Block(2)[1:3]]), mortar([Block(1)[1:2], Block(2)[1:3]])]
160+
# a[[Block(1)[1:2], Block(2)[1:3]], [Block(1)[1:2], Block(2)[1:3]]]
161+
@interface ::AbstractBlockSparseArrayInterface function Base.to_indices(
162+
a, inds, I::Tuple{BlockVector{<:BlockIndex{1},<:Vector{<:BlockIndexRange{1}}},Vararg{Any}}
163+
)
164+
# TODO: Use a type like `BlockSlice` to keep track of the blocks.
165+
# See https://github.com/JuliaArrays/BlockArrays.jl/pull/459.
166+
I1 = blockedunitrange_getindices(inds[1], I[1])
167+
return (I1, to_indices(a, Base.tail(inds), Base.tail(I))...)
168+
end
169+
148170
# TODO: Need to implement this!
149171
function block_merge end
150172

src/blocksparsearrayinterface/map.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,37 @@ using GPUArraysCore: @allowscalar
2222
for I in union_stored_blocked_cartesianindices(a_dest, a_srcs...)
2323
BI_dest = blockindexrange(a_dest, I)
2424
BI_srcs = map(a_src -> blockindexrange(a_src, I), a_srcs)
25+
26+
@show BI_dest
27+
@show BI_srcs
28+
2529
# TODO: Investigate why this doesn't work:
2630
# block_dest = @view a_dest[_block(BI_dest)]
2731
block_dest = blocks_maybe_single(a_dest)[Int.(Tuple(_block(BI_dest)))...]
2832
# TODO: Investigate why this doesn't work:
2933
# block_srcs = ntuple(i -> @view(a_srcs[i][_block(BI_srcs[i])]), length(a_srcs))
34+
35+
@show blocks_maybe_single(a_srcs[1])
36+
@show Int.(Tuple(_block(BI_srcs[1])))
37+
3038
block_srcs = ntuple(length(a_srcs)) do i
3139
return blocks_maybe_single(a_srcs[i])[Int.(Tuple(_block(BI_srcs[i])))...]
3240
end
41+
42+
display(block_srcs[1])
43+
display(block_srcs[1].indices)
44+
3345
subblock_dest = @view block_dest[BI_dest.indices...]
3446
subblock_srcs = ntuple(i -> @view(block_srcs[i][BI_srcs[i].indices...]), length(a_srcs))
3547
I_dest = CartesianIndex(Int.(Tuple(_block(BI_dest))))
3648
# If the function preserves zero values and all of the source blocks are zero,
3749
# the output block will be zero. In that case, if the block isn't stored yet,
3850
# don't do anything.
51+
52+
@show typeof(subblock_srcs[1])
53+
display(subblock_srcs[1])
54+
error()
55+
3956
if f_preserves_zeros && all(iszero, subblock_srcs) && !isstored(blocks(a_dest), I_dest)
4057
continue
4158
end

0 commit comments

Comments
 (0)