JuliaArrays / JuliaArrays/StaticArrays.jl
Special case for 2x3 matrix solve
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
I'm doing some coordinate transformation stuff that requires the solution of a 2 by 3 system. Right now, all rectangular SMatrix systems are done by LinearAlgebra and the allocations mean I can't run this on the GPU. I coded this version which seems to be working and non-allocating.
@inline function (\)(a::SMatrix{2,3}, b::SVector{2})
# columns of a'
a1,a2 = a[1,:],a[2,:]
# Q,R decomposition
r11 = norm(a1)
q1 = a1/r11
r12 = q1'*a2
p = a2-r12*q1
r22 = norm(p) < eps(r11) ? one(r11) : norm(p)
q2 = p/r22
# forward substitution to solve R'v = b
v1 = b[1]/r11
v2 = (b[2]-r12*v1)/r22
# return solution x = Qv
return q1*v1+q2*v2
end
I'm happy to add this to solve.jl and do a PR if it would be helpful.
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 in solve.jl and inspect how rectangular SMatrix systems are currently delegated to LinearAlgebra. Compare the proposed specialized 2x3 solve with the surrounding methods, then verify that the resulting path is non-allocating and suitable for GPU use. Done means the special case is integrated consistently with the existing solve behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100