diff options
Diffstat (limited to '191/CH4/EX4.13/Example4_13.sce')
-rwxr-xr-x | 191/CH4/EX4.13/Example4_13.sce | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/191/CH4/EX4.13/Example4_13.sce b/191/CH4/EX4.13/Example4_13.sce new file mode 100755 index 000000000..13af20e4e --- /dev/null +++ b/191/CH4/EX4.13/Example4_13.sce @@ -0,0 +1,31 @@ +//Orthogonal decomposition - QR method
+//reduce A to tridiagonal form
+clc;
+clear;
+close();
+format('v',7);
+A1 = [1 4 2;-1 2 0;1 3 -1];
+disp(A1, 'A = ');
+// zero is created in lower triangle
+//by taking the rotation matrix X1=[c s 0;-s c 0;0 0 1]; where c=cos and s=sin
+//O is theta
+
+Q = eye(3,3);
+for i=2:3
+ for j=1:i-1
+ p=i;q=j;
+ O = -atan(A1(p,q)/(A1(q,q)));
+ c = cos(O);
+ s = sin(O);
+ X = eye(3,3);
+ X(p,p)=c;
+ X(q,q)=c;
+ X(p,q)=-s;
+ X(q,p)=s;
+ A1 = X'*A1;
+ Q = Q*X;
+ disp(A1,X,'The X and A matrix : ');
+ end
+end
+R = A1;
+disp(R,Q,'Hence the original matrix can be decomposed as : ')
\ No newline at end of file |