Skip to content

Commit db248e9

Browse files
committed
fix
1 parent 7b9037f commit db248e9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/butterflylu.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,32 @@ struct 🦋workspace{T}
2424
U::Matrix{T}
2525
V::Matrix{T}
2626
out::Vector{T}
27+
tmp::Vector{T}
2728
n::Int
2829
function 🦋workspace(A, b, ::Val{SEED} = Val(888)) where {SEED}
2930
n = size(A, 1)
30-
out = similar(b, n)
31+
out = similar(b)
3132
if (n % 4 != 0)
3233
A = pad!(A)
3334
xn = 4 - n % 4
3435
b = [b; rand(xn)]
3536
end
37+
tmp = similar(b)
3638
U, V = (similar(A), similar(A))
3739
ws = 🦋generate_random!(A)
3840
materializeUV(U, V, ws)
39-
new{eltype(A)}(A, b, ws, U, V, out, n)
41+
new{eltype(A)}(A, b, ws, U, V, out, tmp, n)
4042
end
4143
end
4244

4345
function 🦋solve!(workspace::🦋workspace, thread)
44-
(;A, b, ws, U, V, out, n) = workspace
46+
(;A, b, ws, U, V, out, tmp, n) = workspace
4547
🦋mul!(A, ws)
4648
F = RecursiveFactorization.lu!(A, Val(false), thread)
4749

48-
mul!(b, U', b)
49-
ldiv!(b, UnitLowerTriangular(F.factors), b, thread)
50-
ldiv!(b, UpperTriangular(F.factors), b, thread)
51-
mul!(b, V, b)
50+
mul!(tmp, U', b)
51+
ldiv!(F, tmp, thread)
52+
mul!(b, V, tmp)
5253
out .= @view b[1:n]
5354
out
5455
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181
for i in 790 : 810
8282
A = wilkinson(i)
8383
b = rand(i)
84-
ws = RecursiveFactorization.🦋workspace(copy(A), copy(b))
84+
ws = RecursiveFactorization.🦋workspace(copy(A), copy(b))
8585
out = RecursiveFactorization.🦋solve!(ws, Val(true))
8686
@test norm(A * out .- b) <= 1e-10
8787
end

0 commit comments

Comments
 (0)