-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Two performance problems with the Q in QR factorizations #800
Comments
For multiplication, one can perhaps start from the strided matrix version: # this needs to be special-cased for all specific types, to avoid method ambiguities :-(
(*)(A::AbstractQ, B::SpecialMatrix) = _qlmul(A, B)
function _qlmul(A::AbstractQ, B)
TAB = promote_type(eltype(A), eltype(B))
Anew = convert(AbstractMatrix{TAB}, A)
if size(A.factors, 1) == size(B, 1)
Bnew = Matrix{TAB}(B)
elseif size(A.factors, 2) == size(B, 1)
Bnew = [Matrix{TAB}(B); zeros(TAB, size(A.factors, 1) - size(B,1), size(B, 2))]
else
throw(DimensionMismatch("first dimension of matrix must have size either $(size(A.factors, 1)) or $(size(A.factors, 2))"))
end
lmul!(Anew, Bnew)
end The competing method is, for instance, |
This fixes some performance problems reported in #38972 and #37102 (multiplying `Q` by a `Diagonal` or `UniformScaling`).
This fixes some performance problems reported in #38972 and #37102 (multiplying `Q` by a `Diagonal` or `UniformScaling`).
This fixes some performance problems reported in #38972 and #37102 (multiplying `Q` by a `Diagonal` or a `UniformScaling`). This improves the performance of generating random orthogonal matrices as described in https://discourse.julialang.org/t/random-orthogonal-matrices/9779/7 significantly.
This fixes two performance bugs reported in https://github.com/JuliaLang/julia/issues/38972 and https://github.com/JuliaLang/julia/issues/38972 (multiplication of `Q` from `qr` by a `Diagonal` or `UniformScaling`). In particular, it improves the performance of generating random orthogonal matrices as described in https://github.com/JuliaLang/julia/issues/38972.
This fixes two performance bugs reported in https://github.com/JuliaLang/julia/issues/38972 and https://github.com/JuliaLang/julia/issues/38972 (multiplication of `Q` from `qr` by a `Diagonal` or `UniformScaling`). In particular, it improves the performance of generating random orthogonal matrices as described in https://discourse.julialang.org/t/random-orthogonal-matrices/9779/7.
* specialize copyto! and multiplication by numbers for Q from qr This fixes two performance bugs reported in https://github.com/JuliaLang/julia/issues/38972 and https://github.com/JuliaLang/julia/issues/38972 (multiplication of `Q` from `qr` by a `Diagonal` or `UniformScaling`). In particular, it improves the performance of generating random orthogonal matrices as described in https://discourse.julialang.org/t/random-orthogonal-matrices/9779/7. * fix typo in new qr tests * resolve mehod ambiguity of copyto!
…Lang#39533) * specialize copyto! and multiplication by numbers for Q from qr This fixes two performance bugs reported in https://github.com/JuliaLang/julia/issues/38972 and https://github.com/JuliaLang/julia/issues/38972 (multiplication of `Q` from `qr` by a `Diagonal` or `UniformScaling`). In particular, it improves the performance of generating random orthogonal matrices as described in https://discourse.julialang.org/t/random-orthogonal-matrices/9779/7. * fix typo in new qr tests * resolve mehod ambiguity of copyto!
…Lang#39533) * specialize copyto! and multiplication by numbers for Q from qr This fixes two performance bugs reported in https://github.com/JuliaLang/julia/issues/38972 and https://github.com/JuliaLang/julia/issues/38972 (multiplication of `Q` from `qr` by a `Diagonal` or `UniformScaling`). In particular, it improves the performance of generating random orthogonal matrices as described in https://discourse.julialang.org/t/random-orthogonal-matrices/9779/7. * fix typo in new qr tests * resolve mehod ambiguity of copyto!
Only |
Uff, that may be the reason for the significantly longer runtimes of the linalg tests. I'll take care of it. |
gives
There seems to be two problems
QRCompactQ
.The same issue was reported for multiplication with
UniformScaling
in Unexpected performance loss #758.I guess the solution is to define the proper methods. Perhaps this would also fix Missing element promotion in I(n)*F.Q' #801.
getindex
forQRCompactQ
This problem could be solved by defining the
getindex
method properly.A bonus would be that one could use
F.Q[:,:]
to retrieve the fullQ
, rather than the cumbersomeF.Q*Matrix(I,m,m)
as suggested in the docstring.For problem 2., the following method seems to work for me, but I guess it needs further consideration and testing.
Perhaps it would also be good to have
If the above methods are introduced it seems like the existing method,
could be removed.
The text was updated successfully, but these errors were encountered: