summaryrefslogtreecommitdiff
path: root/packages/numlib/examples/invgpdex.pas
blob: c87044132992acdfbf7edf70a38f7856d3acc02e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
program invgpdex;

uses
  typ, iom, inv;

const
  n = 4;
  
var
  i, j, term: ArbInt;
  A: array[1..n, 1..n] of ArbFloat;
  
begin
  Assign(input, ParamStr(1));
  reset(input);
  Assign(output, ParamStr(2));
  rewrite(output);
  writeln('program results invgpdex');
  { read bottomleft part of matrix A}
  for i := 1 to n do
    iomrev(input, A[i, 1], i);
  { Print matrix A}
  writeln;
  writeln('A =');
  for i := 1 to n do
    for j := 1 to i - 1 do
      A[j, i] := A[i, j];
  iomwrm(output, A[1, 1], n, n, n, numdig);
  { Calculate inverse of matrix A}
  invgpd(n, n, A[1, 1], term);
  writeln;
  writeln('term=', term: 2);
  if term = 1 then
    { Print inverse of matrix A}
  begin
    writeln;
    writeln('inverse of A =');
    iomwrm(output, A[1, 1], n, n, n, numdig);
  end; {term=1}
  Close(input);
  Close(output);
end.