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

Make sure lmul! and rmul! for Givens rotations are inlined. #28138

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/src/givens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,26 +334,26 @@ function getindex(G::Givens, i::Integer, j::Integer)
end
end

function lmul!(G::Givens, A::AbstractVecOrMat)
@inline function lmul!(G::Givens, A::AbstractVecOrMat)
@assert !has_offset_axes(A)
m, n = size(A, 1), size(A, 2)
if G.i2 > m
throw(DimensionMismatch("column indices for rotation are outside the matrix"))
end
@inbounds @simd for i = 1:n
@inbounds for i = 1:n
a1, a2 = A[G.i1,i], A[G.i2,i]
A[G.i1,i] = G.c *a1 + G.s*a2
A[G.i2,i] = -conj(G.s)*a1 + G.c*a2
end
return A
end
function rmul!(A::AbstractMatrix, G::Givens)
@inline function rmul!(A::AbstractMatrix, G::Givens)
@assert !has_offset_axes(A)
m, n = size(A, 1), size(A, 2)
if G.i2 > n
throw(DimensionMismatch("column indices for rotation are outside the matrix"))
end
@inbounds @simd for i = 1:m
@inbounds for i = 1:m
a1, a2 = A[i,G.i1], A[i,G.i2]
A[i,G.i1] = a1*G.c - a2*G.s'
A[i,G.i2] = a1*G.s + a2*G.c
Expand Down