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

QR Decomposition Extremely Slow Converting to Float64 Matrix #29846

Closed
clintonTE opened this issue Oct 30, 2018 · 2 comments
Closed

QR Decomposition Extremely Slow Converting to Float64 Matrix #29846

clintonTE opened this issue Oct 30, 2018 · 2 comments
Labels
linear algebra Linear algebra

Comments

@clintonTE
Copy link

clintonTE commented Oct 30, 2018

It seems converting a qr decomposition Q matrix to a Float Matrix takes high-degree polynomial time at best.

Seems like a bug. I don’t remember having this problem on earlier versions (I am using 1.01 on Windows 10). Granted my laptop is pretty slow, but this is worse than matrix inversion, so the performance doesn’t make a lot of sense to me.

using LinearAlgebra
function mwe()
  local Q::Matrix{Float64}

  X = rand(200,13)
  f = qr(X)
  @time Q = Matrix{Float64}(f.Q)

  X = rand(400,13)
  f = qr(X)
  @time Q = Matrix{Float64}(f.Q)

  X = rand(600,13)
  f = qr(X)
  @time Q = Matrix{Float64}(f.Q)

  X = rand(800,13)
  f = qr(X)
  @time Q = Matrix{Float64}(f.Q)
end

mwe()

Output:
0.260873 seconds (120.00 k allocations: 145.569 MiB, 1.49% gc time)
2.115116 seconds (480.00 k allocations: 1.022 GiB, 3.70% gc time)
6.812497 seconds (1.08 M allocations: 3.372 GiB, 4.46% gc time)
15.563167 seconds (1.92 M allocations: 7.901 GiB, 3.08% gc time)

Version Info:

Julia Version 1.0.1
Commit 0d713926f8 (2018-09-29 19:05 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

Also on discourse:
https://discourse.julialang.org/t/qr-decomposition-extremely-slow/16946?u=clinton

@RalphAS
Copy link

RalphAS commented Oct 30, 2018

Specifying the type parameter Matrix{Float64}(f.Q) dispatches to a generic copy constructor, whereas Matrix(f.Q) dispatches to the proper method in qr.jl.

@clintonTE
Copy link
Author

Thanks for the work around! That worked for what I was doing. Note that Matrix(f.Q[:,:]) is also slow.

@KristofferC KristofferC added the linear algebra Linear algebra label Oct 30, 2018
andreasnoack added a commit that referenced this issue Oct 30, 2018
andreasnoack added a commit that referenced this issue Oct 31, 2018
andreasnoack added a commit that referenced this issue Oct 31, 2018
andreasnoack added a commit that referenced this issue Nov 2, 2018
KristofferC pushed a commit that referenced this issue Nov 12, 2018
…9865)

LQ and Hessenberg to Matrix

Fixes #29846

(cherry picked from commit 6a3a504)
KristofferC pushed a commit that referenced this issue Dec 12, 2018
…9865)

LQ and Hessenberg to Matrix

Fixes #29846

(cherry picked from commit 6a3a504)
KristofferC pushed a commit that referenced this issue Feb 11, 2019
…9865)

LQ and Hessenberg to Matrix

Fixes #29846

(cherry picked from commit 6a3a504)
KristofferC pushed a commit that referenced this issue Feb 20, 2020
…9865)

LQ and Hessenberg to Matrix

Fixes #29846

(cherry picked from commit 6a3a504)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linear algebra Linear algebra
Projects
None yet
Development

No branches or pull requests

3 participants