@@ -40,6 +40,31 @@ function eachstoredblock(a::AbstractArray)
4040 return storedvalues (blocks (a))
4141end
4242
43+ # TODO : Generalize this, this catches simple cases
44+ # where the more general definition isn't specific enough.
45+ blocktype (a:: Array ) = typeof (a)
46+ # TODO : Maybe unwrap SubArrays?
47+ function blocktype (a:: AbstractArray )
48+ # TODO : Unfortunately, this doesn't always give
49+ # a concrete type, even when it could be concrete, i.e.
50+ #=
51+ ```julia
52+ julia> eltype(blocks(BlockArray(randn(2, 2), [1, 1], [1, 1])))
53+ Matrix{Float64} (alias for Array{Float64, 2})
54+
55+ julia> eltype(blocks(BlockedArray(randn(2, 2), [1, 1], [1, 1])))
56+ AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
57+
58+ julia> eltype(blocks(randn(2, 2)))
59+ AbstractMatrix{Float64} (alias for AbstractArray{Float64, 2})
60+ ```
61+ =#
62+ if isempty (blocks (a))
63+ return eltype (blocks (a))
64+ end
65+ return eltype (first (blocks (a)))
66+ end
67+
4368abstract type AbstractBlockSparseArrayInterface <: AbstractSparseArrayInterface end
4469
4570# TODO : Also support specifying the `blocktype` along with the `eltype`.
0 commit comments