Skip to content

Commit

Permalink
Use dot and views in QR code
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie committed Dec 23, 2020
1 parent 0e15141 commit 512ccf2
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions stdlib/LinearAlgebra/src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1490,14 +1490,10 @@ end
n == 0 && return zero(eltype(x))
@inbounds begin
ξ1 = x[1]
normu = abs2(ξ1)
for i = 2:n
normu += abs2(x[i])
end
normu = norm(x)
if iszero(normu)
return zero(ξ1/normu)
end
normu = sqrt(normu)
ν = copysign(normu, real(ξ1))
ξ1 += ν
x[1] = -ν
Expand All @@ -1516,22 +1512,11 @@ end
throw(DimensionMismatch("reflector has length $(length(x)), which must match the first dimension of matrix A, $m"))
end
m == 0 && return A
@inbounds begin
for j = 1:n
# dot
vAj = A[1, j]
for i = 2:m
vAj += x[i]'*A[i, j]
end

vAj = conj(τ)*vAj

# ger
A[1, j] -= vAj
for i = 2:m
A[i, j] -= x[i]*vAj
end
end
@inbounds for j = 1:n
Aj, xj = view(A, 2:m, j), view(x, 2:m)
vAj = conj(τ)*(A[1, j] + dot(xj, Aj))
A[1, j] -= vAj
axpy!(-vAj, xj, Aj)
end
return A
end
Expand Down

0 comments on commit 512ccf2

Please sign in to comment.