Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Application of Householder reflector from right
# apply reflector from right
# derived from base/linalg/generic.jl
@inline function reflectorApplyRight!(x::AbstractVector, τ::Number, A::AbstractMatrix)
m, n = size(A)
if length(x) != n
throw(DimensionMismatch("reflector has length $(length(x)), which must match the first dimension of matrix A, $n"))
end
@inbounds begin
for i = 1:m
# note: ommited x[1] == 1
# dot
Aiv = A[i, 1]
for j = 2:n
Aiv += A[i, j]*x[j]
end
Aiv = τ*Aiv
# ger
A[i, 1] -= Aiv
for j = 2:n
A[i, j] -= Aiv*x[j]'
end
end
end
return A
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.