Skip to content

Commit 1996cae

Browse files
simplify the simplelu code a bit
1 parent f336a16 commit 1996cae

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/simplelu.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,12 @@ function simplelu_factorize!(lu::LUSolver{T}, pivot=true) where {T}
8282
end
8383

8484
function simplelu_solve!(lu::LUSolver{T}) where {T}
85-
local s::T
86-
8785
@inbounds for i = 1:lu.n
8886
lu.x[i] = lu.b[lu.perms[i]]
8987
end
9088

9189
@inbounds for i = 2:lu.n
92-
s = 0
90+
s = zero(T)
9391
for j = 1:i-1
9492
s += lu.A[i,j] * lu.x[j]
9593
end
@@ -98,15 +96,15 @@ function simplelu_solve!(lu::LUSolver{T}) where {T}
9896

9997
lu.x[lu.n] /= lu.A[lu.n,lu.n]
10098
@inbounds for i = lu.n-1:-1:1
101-
s = 0
99+
s = zero(T)
102100
for j = i+1:lu.n
103101
s += lu.A[i,j] * lu.x[j]
104102
end
105103
lu.x[i] -= s
106104
lu.x[i] /= lu.A[i,i]
107105
end
108106

109-
lu.b .= lu.x
107+
copyto!(lu.b,lu.x)
110108

111109
lu.x
112110
end

0 commit comments

Comments
 (0)