Skip to content

Instantly share code, notes, and snippets.

@eamartin
Created November 12, 2013 21:49
Show Gist options
  • Save eamartin/7439407 to your computer and use it in GitHub Desktop.
Save eamartin/7439407 to your computer and use it in GitHub Desktop.
A
A =
5 -1 0 0
-1 5 -1 0
0 -1 5 -1
0 0 -1 5
sigma = 5;
A - sigma
ans =
0 -6 -5 -5
-6 0 -6 -5
-5 -6 0 -6
-5 -5 -6 0
[Q, R] = qr(A - sigma)
Q =
0 -0.7631 0.5098 -0.3973
0.6470 0.4880 0.3893 -0.4378
0.5392 -0.3564 -0.7232 -0.2435
0.5392 -0.2292 0.2561 0.7689
R =
-9.2736 -5.9308 -7.1170 -6.4700
0 7.8629 2.2626 3.5137
0 0 -6.4210 -0.1563
0 0 0 5.6364
R * Q
ans =
-11.1628 8.2017 -3.5462 3.0389
8.2017 2.2254 2.3243 -1.2920
-3.5462 2.3243 4.6036 1.4433
3.0389 -1.2920 1.4433 4.3338
R * Q + sigma
ans =
-6.1628 13.2017 1.4538 8.0389
13.2017 7.2254 7.3243 3.7080
1.4538 7.3243 9.6036 6.4433
8.0389 3.7080 6.4433 9.3338
diary off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment