Skip to content

Feature request: concatenation may preserve static sizes #46487

@jishnub

Description

@jishnub

Currently, concatenation passes the sizes of the components to determine the type of the container. It might be possible to use the axes instead, thereby preserving static sizes. As an example:

julia> using StaticArrays, FillArrays

julia> a = SMatrix{2,2}(1:4)
2×2 SMatrix{2, 2, Int64, 4} with indices SOneTo(2)×SOneTo(2):
 1  3
 2  4

julia> row = Ones(SOneTo(1), axes(a,2))
1×2 Ones{Float64, 2, Tuple{SOneTo{1}, SOneTo{2}}} with indices SOneTo(1)×SOneTo(2)

julia> [a; row]
3×2 Matrix{Float64}:
 1.0  3.0
 2.0  4.0
 1.0  1.0

Since all components have their sizes statically known, it should be possible to preserve that information in the container. This will perhaps require some function that accepts SOneTo(2) and SOneTo(1) as arguments and returns SOneTo(3). I'm uncertain if there is an existing function that does this. However, once this is available, one may pass the result to similar to generate the container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions