-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Avoid some unintended calls to generic_matmatmul! for special matrices #16615
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,16 +106,16 @@ end | |
| ## Multiplication by Q | ||
| ### QB | ||
| A_mul_B!{T<:BlasFloat}(A::LQPackedQ{T}, B::StridedVecOrMat{T}) = LAPACK.ormlq!('L','N',A.factors,A.τ,B) | ||
| function *{TA,TB}(A::LQPackedQ{TA},B::StridedVecOrMat{TB}) | ||
| TAB = promote_type(TA, TB) | ||
| function (*)(A::LQPackedQ,B::StridedVecOrMat) | ||
| TAB = promote_type(eltype(A), eltype(B)) | ||
| A_mul_B!(convert(AbstractMatrix{TAB}, A), copy_oftype(B, TAB)) | ||
| end | ||
|
|
||
| ### QcB | ||
| Ac_mul_B!{T<:BlasReal}(A::LQPackedQ{T}, B::StridedVecOrMat{T}) = LAPACK.ormlq!('L','T',A.factors,A.τ,B) | ||
| Ac_mul_B!{T<:BlasComplex}(A::LQPackedQ{T}, B::StridedVecOrMat{T}) = LAPACK.ormlq!('L','C',A.factors,A.τ,B) | ||
| function Ac_mul_B{TA,TB}(A::LQPackedQ{TA}, B::StridedVecOrMat{TB}) | ||
| TAB = promote_type(TA,TB) | ||
| function Ac_mul_B(A::LQPackedQ, B::StridedVecOrMat) | ||
| TAB = promote_type(eltype(A), eltype(B)) | ||
| if size(B,1) == size(A.factors,2) | ||
| Ac_mul_B!(convert(AbstractMatrix{TAB}, A), copy_oftype(B, TAB)) | ||
| elseif size(B,1) == size(A.factors,1) | ||
|
|
@@ -125,6 +125,19 @@ function Ac_mul_B{TA,TB}(A::LQPackedQ{TA}, B::StridedVecOrMat{TB}) | |
| end | ||
| end | ||
|
|
||
| ### QBc/QcBc | ||
| for (f1, f2) in ((:A_mul_Bc, :A_mul_B!), | ||
| (:Ac_mul_Bc, :Ac_mul_B!)) | ||
| @eval begin | ||
| function ($f1)(A::LQPackedQ, B::StridedVecOrMat) | ||
| TAB = promote_type(eltype(A), eltype(B)) | ||
| BB = similar(B, TAB, (size(B, 2), size(B, 1))) | ||
| ctranspose!(BB, B) | ||
| return ($f2)(A, BB) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| ### AQ | ||
| A_mul_B!{T<:BlasFloat}(A::StridedMatrix{T}, B::LQPackedQ{T}) = LAPACK.ormlq!('R', 'N', B.factors, B.τ, A) | ||
| function *{TA,TB}(A::StridedMatrix{TA},B::LQPackedQ{TB}) | ||
|
|
@@ -146,6 +159,19 @@ function A_mul_Bc{TA<:Number,TB<:Number}( A::StridedVecOrMat{TA}, B::LQPackedQ{T | |
| A_mul_Bc!(copy_oftype(A, TAB), convert(AbstractMatrix{TAB},(B))) | ||
| end | ||
|
|
||
| ### AcQ/AcQc | ||
| for (f1, f2) in ((:Ac_mul_B, :A_mul_B!), | ||
| (:Ac_mul_Bc, :A_mul_Bc!)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because I explicitly transpose
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah right I think I was reading this as a loop of 4 definitions, sorry |
||
| @eval begin | ||
| function ($f1)(A::StridedMatrix, B::LQPackedQ) | ||
| TAB = promote_type(eltype(A), eltype(B)) | ||
| AA = similar(A, TAB, (size(A, 2), size(A, 1))) | ||
| ctranspose!(AA, A) | ||
| return ($f2)(AA, B) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| function \{TA,Tb}(A::LQ{TA}, b::StridedVector{Tb}) | ||
| S = promote_type(TA,Tb) | ||
| m = checksquare(A) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transpose!