From: samah karim on 26 Mar 2010 05:39 i coded the process in MATLAB, it goes as follows: function [F,G]=GramSchmidt(E,tol) % Input: E is an m by n matrix of full rank m<=n % tol: our zero tolerance % Output: An orthogonal matrix F, the product of the Gram Schmidt process % applied on the columns of E % F must verify F*F'=I [m,n]=size(E); F=zeros(m); G=zeros(m); % Start the process e=E(:,1);c=sqrt(e'*e); f=(1/c)*e; F(:,1)=f; G(1,1)=c; for k=2:m % select the kth column of E e=E(:,k); % Project e on the span of f1,...f_{k-1} p=zeros(m,1); for j=1:k-1 G(j,k)=e'*F(:,j); p=p+G(j,k)*F(:,j); end v=e-p;c=sqrt(v'*v); if c<tol fprintf('Process breaks at %i/n ',k) break else F(:,k)=(1/c)*v; G(k,k)=c; end end it's working perfectly with real matrices, but when E is complex, the output matrix F is no longer orthogonal. The vectors F(:,j) have norms = 1 so that part is fine, but they're not mutually orthogonal. and i can't figure out the source of the problem. help please
From: Bruno Luong on 26 Mar 2010 05:49 > G(j,k)=e'*F(:,j); Replace with G(j,k)=F(:,j)'*e; Bruno
From: samah karim on 31 Mar 2010 10:20 Thank u Bruno! It worked :D But i can't figure out why t worked, why should i change it if it's complex? Well i read it in many books that the projection should be given by e'*f? Please help. thank you.
From: Bruno Luong on 31 Mar 2010 10:34 "samah karim" <sammouha_007(a)hotmail.com> wrote in message <hovln3$4dr$1(a)fred.mathworks.com>... > Thank u Bruno! It worked :D > But i can't figure out why t worked, why should i change it if it's complex? Because the first version of your code is the conjugate of the right expression. For real matrix, conjugate does not matter. > Well i read it in many books that the projection should be given by e'*f? The book is wrong then. Bruno
From: samah karim on 31 Mar 2010 11:05
i mean i read that the projection of the 2nd column vector on the normalized 1st one, is given by e'*f but i never found any description of the problem when the matrix is complex. Do u have any references(websites,books) about this topic in particular(i.e. Gram-Scmidt with complex matrices) so i can understand the math behind this change? |