using LinearAlgebra
Copyright By PowCoder代写 加微信 powcoder
function householder(s, x) # s = ±1
n = length(x)
e1 = [1; zeros(n-1)]
y = -s*norm(x)*e1 + x
w = y/norm(y)
householder (generic function with 1 method)
Q = householder(-sign(x[1]), x)
2-element Vector{Float64}:
n = length(x)
e1 = [1; zeros(n-1)]
-norm(x)*e1 , x
([-1.0, -0.0], [1.0, 1.0e-9])
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com