# So, let's do Gram-Schmidt and generate a QR factorization
v1 = A(:,1);
v2 = A(:,2);
v3 = A(:,3);
v4 = A(:,4);
disp("Here are the original vectors")
V = [v1 v2 v3 v4];
printf ("% 4.0f % 4.0f % 4.0f % 4.0f \n", V');
disp("Now apply Gram-Schmidt")
u1 = v1;
u2 = v2 - (v2'*u1)/(u1'*u1)*u1;
u3 = v3 - (v3'*u1)/(u1'*u1)*u1 - (v3'*u2)/(u2'*u2)*u2;
u4 = v4 - (v4'*u1)/(u1'*u1)*u1 - (v4'*u2)/(u2'*u2)*u2 - (v4'*u3)/(u3'*u3)*u3;
Q = [u1 u2 u3 u4];
printf ("% 5.3f % 5.3f % 5.3f % 5.3f \n", Q');
R = Q'*A
|
Here are the original vectors
1 3 -3 0
-1 -5 -4 -2
-1 -1 2 -1
-1 -5 3 1
-3 3 -2 -4
0 -4 0 1
Now apply Gram-Schmidt
1.000 2.615 -2.752 0.272
-1.000 -4.615 -4.556 -0.347
-1.000 -0.615 2.059 -0.684
-1.000 -4.615 2.444 0.454
-3.000 4.154 -0.900 0.283
0.000 -4.000 -0.615 0.452
R =
1.3000e+01 5.0000e+00 2.0000e+00 1.4000e+01
-3.5527e-15 8.3077e+01 -1.2769e+01 -1.5385e+01
-4.4409e-16 4.4409e-15 3.9730e+01 1.2481e+01
2.2204e-16 5.1070e-15 4.3299e-15 1.1529e+00
Here are the original vectors
1 3 -3 0
-1 -5 -4 -2
-1 -1 2 -1
-1 -5 3 1
-3 3 -2 -4
0 -4 0 1
Now apply Gram-Schmidt
1.000 2.615 -2.752 0.272
-1.000 -4.615 -4.556 -0.347
-1.000 -0.615 2.059 -0.684
-1.000 -4.615 2.444 0.454
-3.000 4.154 -0.900 0.283
0.000 -4.000 -0.615 0.452
R =
1.3000e+01 5.0000e+00 2.0000e+00 1.4000e+01
-3.5527e-15 8.3077e+01 -1.2769e+01 -1.5385e+01
-4.4409e-16 4.4409e-15 3.9730e+01 1.2481e+01
2.2204e-16 5.1070e-15 4.3299e-15 1.1529e+00
|