Skip to content

Generic interface for constructing AbstractBlockArrays: blocked(a::AbstractArray, blocklengths...) #366

@mtfishman

Description

@mtfishman

This is a proposal for a new generic function for constructing block arrays, blocked(a::AbstractArray, blocklengths...), which takes an AbstractArray a and block lengths blocklengths, one for each dimension, and outputs the closest reasonable AbstractBlockArray. It would be a generalization of the corresponding BlockArray and PseudoBlockArray constructors, and could make a PseudoBlockArray as a fallback.

This could be used for making BlockedUnitRanges with blocked(1:7, [4, 3]) == blockedrange([4, 3]) and BlockedOneTo (being developed in #348) with blocked(Base.OneTo(7), [4, 3]). It may also call for defining BlockedUnitRange(1:7, [4, 3]) and BlockedOneTo(Base.OneTo(7), [4, 3]), again analogous to the BlockArray and PseudoBlockArray constructors, but I'm not sure if that is needed.

blocked(a::AbstractArray, blocklengths...) would be very similar to a[blockedrange.(blocklengths)...], however, so maybe it isn't needed and that is the preferred syntax for this operation. However, blocked could make a view while a[blockedrange.(blocklengths)...] copies.

See #347 (comment) for a related discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions