Skip to content

Commit 45bf516

Browse files
authored
Merge pull request #42376 from JuliaLang/ksh/qr
tests for converting QR eltype
2 parents 60eb238 + 46ad9c9 commit 45bf516

File tree

1 file changed

+17
-0
lines changed
  • stdlib/LinearAlgebra/test

1 file changed

+17
-0
lines changed

stdlib/LinearAlgebra/test/qr.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,4 +415,21 @@ end
415415
@test A.Q' * B A.Q
416416
end
417417

418+
@testset "convert between eltypes" begin
419+
a = rand(Float64, 10, 5)
420+
qra = qr(a)
421+
qrwy = LinearAlgebra.QRCompactWY{Float32}(qra.factors, qra.T)
422+
@test Array(qrwy) Array(qr(Float32.(a)))
423+
@test eltype(qrwy.factors) == eltype(qrwy.T) == Float32
424+
qra = qr(a, ColumnNorm())
425+
qrp = QRPivoted{Float32}(qra.factors, qra.τ, qra.jpvt)
426+
@test Array(qrp) Array(qr(Float32.(a), ColumnNorm()))
427+
@test eltype(qrp.factors) == eltype(qrp.τ) == Float32
428+
a = rand(Float16, 10, 5)
429+
qra = qr(a)
430+
qrnonblas = QR{ComplexF16}(qra.factors, qra.τ)
431+
@test Array(qrnonblas) Array(qr(ComplexF16.(a)))
432+
@test eltype(qrnonblas.factors) == eltype(qrnonblas.τ) == ComplexF16
433+
end
434+
418435
end # module TestQR

0 commit comments

Comments
 (0)