]> gitweb.factorcode.org Git - factor.git/blob - core/math/functions/functions-tests.factor
Initial import
[factor.git] / core / math / functions / functions-tests.factor
1 USING: kernel math math.constants math.functions math.private
2 math.libm tools.test ;
3 IN: temporary
4
5 [ t ] [ 4 4 .00000001 ~ ] unit-test
6 [ t ] [ 4.0000001 4.0000001 .000001 ~ ] unit-test
7 [ f ] [ -4.0000001 4.0000001 .00001 ~ ] unit-test
8 [ t ] [ -.0000000000001 0 .0000000001 ~ ] unit-test
9
10 ! Lets get the argument order correct, eh?
11 [ 0.0 ] [ 0.0 1.0 fatan2 ] unit-test
12 [ 0.25 ] [ 2.0 -2.0 fpow ] unit-test
13
14 [ 4.0 ] [ 16 sqrt ] unit-test
15 [ C{ 0 4.0 } ] [ -16 sqrt ] unit-test
16
17 [ 4.0 ] [ 2 2 ^ ] unit-test
18 [ 0.25 ] [ 2 -2 ^ ] unit-test
19 [ t ] [ 2 0.5 ^ 2 ^ 2 2.00001 between? ] unit-test
20 [ t ] [ e pi i * ^ real -1.0 = ] unit-test
21 [ t ] [ e pi i * ^ imaginary -0.00001 0.00001 between? ] unit-test
22
23 [ t ] [ 0 0 ^ fp-nan? ] unit-test
24 [ 1.0/0.0 ] [ 0 -2 ^ ] unit-test
25 [ t ] [ 0 0.0 ^ fp-nan? ] unit-test
26 [ 1.0/0.0 ] [ 0 -2.0 ^ ] unit-test
27 [ 0 ] [ 0 3.0 ^ ] unit-test
28 [ 0 ] [ 0 3 ^ ] unit-test
29
30 [ 1.0 ] [ 0 cosh ] unit-test
31 [ 0.0 ] [ 1 acosh ] unit-test
32             
33 [ 1.0 ] [ 0 cos ] unit-test
34 [ 0.0 ] [ 1 acos ] unit-test
35             
36 [ 0.0 ] [ 0 sinh ] unit-test
37 [ 0.0 ] [ 0 asinh ] unit-test
38             
39 [ 0.0 ] [ 0 sin ] unit-test
40 [ 0.0 ] [ 0 asin ] unit-test
41
42 [ 100 ] [ 100 100 gcd nip ] unit-test
43 [ 100 ] [ 1000 100 gcd nip ] unit-test
44 [ 100 ] [ 100 1000 gcd nip ] unit-test
45 [ 4 ] [ 132 64 gcd nip ] unit-test
46 [ 4 ] [ -132 64 gcd nip ] unit-test
47 [ 4 ] [ -132 -64 gcd nip ] unit-test
48 [ 4 ] [ 132 -64 gcd nip ] unit-test
49 [ 4 ] [ -132 -64 gcd nip ] unit-test
50
51 [ 100 ] [ 100 >bignum 100 >bignum gcd nip ] unit-test
52 [ 100 ] [ 1000 >bignum 100 >bignum gcd nip ] unit-test
53 [ 100 ] [ 100 >bignum 1000 >bignum gcd nip ] unit-test
54 [ 4 ] [ 132 >bignum 64 >bignum gcd nip ] unit-test
55 [ 4 ] [ -132 >bignum 64 >bignum gcd nip ] unit-test
56 [ 4 ] [ -132 >bignum -64 >bignum gcd nip ] unit-test
57 [ 4 ] [ 132 >bignum -64 >bignum gcd nip ] unit-test
58 [ 4 ] [ -132 >bignum -64 >bignum gcd nip ] unit-test
59
60 [ 6 ] [
61     1326264299060955293181542400000006
62     1591517158873146351817850880000000
63     gcd nip
64 ] unit-test
65
66 : verify-gcd
67     2dup gcd
68     >r rot * swap rem r> = ; 
69
70 [ t ] [ 123 124 verify-gcd ] unit-test
71 [ t ] [ 50 120 verify-gcd ] unit-test
72
73 [ 3 ] [ 5 7 mod-inv ] unit-test
74 [ 78572682077 ] [ 234829342 342389423843 mod-inv ] unit-test