summaryrefslogtreecommitdiff
path: root/packages/extra/numlib/tests/slegsylt.pas
blob: a26a22fb058ec0e9eacbb07af55b87f52bc5bd05 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
program slegsylt;

uses
  typ,
  iom,
  sle;

const
  m1   = -8;
  m2   = 12;
  nmax = 10;

type
  row = array[1..nmax] of ArbFloat;

var
  i, j, n, k, l, v, nv, term: ArbInt;
  ca:   ArbFloat;
  b, x: array[m1..m2] of ArbFloat;
  a:    array[m1..m2] of ^row;
begin
  Assign(input, ParamStr(1));
  Reset(input);
  Assign(output, ParamStr(2));
  Rewrite(output);

  Write('program results slegsylt ');
  case SizeOf(ArbFloat) of
    4: writeln('(single)');
    8: writeln('(double)');
    6: writeln('(real)');
  end;
  writeln;
  Read(randseed);
  writeln('  randseed = ', randseed: 15);
  Read(nv);
  writeln;
  writeln('   number of examples: ', nv: 2);
  for v := 1 to nv do
  begin
    writeln;
    writeln('  example number :', v: 2);
    Read(k, l, n);
    for i := 1 to n do
    begin
      Getmem(a[i + k - 1], n * sizeOf(ArbFloat));
      iomrev(input, a[i + k - 1]^[1], i);
    end;
    iomrev(input, b[l], n);
    slegsyl(n, a[k], b[l], x[l], ca, term);
    writeln;
    writeln(' A =');
    for i := 1 to n do
      for j := i + 1 to n do
        a[i + k - 1]^[j] := a[j + k - 1]^[i];
    for i := 1 to n do
      iomwrv(output, a[i + k - 1]^[1], n, numdig);
    for i := n downto 1 do
      Freemem(a[i + k - 1], n * sizeOf(ArbFloat));
    writeln;
    writeln('b=');
    iomwrv(output, b[l], n, numdig);
    writeln;
    writeln('term=', term: 2);
    writeln;
    case term of
      1:
      begin
        writeln('x=');
        iomwrv(output, x[l], 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 slegsylt;

uses
  typ,
  iom,
  sle;

const
  m1   = -8;
  m2   = 12;
  nmax = 10;

type
  row = array[1..nmax] of ArbFloat;

var
  i, j, n, k, l, v, nv, term: ArbInt;
  ca:   ArbFloat;
  b, x: array[m1..m2] of ArbFloat;
  a:    array[m1..m2] of ^row;
begin
  Assign(input, ParamStr(1));
  Reset(input);
  Assign(output, ParamStr(2));
  Rewrite(output);

  Write('program results slegsylt ');
  case SizeOf(ArbFloat) of
    4: writeln('(single)');
    8: writeln('(double)');
    6: writeln('(real)');
  end;
  writeln;
  Read(randseed);
  writeln('  randseed = ', randseed: 15);
  Read(nv);
  writeln;
  writeln('   number of examples: ', nv: 2);
  for v := 1 to nv do
  begin
    writeln;
    writeln('  example number :', v: 2);
    Read(k, l, n);
    for i := 1 to n do
    begin
      Getmem(a[i + k - 1], n * sizeOf(ArbFloat));
      iomrev(input, a[i + k - 1]^[1], i);
    end;
    iomrev(input, b[l], n);
    slegsyl(n, a[k], b[l], x[l], ca, term);
    writeln;
    writeln(' A =');
    for i := 1 to n do
      for j := i + 1 to n do
        a[i + k - 1]^[j] := a[j + k - 1]^[i];
    for i := 1 to n do
      iomwrv(output, a[i + k - 1]^[1], n, numdig);
    for i := n downto 1 do
      Freemem(a[i + k - 1], n * sizeOf(ArbFloat));
    writeln;
    writeln('b=');
    iomwrv(output, b[l], n, numdig);
    writeln;
    writeln('term=', term: 2);
    writeln;
    case term of
      1:
      begin
        writeln('x=');
        iomwrv(output, x[l], n, numdig);
        writeln;
        writeln(' ca = ', ca: 12);
      end;
      2: writeln('solution not possible');
      3: writeln(' wrong value of n');
    end;
    writeln('-----------------------------------------------');
  end; {example}
end.