JuliaArrays / JuliaArrays/StaticArrays.jl

Transposing nx0 or 0xn SMartix yields empty Union as element type

Open
#786 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I am having issues when transposing an SMatrix with a zero dimension. When transposing this matrix, the element type changes to Union{}. This happens with either one of the 2 dimension being zero, and also with other types (e.g. Int64).

This issue came up using v0.12.3 and v0.12.2. In v0.12.1 the element type stays the same, which I think is the expected and desired behavior.

Minimum (not) working example using v0.12.3 (and v0.12.2):

julia> using StaticArrays

julia> a = SMatrix{3,0,Float64,0}()
3×0 SArray{Tuple{3,0},Float64,2,0} with indices SOneTo(3)×SOneTo(0)

julia> a'
0×3 SArray{Tuple{0,3},Union{},2,0} with indices SOneTo(0)×SOneTo(3)

Working example using v0.12.1:

julia> using StaticArrays

julia> a = SMatrix{3,0,Float64,0}()
3×0 SArray{Tuple{3,0},Float64,2,0} with indices SOneTo(3)×SOneTo(0)

julia> a'
0×3 SArray{Tuple{0,3},Float64,2,0} with indices SOneTo(0)×SOneTo(3)

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

Reproduce the issue with the Julia examples for SMatrix{3,0,Float64,0} and its transpose, comparing StaticArrays v0.12.3 with v0.12.1. Trace the transpose operation and verify that zero-dimension matrices preserve their original element type, including the Int64 case described; done means the result no longer has element type Union{}.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.