Skip to content

Commit 712f052

Browse files
Set types by SparseMatrixCSC{Tv, Ti} when possible
1 parent 3fef053 commit 712f052

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/solvers/spqr.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ function LinearAlgebra.qr(A::SparseMatrixCSC{Tv, Ti}; tol=_default_tol(A), order
204204
C_NULL, C_NULL, C_NULL, C_NULL,
205205
R, E, H, HPinv, HTau)
206206

207-
R_ = SparseMatrixCSC(Tv.(Sparse(R[])))
208-
return QRSparse(SparseMatrixCSC(Tv.(Sparse(H[]))),
207+
R_ = SparseMatrixCSC{Tv, Ti}(Sparse(R[]))
208+
return QRSparse(SparseMatrixCSC{Tv, Ti}(Tv.(Sparse(H[]))),
209209
vec(Array{Tv}(CHOLMOD.Dense(HTau[]))),
210-
SparseMatrixCSC(min(size(A)...),
210+
SparseMatrixCSC{Tv, Ti}(min(size(A)...),
211211
size(R_, 2),
212212
getcolptr(R_),
213213
rowvals(R_),

test/spqr.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ end
110110
@test (F.Q*F.R)::SparseMatrixCSC == A[F.prow,F.pcol]
111111
end
112112

113+
@testset "Issue #585 for element type: $eltyA" for eltyA in (Float64, Float32)
114+
A = sparse(eltyA[1 0; 0 1])
115+
F = qr(A)
116+
@test eltype(F.Q) == eltype(F.R) == eltyA
117+
end
118+
113119
@testset "select ordering overdetermined" begin
114120
A = sparse([1:n; rand(1:m, nn - n)], [1:n; rand(1:n, nn - n)], randn(nn), m, n)
115121
b = randn(m)

0 commit comments

Comments
 (0)