I have this code for Gram Schmidt:
GS[A_] :=
Module[{u = {}, col, e = {}, ae, t},
col = Transpose[A]; (* lista dos vectores coluna de A *)
AppendTo[u, col[[1]]];
AppendTo[e, u[[1]]/Norm[u[[1]]]];
For[i = 2, i <= Length[col], i++,
ae = 0;
t = 1;
While[t <= i - 1, ae = ae - (col[[i]].e[[t]])*e[[t]]; t++];
AppendTo[u, col[[i]] + ae];
AppendTo[e, u[[i]]/Norm[u[[i]]]]];
{u, e}]
And this is my code for QR decomposition:
QR[A_] :=
Module[{Ak, i, Q, R, a = {}, col, k},
Ak = FullSimplify[GS[A]];
col = Transpose[A];
Q = Transpose[Ak[[2]]];
R = Ak[[2]].A;
R = UpperTriangularize[FullSimplify[R]];
{Q, R}]
I want to test this code with this matrix:
SJorge =
Import[
StringJoin["https://c2.staticflickr.com/4/3463/3823583611_c80bf5a375_b.jpg"]];
imagem = ColorConvert[SJorge, "Grayscale"];
M = ImageData[imagem, "Byte"];
It's giving results different than from what I get when I do
QRDecompoition[N[M]]`
op
QR[N[M]]
Need some help.