Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Gram–Schmidt process
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Algorithm == The following [[MATLAB]] algorithm implements classical Gram–Schmidt orthonormalization. The vectors {{math|'''v'''<sub>1</sub>, ..., '''v'''<sub>''k''</sub>}} (columns of matrix <code>V</code>, so that <code>V(:,j)</code> is the <math>j</math>th vector) are replaced by orthonormal vectors (columns of <code>U</code>) which span the same subspace. <syntaxhighlight lang="matlab" line="1"> function U = gramschmidt(V) [n, k] = size(V); U = zeros(n,k); U(:,1) = V(:,1) / norm(V(:,1)); for i = 2:k U(:,i) = V(:,i); for j = 1:i-1 U(:,i) = U(:,i) - (U(:,j)'*U(:,i)) * U(:,j); end U(:,i) = U(:,i) / norm(U(:,i)); end end </syntaxhighlight> The cost of this algorithm is asymptotically {{math|O(''nk''<sup>2</sup>)}} floating point operations, where {{mvar|n}} is the dimensionality of the vectors.{{sfn|Golub|Van Loan|1996|loc=§5.2.8}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)