JuliaArrays / JuliaArrays/StaticArrays.jl

`hcat(A, B)` is SArray, but `[ A ;; B]` is not

Open
#1,275 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

consider this MWE:

using LinearAlgebra, StaticArrays

A = @SMatrix randn(3, 4)
B = @SMatrix randn(3, 2)

as expected,

hcat(A, B)  #returns 3×6 SMatrix{3, 6, Float64, 18}

but

[ A ;; B]  # returns 3×6 Matrix{Float64}

If we compare this to vcat,

A = @SMatrix randn(3, 4)
B = @SMatrix randn(2, 4)
vcat(A, B) # returns 5×4 SMatrix{5, 4, Float64, 20} (as expected)
[ A ; B] # returns 5×4 SMatrix{5, 4, Float64, 20} (as expected)

So somehow, the array concatenation works for vcat but not for hcat.

Is this expected behavior?

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

No source file or test is named. Reproduce the MWE with StaticArrays and compare the types returned by hcat(A, B), [A ;; B], vcat(A, B), and [A ; B]. Determine whether horizontal concatenation should preserve the SMatrix type like vertical concatenation, then add or update coverage for the chosen behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.