summaryrefslogtreecommitdiff
path: root/packages/numlib/tests/slegente.pas
blob: bfefefdb9c4fde69a4d50992bbd67df7693a00e3 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
program slegente;

uses
  typ,
  iom,
  sle;

const
  m1 = -10;
  m2 = 10;
  n1 = -10;
  n2 = 10;

type
  array1dr = array[m1..m2] of ArbFloat;
  array2dr = array[m1..m2, n1..n2] of ArbFloat;

var
  v, nv, k, j, n, term: ArbInt;
  ca:   ArbFloat;
  a:    array2dr;
  b, x: array1dr;
begin
  Write('program results slegente ');
  case SizeOf(ArbFloat) of
    4: writeln('(single)');
    8: writeln('(double)');
    6: writeln('(real)');
  end;
  Read(nv);
  writeln;
  writeln('   number of examples: ', nv: 2);
  for v := 1 to nv do
  begin
    writeln;
    writeln('  example number :', v: 2);
    Read(k, j, n);
    iomrem(input, a[k, j], n, n, n2 - n1 + 1);
    iomrev(input, b[k], n);
    slegen(n, n2 - n1 + 1, a[k, j], b[k], x[k], ca, term);
    writeln;
    writeln(' A =');
    iomwrm(output, a[k, j], n, n, n2 - n1 + 1, numdig);
    writeln;
    writeln('b=');
    iomwrv(output, b[k], n, numdig);
    writeln;
    writeln('term=', term: 2);
    writeln;
    case term of
      1:
      begin
        writeln('x=');
        iomwrv(output, x[k], n, numdig);
        writeln;
        writeln(' ca = ', ca: 12);
      end;
      2: writeln('solution not possible');
      3: writeln(' wrong value of n');
    end;
    writeln('-----------------------------------------------');
  end; {example}
end.
program slegente;

uses
  typ,
  iom,
  sle;

const
  m1 = -10;
  m2 = 10;
  n1 = -10;
  n2 = 10;

type
  array1dr = array[m1..m2] of ArbFloat;
  array2dr = array[m1..m2, n1..n2] of ArbFloat;

var
  v, nv, k, j, n, term: ArbInt;
  ca:   ArbFloat;
  a:    array2dr;
  b, x: array1dr;
begin
  Write('program results slegente ');
  case SizeOf(ArbFloat) of
    4: writeln('(single)');
    8: writeln('(double)');
    6: writeln('(real)');
  end;
  Read(nv);
  writeln;
  writeln('   number of examples: ', nv: 2);
  for v := 1 to nv do
  begin
    writeln;
    writeln('  example number :', v: 2);
    Read(k, j, n);
    iomrem(input, a[k, j], n, n, n2 - n1 + 1);
    iomrev(input, b[k], n);
    slegen(n, n2 - n1 + 1, a[k, j], b[k], x[k], ca, term);
    writeln;
    writeln(' A =');
    iomwrm(output, a[k, j], n, n, n2 - n1 + 1, numdig);
    writeln;
    writeln('b=');
    iomwrv(output, b[k], n, numdig);
    writeln;
    writeln('term=', term: 2);
    writeln;
    case term of
      1:
      begin
        writeln('x=');
        iomwrv(output, x[k], n, numdig);
        writeln;
        writeln(' ca = ', ca: 12);
      end;
      2: writeln('solution not possible');
      3: writeln(' wrong value of n');
    end;
    writeln('-----------------------------------------------');
  end; {example}
end.