JuliaArrays / JuliaArrays/StaticArrays.jl

`kron(::SMatrix, ::SDiagonal)` doesn't produce an `SMatrix`

Open
#1,180 0 comments 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

I noticed the following (c.f. #257)

julia> using StaticArrays

julia> A = @SMatrix rand(3, 3)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.096179  0.904208  0.721372
 0.329266  0.80936   0.112793
 0.607664  0.412918  0.816508

julia> B = @SMatrix rand(3, 3)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
 0.545279  0.442201  0.237385
 0.26991   0.755759  0.917111
 0.618612  0.246417  0.305401

julia> D = SDiagonal(1,1,1)
3×3 LinearAlgebra.Diagonal{Int64, SVector{3, Int64}} with indices SOneTo(3)×SOneTo(3):
 1  ⋅  ⋅
 ⋅  1  ⋅
 ⋅  ⋅  1

julia> kron(A, B) |> typeof
SMatrix{9, 9, Float64, 81} (alias for SArray{Tuple{9, 9}, Float64, 2, 81})

julia> kron(A, D) |> typeof
Matrix{Float64} (alias for Array{Float64, 2})

I would expect that the return type is a SMatrix, like above.

Here is what I'm running

julia> versioninfo()
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 8 on 8 virtual cores
Environment:
  JULIA_NUM_THREADS = auto
  JULIA_IMAGE_THREADS = 1

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 reported kron(A, D) case with an SMatrix and SDiagonal, then trace the kron dispatch and related StaticArrays methods. Compare its result with kron(A, B); done means the diagonal case returns an SMatrix and a regression test covers the reported 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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.