JuliaArrays / JuliaArrays/StaticArrays.jl
`tril` and `triu` not working with static arrays
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
At the moment tril and triu do not work for static arrays
julia> B = @SMatrix [1 2 3 4;5 6 7 8;9 10 11 12; 13 14 15 16]
4×4 SMatrix{4, 4, Int64, 16} with indices SOneTo(4)×SOneTo(4):
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
julia> tril(B)
ERROR: setindex!(::SMatrix{4, 4, Int64, 16}, value, ::Int) is not defined.
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] setindex!(a::SMatrix{4, 4, Int64, 16}, value::Int64, i::Int64)
@ StaticArrays ~\.julia\packages\StaticArrays\rdb0l\src\indexing.jl:3
[3] macro expansion
@ ~\.julia\packages\StaticArrays\rdb0l\src\indexing.jl:66 [inlined]
[4] _setindex!_scalar
@ ~\.julia\packages\StaticArrays\rdb0l\src\indexing.jl:46 [inlined]
[5] setindex!
@ ~\.julia\packages\StaticArrays\rdb0l\src\indexing.jl:42 [inlined]
[6] tril!
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\dense.jl:176 [inlined]
[7] tril!
@ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\generic.jl:443 [inlined]
[8] tril(M::SMatrix{4, 4, Int64, 16})
@ LinearAlgebra C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\LinearAlgebra\src\generic.jl:365
[9] top-level scope
@ REPL[126]:1
I think it might be useful in some situations to have those working for static arrays.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported REPL example for tril(B), then inspect StaticArrays' indexing.jl alongside the LinearAlgebra tril! and triu! entry points shown in the stack trace. Done means both tril and triu operate on static arrays without the reported setindex! error, with behavior checked for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100