I defined Gram-Schmidt like this:
GS[A_] := Module[{u = {}, col, e = {}, ae, t},
col = Transpose[A];(* lista dos vectores coluna de A *)
u = Append[u, col[[1]]];
e = 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++];
u = AppendTo[u, col[[i]] + ae];
e = Append[e, u[[i]]/Norm[u[[i]]]]]; {u, e}]
and I defined a QR decomposition:
QR[A_] := Module[{Ak, i, Q, R = {}, a = {}, col, k},
Ak = FullSimplify[GS[A]];
col = Transpose[A];(* lista dos vectores coluna de A *)
Q = Transpose[Ak[[2]]];
For[i = 1, i <= Length[Ak[[2]]], i++, a = {}; k = 1;
While[k <= Length[col], a = AppendTo[a, col[[k]]. Ak[[2]][[i]]];
k++];
R = AppendTo[R, a]];
R = UpperTriangularize[FullSimplify[R]]; {Q, R}]
I want to do my QR with this matrix:
SJorge = Import[
StringJoin[
"https://c2.staticflickr.com/4/3463/3823583611_c80bf5a375_b.jpg"]]\
;
imagem = ColorConvert[SJorge, "Grayscale"];
M = ImageData[imagem, "Byte"];
That have as dimensions {521,1023}. My code runs but doesn't give any values back. I works for normal and short matrixes.
Need Help..Thanks!
OrthogonalizeandQRDecomposition? – cvgmt Dec 07 '20 at 00:22AppendTothen something like “u=AppendTo...” is unnecessary asAppendTodoes exactly what you are trying to do with theu=portion & may result in a longer computation time. – CA Trevillian Dec 07 '20 at 03:09