© 2018 W.Ehrhardt | Last update Feb. 17, 2018 |
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: generic_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_rangew(var ctx: generic_ctx; range: word): word; {-Next random word in range 0..range-1} function generic_rangel(var ctx: generic_ctx; range: longint): longint; {-Next random longint in range 0..range-1} 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.7 GHz Pentium 4 / Windows 98: BP7 = Borland Pascal 7 real mode with 386 BASM and D6 = Delphi 6; on Win7/64 Core i3-2350M: D18/64 = Delphi 18 64-bit. Note that isaac was compiled with {$define testing}):
BP7 | BP7 | D6 | D6 | D18/64 | D18/64 | |||
---|---|---|---|---|---|---|---|---|
Generator | ctx size | cycle length | C/B | MB/s | C/B | MB/s | C/B | MB/s |
pasrand | 4 | 2**32 | 74.0 | 22.9 | 5.0 | 294.0 | 5.0 | 459.0 |
taus88 | 16 | 2**88 | 79.0 | 21.5 | 8.0 | 211.9 | 10.8 | 213.5 |
taus113 | 20 | 2**113 | 85.0 | 20.0 | 8.0 | 211.9 | 13.5 | 170.0 |
kiss123 | 20 | 2**123 | 114.0 | 14.9 | 13.3 | 127.9 | 15.0 | 153.0 |
tt800 | 106 | 2**800 | 308.3 | 5.5 | 18.5 | 91.7 | 18.0 | 126.7 |
well1024a | 134 | 2**1024 | 166.5 | 10.2 | 7.8 | 218.7 | 13.8 | 166.9 |
xor4096 | 522 | 2**4096 | 80.0 | 21.0 | 6.5 | 260.7 | 12.3 | 187.3 |
mt19937 | 2502 | 2**19937 | 227.4 | 7.4 | 8.3 | 204.5 | 12.6 | 181.5 |
aesr | 290 | 2**128 | 211.2 | 8.0 | 28.4 | 59.7 | 60.2 | 38.1 |
salsar | 202 | 2**70 | 108.3 | 15.7 | 15.4 | 110.3 | 31.1 | 73.8 |
isaac | 2066 | 2**8295 | 122.0 | 13.9 | 9.0 | 189.3 | 12.8 | 178.9 |
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|.
type Quaternion = record r: extended; {real or scalar part } x,y,z: extended; {imaginary or vector part} end;Most routines are procedures with const input record(s) and a var output record. A quaternion is often written as a = r1 + xi + yj + zk, where 1, i, j, k are the fundamental quaternion units (as 4-dimensional vectors they are the standard unit vectors).
type Quaternion = record r: double; {real or scalar part } x,y,z: double; {imaginary or vector part} end;Most routines are procedures with const input record(s) and a var output record. Addition and subtraction are defined component-wise. Multiplication of quaternions is associative and distributive, but it is not commutative. Most (inverse) trigonometric / hyperbolic quaternion functions are basically computed with their corresponding complex function.
Home | CRC/Hash | Crypto | Misc. | Info | Links | Deutsch |