I need to make all other columns of a matrix A
orthogonal to one of its column j
.
I use the following algorithm :
# Orthogonalize with selected column
for i in remaining_cols:
A[:,i] = A[:,i] - A[:,j] * np.dot(A[:,i], A[:,j]) / np.sum(A[:,j]**2)
The idea comes from the QR decomposition with the Gram-Schmidt process.
But this code is not optimized and unstable because of the Gram-Schmidt process.
Does Numpy provide any method to compute the orthogonal projection of those vectors ?
With Householder Matrix
I heard that the Householder Reflectors are used in numpy.linalg.qr
. This would allow me to compute an orthogonal matrix Q
so that
Q * A[:,j] = [0 ... 0 1 0 ... 0]
|
j_th coordinate
I would only have to ignore the line j
and multiply back with Q.T
.
Is there a method to obtain the Householder Matrix with Numpy ? I mean without coding the algorithm by hand.