Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const
- n = 2;
- eps = 1000;
- var
- col, row, i, j: integer;
- r,c,s, row_i, col_i: real;
- mas: array [0..n, 0..n] of real;
- Q: array [0..n, 0..n] of real;
- begin
- mas[0, 0] := 0; mas[0, 1] := -1; mas[0, 2] := 1;
- mas[1, 0] := 4; mas[1, 1] := 2; mas[1, 2] := 0;
- mas[2, 0] := 3; mas[2, 1] := 4; mas[2, 2] := 0;
- Q[0, 0] := 1; Q[0, 1] := 0; Q[0, 2] := 0;
- Q[1, 0] := 0; Q[1, 1] := 1; Q[1, 2] := 0;
- Q[2, 0] := 0; Q[2, 1] := 0; Q[2, 2] := 1;
- for col := 0 to n do
- begin
- for row := col+1 to n do
- if mas[row, col] <> 0 then
- begin
- r := sqrt(mas[col, col]*mas[col, col] + mas[row, col]*mas[row, col]);
- c := mas[col, col] / r;
- s := -mas[row, col] / r;
- for i := 0 to n do
- begin
- {R}
- col_i := mas[col, i] * c + mas[row, i] * (-s);
- row_i := mas[col, i] * s + mas[row, i] * c;
- mas[col, i] := col_i;
- mas[row, i] := row_i;
- {Q}
- col_i := Q[i, col] * c + Q[i, row] * (-s);
- row_i := Q[i, col] * s + Q[i, row] * c;
- Q[i, col] := col_i;
- Q[i, row] := row_i;
- end;
- end;
- end;
- writeln('R:');
- for i := 0 to n do
- begin
- for j := 0 to n do
- write(round(mas[i, j] * eps) / eps, Chr(9));
- writeln();
- end;
- writeln('Q:');
- for i := 0 to n do
- begin
- for j := 0 to n do
- write(round(Q[i, j] * eps) / eps, Chr(9));
- writeln();
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement