Hello folks,
I'm new to Matlab and tackling numerical linear algebra with it.
I am trying to get some practice ahead and right now, I'm having issues with my basic QR factorization.
Basically, I'm writing my own general Gram Schmidt code that would take in a matrix A of size mxn and spit out Q(mxn) and R(nxn)
to give you the context of the calculation:
1_ given a matrix A =[a_1, a_2,..... a_n] where a_i are vectors of size (m, 1)
2_ I calculate the elements of Q=[q_1, q_2,... q_n] where q_i=h_i/||h_i||
3_Where h_i is a vector built from the following expression : h_i=a_i-sum(j=0 to i, q_j*(q_j)'*a_i
4_ I calculate the elements of R=[r_1, r_2,..... r_n] as follows : r_11=||a_1||=a_1*(a_1)', for i<j r_ij=(q_i)'*(a_j), for i=j r_ij=||h_i|| and else r_ij=0
I finally got my code running but it spits out intermediary R that don't match the final R I am supposed to get and there is no sign of Q.
Any insight on what is wrong is welcome, anything to improve on it as well.
attached is my code. thank you!