-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.simba
76 lines (61 loc) · 1.32 KB
/
test.simba
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
program new;
{$i srl.simba}
function strofchar(s: char; num: Integer): String;
var
i: Integer;
begin
Result := '';
for i := 1 to num do
Result := Result + s;
end;
function MaxA(a: TIntegerArray): Integer;
var
L, i: Integer;
begin
L := High(a);
if (L < 0) then
begin
Result := -1;
exit;
end;
Result := a[0];
for i := 1 to L do
if (a[i] > Result) then
Result := a[i];
end;
procedure plotValues();
var
x, err, i, ma: Integer;
vals: TIntegerArray;
time: Integer;
begin
setLength(vals, 101);
time := getSystemTime;
for i := 1 to 100000 do
begin
x := iGaussRange(-50, 50);
if (inRange(x, -50, 50)) then
inc(vals[x+50]) else
inc(err);
end;
time := getSystemTime-time;
ma := MaxA(vals);
if (ma = 0) then
begin
WriteLn('max is 0..');
Exit;
end;
for i := 0 to 100 do
WriteLn(Format('%4.0d:%s [%d]', [i-50, strofchar('=', round(vals[i]*60.0/ma)), vals[i]]));
WriteLn(Format('Time taken: %d ms, %.4f/cycle. Errors: %d',
[time, time/100000.0, err]));
end;
begin
setupGauss();
WriteLn('Gauss Box-Muller Polar:');
SRL_GaussSettings.genStd := @GaussBMPolar;
plotValues();
WriteLn('Gauss n2_gauss');
SRL_GaussSettings.genStd := @n2_gauss;
plotValues();
end.