Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong full matrix for Q of QR-factorization in sparse #26367

Closed
KlausC opened this issue Mar 8, 2018 · 1 comment · Fixed by #26392
Closed

Wrong full matrix for Q of QR-factorization in sparse #26367

KlausC opened this issue Mar 8, 2018 · 1 comment · Fixed by #26392
Labels
linear algebra Linear algebra sparse Sparse arrays

Comments

@KlausC
Copy link
Contributor

KlausC commented Mar 8, 2018

There seems to be a bug in the constructor Matrix(::SuiteSparse.SPQR.QRSparseQ).

julia> versioninfo()
Julia Version 0.7.0-DEV.4473
Commit 2f826b55d6 (2018-03-06 05:55 UTC)
Platform Info:
  OS: Linux (x86_64-redhat-linux)
  CPU: Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-3.9.1 (ORCJIT, ivybridge)
Environment:

julia> A = sparse([0.0 1 0 0; 0 0 0 0])
2×4 SparseMatrixCSC{Float64,Int64} with 1 stored entry:
  [1, 2]  =  1.0

julia> F = qrfact(A);

julia> Matrix(F.Q)
2×0 Array{Float64,2}

julia> Matrix(F.Q')
2×2 Array{Float64,2}:
 1.0  0.0
 0.0  1.0

Size calculation of the result matrix in LinearAlgebra/src/qr.jl:530 is not ok

Matrix(A::AbstractQ{T}) where {T} =
 lmul!(A, Matrix{T}(I, size(A.factors, 1), min(size(A.factors    )...)))

The number of columns of Matrix(F.Q) should be the same as the number of rows of F.R, or it should be square.

@andreasnoack
Copy link
Member

This is an unfortunate consequence of the storage format for the householders being different between dense and sparse QR here but the Matrix(AbstractQ) constructor assumes they are the same. The constructor should probably not access the fields directly.

andreasnoack added a commit that referenced this issue Mar 9, 2018
andreasnoack added a commit that referenced this issue Mar 11, 2018
andreasnoack added a commit that referenced this issue Mar 11, 2018
andreasnoack added a commit that referenced this issue Mar 23, 2018
andreasnoack added a commit that referenced this issue Mar 27, 2018
andreasnoack added a commit that referenced this issue May 22, 2018
andreasnoack added a commit that referenced this issue Nov 23, 2018
andreasnoack added a commit that referenced this issue Nov 28, 2018
* Fix Matrix(QRSparseQ) constructor

Fixes #26367

* Make sure that size(Q, i) definition covers HessenbergQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra sparse Sparse arrays
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants