JuliaArrays / JuliaArrays/StaticArrays.jl

StaticArray types with cartesian index style

Open
#649 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Julia
Stars
844
Forks
159
Avg merge
3d 21h
Merged PRs (30d)
3

Description

I was trying to create a new static array type (an unsafe strided statically-sized view - or USS View for short). Because of the strided this type must have a cartesian index style. Most of the generated functions in StaticArrays generate code with linear indexing. Unfortunately, splitting a linear index to a cartesian one is fairly slow.

Ideally one could generate code using linear indexing for linear-indexable types and cartesian indexing for cartesian-indexable types. I tried to write a patch like this, but it turns out that generated (that is, generator) functions run in an older world and can't see new methods to Base.IndexStyle. Ouch.

So if there's interest in supporting external subtypes of StaticArray with different index styles, I believe this has to be encoded on the type level as a new parameter, i.e.

abstract type StaticArray{S, T, N, I<:IndexStyle} <: AbstractArray{T, N} end
Base.IndexStyle(::Type{StaticArray{S,T,N,I}}) where {S,T,N,I} = I()
struct SArray{S, T, N, L} <: StaticArray{S, T, N, IndexLinear} # .... etc

Is there interest in doing this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the StaticArray and SArray type definitions and the existing generated functions that use linear indexing. Check how Base.IndexStyle is currently handled, then determine whether a type-level index-style parameter can support external cartesian-indexable subtypes without the slow linear-to-cartesian conversion; the issue does not name tests or files.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.