http://faculty.salina.k-state.edu/tim/DAT/linAlg/appendixLA/QR.html
Implementation of Gram Schmidt
Gram Schmidt and Orthogonal (QR) Factoring
The Gram Schmidt algorithm has two primary applications. In some physics applications one might have a set basis vectors which are not orthonormal. The Gram Schmidt algorithm can be used to find a new set of basis vectors that are orthonormal. The other application is a matrix factoring resulting in one matrix, , with orthonormal columns and another matrix, , which is upper triangular.
The discussion here focuses on QR factoring, but can be equally be applied to finding orthonormal basis vectors from the columns of a matrix.
Note
What is defined here is the classic Gram – Schmidt process. MATLAB has two functions that implement a modified version of the classic Gram – Schmidt process. The function orth( )
finds orthogonal basis vectors, while the function qr( )
factors a matrix into an orthogonal matrix and an upper triangular matrix. The results of both functions are different from what results from a direct implementation of the classic Gram – Schmidt process. According to the MATLAB documentation, the classic Gram – Schmidt process is numerically unstable. But for our introduction, we will stick with the classic algorithm.
6.11.5.1. The Gram Schmidt Algorithm
The columns of are first formed from vector projections (see Projections Onto a Line), and then made unit length. Recall that when a vector is projected onto another vector, the vector representing the error between the projection and original vector are perpendicular to each other. Here it is the vector representing the error from projection is what we want.
Let matrix be formed from column vectors.
We will first find a matrix, , who’s columns are orthogonal and are formed from projections of the columns of . For each column after the first, we subtract the projection of the column onto the previous columns. Thus we are subtracting away the projection leaving a vector that is orthogonal to the previous column vector.
The columns of are then unit vectors of the columns of .
Then is found from and . Because has orthonormal columns, . Because the matrix multiplication involves dot products of orthogonal vectors, matrix will be upper triangular.
MATLAB has a command, [Q, R] = qr(A)
that finds the factors and .
No hay comentarios:
Publicar un comentario