Skip to content

Commit fc315c3

Browse files
committed
hoist y out of branches
1 parent 71b4ab3 commit fc315c3

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/solve.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
@inline function _solve(::Size{Sq}, ::Size{Sr}, q::QR, b::StaticVecOrMat) where {Sq, Sr}
44
Sa = (Sq[1], Sr[2]) # Size of the original matrix: Q * R
55
Q, R = q.Q, q.R
6+
y = Q' * b
67
if Sa[1] == Sa[2]
7-
return UpperTriangular(R) \ (Q' * b)
8+
return UpperTriangular(R) \ y
89
elseif Sa[1] > Sa[2]
9-
y = Q' * b
1010
R₁ = UpperTriangular(@view R[SOneTo(Sa[2]), SOneTo(Sa[2])])
1111
return R₁ \ y
1212
else
13-
y = Q' * b
1413
return R' * ((R * R') \ y)
1514
end
1615
end

0 commit comments

Comments
 (0)