Skip to content

Commit

Permalink
used Matrix(qr) to make tests more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Jul 23, 2022
1 parent 924b2e8 commit 31df81e
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions test/qr_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ using LinearAlgebra.LAPACK
ws = QRWs(A0)
@testset "geqrf!" begin
A = copy(A0)
AT, tau = LAPACK.geqrf!(ws, A)
qr1 = QR(LAPACK.geqrf!(ws, A)...)

AT1, tau1 = LAPACK.geqrf!(copy(A0), randn(n))
@test AT1 == AT
@test tau1 == tau
qr2 = QR(LAPACK.geqrf!(copy(A0), randn(n))...)
@test isapprox(Matrix(qr1), Matrix(qr2))
# using Workspace, factorize!
ws = Workspace(LAPACK.geqrf!, copy(A0))
AT1, tau1 = factorize!(ws, copy(A0))
@test AT1 == AT
@test tau1 == tau
qr2 = QR(factorize!(ws, copy(A0))...)

@test isapprox(Matrix(qr1), Matrix(qr2))

@test_throws ArgumentError factorize!(ws, rand(n+1, n+1); resize=false)
factorize!(ws, rand(n+1, n+1))
Expand Down Expand Up @@ -51,15 +50,13 @@ end
A = copy(A0)
ws = QRWYWs(A)

AT, taut = LAPACK.geqrt!(ws, copy(A))
AT1, taut1 = LAPACK.geqrt!(copy(A0), zeros(size(ws.T)))
@test AT1 == AT
@test isapprox(taut1, taut)
qr1 = LinearAlgebra.QRCompactWY(LAPACK.geqrt!(ws, copy(A))...)
qr2 = LinearAlgebra.QRCompactWY(LAPACK.geqrt!(copy(A0), zeros(size(ws.T)))...)
@test isapprox(Matrix(qr1), Matrix(qr2))
# using Workspace, factorize!
ws = Workspace(LAPACK.geqrt!, copy(A))
AT, taut = factorize!(ws, A)
@test AT1 == AT
@test isapprox(taut1, taut)
qr1 = LinearAlgebra.QRCompactWY(factorize!(ws, A)...)
@test isapprox(Matrix(qr1), Matrix(qr2))
show(devnull, "text/plain", ws)
@test_throws ArgumentError factorize!(ws, rand(n-1, n-1); resize=false)
factorize!(ws, rand(n-1, n-1))
Expand Down

0 comments on commit 31df81e

Please sign in to comment.