# QR分解，LinearAlgebra包中计算结果疑问，望指教！

#1

using LinearAlgebra
A = [ 12.0 -51.0   4.0;
6.0  167.0 -68.0;
-4.0   24.0 -41.0]

F = qr(A)
Q = Matrix(F.Q)
R = F.R


B = [-3.0 -6.0;
4.0 8.0;
0.0 1.0]
FB = qr(B)
FQ = Matrix(FB.Q)
FR = FB.R


#2

wiki上的算法适合手算，不一定是最有效率的算法。

#3

#4

#5

#6

Let {\displaystyle \mathbf {x} } be an arbitrary real m -dimensional column vector of {\displaystyle A} such that {\displaystyle |\mathbf {x} |=|\alpha |} for a scalar α . If the algorithm is implemented using floating-point arithmetic, then α should get the opposite sign as the k -th coordinate of {\displaystyle \mathbf {x} }, where {\displaystyle x_{k}} is to be the pivot coordinate after which all entries are 0 in matrix A 's final upper triangular form, to avoid loss of significance.

https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections