© 2014 W.Ehrhardt | Last update Oct. 13, 2014 |
Home | CRC/Hash | Crypto | Misc. | Info | Links | Deutsch |
Miscellaneous |
procedure generic_init(var ctx: generic_ctx; seed: longint); {-Init context from seed} procedure generic_init0(var ctx: generic_ctx); {-Init context from randseed} procedure generic_next(var ctx: generic_ctx); {-Next step of PRNG} procedure generic_read(var ctx: generic_ctx; dest: pointer; len: longint); {-Read len bytes from the PRNG to dest} function generic_long(var ctx: generic_ctx): longint; {-Next random positive longint} function generic_dword(var ctx: xor4096_ctx): {$ifdef HAS_CARD32}cardinal{$else}longint{$endif}; {-Next 32 bit random dword (cardinal or longint)} function generic_word(var ctx: generic_ctx): word; {-Next random word} function generic_double(var ctx: generic_ctx): double; {-Next random double [0..1) with 32 bit precision} function generic_double53(var ctx: generic_ctx): double; {-Next random double in [0..1) with 53 bit precision} function generic_selftest: boolean; {-Simple self-test of PRNG}Table of properties (C/B: CPU cycles per byte, MB/s: million bytes per second on 1.8 GHz Pentium 4 / Windows 98, P7: Borland Pascal 7 real mode with 386 BASM; isaac was compiled with {$define testing}):
Generator | ctx size | cycle length | C/B P7 | MB/s P7 | C/B D6 | MB/s D6 |
---|---|---|---|---|---|---|
random | (4) | 2**32 | 79.0 | 22.7 | 7.5 | 239.0 |
taus88 | 16 | 2**88 | 80.5 | 22.3 | 6.5 | 275.8 |
taus113 | 20 | 2**113 | 83.0 | 21.6 | 8.3 | 217.3 |
kiss123 | 20 | 2**123 | 96.0 | 18.7 | 11.8 | 152.6 |
tt800 | 106 | 2**800 | 230.8 | 7.8 | 18.1 | 99.2 |
xor4096 | 522 | 2**4096 | 82.5 | 21.7 | 5.8 | 311.8 |
mt19937 | 2502 | 2**19937 | 220.3 | 8.1 | 8.3 | 216.2 |
aesr | 290 | 2**128 | 236.0 | 7.6 | 28.4 | 63.2 |
salsar | 202 | 2**70 | 109.3 | 16.4 | 14.4 | 124.8 |
isaac | 2066 | 2**8295 | 109.5 | 16.3 | 9.1 | 197.8 |
It is known since more than 15 years that exp looses up to 13 bits for extended arguments; even the newer Delphi versions (confirmed up to D14, some are corrected in D17) have horrible bugs: e.g. arccsch(2) = 0.27980789397 (correct = 0.48121182506); coth(12000)=1 crashes; sech(12000)=0 crashes; sinh(x)/x=0 for small x; sin(1e22)=1e22 (correct = -0.852200849767); StdDev(a,a+1,a+2) crashes e.g. for a=100000000000; etc..
AMath's elementary mathematical functions include: exponential, logarithmic,
trigonometric, hyperbolic, inverse circular / hyperbolic functions.
There are polynomial, vector, statistic operations as well as
floating point and FPU control functions. Delphi's nonsense routines
(IfThen, IsZero, InRange ...) and its financial functions are not
(and will not be) implemented. Here is the complete list of
AMath functions with short descriptions.
All standard one argument elementary transcendental functions have peak relative errors less than
2.2e-19, values for power(x,y) are 2.1e-19 (for |x|,|y| < 1000) and 3.4e-19
(for |x|,|y| < 2000). The precision is tested with the t_amathx
program using MPArith functions.
The ext2 (double-extended) routines operate on pairs of extended floating
point numbers, which represent the unevaluated sum of the high and low parts:
a = (a.h, a.l) = a.h + a.l, normally with |a.l| ≤ eps_x*|a.h|.
Home | CRC/Hash | Crypto | Misc. | Info | Links | Deutsch |