Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mtfishman opened this issue Mar 29, 2024 · 0 comments

Comments

@mtfishman
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant