Skip to content

Commit 9811e61

Browse files
committed
improve pixie.math scope (adapted from work of @edw found here:
https://gist.github.com/edw/87a4e234a33b5a1e0377)
1 parent 9b556c0 commit 9811e61

File tree

1 file changed

+74
-33
lines changed

1 file changed

+74
-33
lines changed

pixie/math.pxi

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,93 @@
44
(i/with-config {:library "m"
55
:cxx-flags ["-lm"]
66
:includes ["math.h"]}
7-
(i/defcfn sin)
8-
(i/defcfn cos)
9-
(i/defcfn tan)
7+
(i/defconst M_E)
8+
(i/defconst M_LOG2E)
9+
(i/defconst M_LOG10E)
10+
(i/defconst M_LN2)
11+
(i/defconst M_LN10)
12+
(i/defconst M_PI)
13+
(i/defconst M_PI_2)
14+
(i/defconst M_PI_4)
15+
(i/defconst M_1_PI)
16+
(i/defconst M_2_PI)
17+
(i/defconst M_2_SQRTPI)
18+
(i/defconst M_SQRT2)
19+
(i/defconst M_SQRT1_2)
1020

11-
(i/defcfn asin)
12-
(i/defcfn acos)
13-
(i/defcfn atan)
14-
(i/defcfn atan2) ; Arc tangent function of two variables.
21+
(i/defcfn nan)
22+
(i/defcfn ceil)
23+
(i/defcfn floor)
24+
(i/defcfn nearbyint)
25+
(i/defcfn rint)
26+
(i/defcfn lround)
27+
(i/defcfn llrint)
28+
(i/defcfn llround)
29+
(i/defcfn trunc)
1530

16-
(i/defcfn sinh)
17-
(i/defcfn cosh)
18-
(i/defcfn tanh)
31+
(i/defcfn fmod)
32+
(i/defcfn remainder)
33+
(i/defcfn remquo)
1934

20-
(i/defcfn asinh)
21-
(i/defcfn acosh)
22-
(i/defcfn atanh)
35+
(i/defcfn fdim)
36+
(i/defcfn fmax)
37+
(i/defcfn fmin)
38+
39+
(i/defcfn fma)
40+
41+
(i/defcfn fabs)
42+
(i/defcfn sqrt)
43+
(i/defcfn cbrt)
44+
(i/defcfn hypot)
2345

2446
(i/defcfn exp)
25-
(i/defcfn ldexp)
47+
(i/defcfn exp2)
48+
(i/defcfn exp10)
49+
(i/defcfn expm1)
2650

2751
(i/defcfn log)
2852
(i/defcfn log2)
2953
(i/defcfn log10)
3054
(i/defcfn log1p)
55+
3156
(i/defcfn logb)
3257
(i/defcfn ilogb)
3358

34-
;; (i/defcfn modf) ;; Needs ffi support
59+
(i/defcfn modf)
60+
(i/defcfn frexp)
61+
62+
(i/defcfn ldexp)
63+
(i/defcfn scalbn)
64+
(i/defcfn scalbln)
65+
3566
(i/defcfn pow)
36-
(i/defcfn sqrt)
37-
(i/defcfn ceil)
38-
(i/defcfn fabs)
39-
(i/defcfn floor)
40-
(i/defcfn fmod)
4167

42-
(i/defconst M_E) ; base of natural logarithm, e
43-
(i/defconst M_LOG2E) ; log2(e)
44-
(i/defconst M_LOG10E) ; log10(e)
45-
(i/defconst M_LN2) ; ln(2)
46-
(i/defconst M_LN10) ; ln(10)
47-
(i/defconst M_PI) ; pi
48-
(i/defconst M_PI_2) ; pi / 2
49-
(i/defconst M_PI_4) ; pi / 4
50-
(i/defconst M_1_PI) ; 1 / pi
51-
(i/defconst M_2_PI) ; 2 / pi
52-
(i/defconst M_2_SQRTPI) ; 2 / sqrt(pi)
53-
(i/defconst M_SQRT2) ; sqrt(2)
54-
(i/defconst M_SQRT1_2)) ; sqrt(1/2)
68+
(i/defcfn cos)
69+
(i/defcfn sin)
70+
(i/defcfn tan)
71+
72+
(i/defcfn cosh)
73+
(i/defcfn sinh)
74+
(i/defcfn tanh)
75+
76+
(i/defcfn acos)
77+
(i/defcfn asin)
78+
(i/defcfn atan)
79+
(i/defcfn atan2)
80+
81+
(i/defcfn acosh)
82+
(i/defcfn asinh)
83+
(i/defcfn atanh)
84+
85+
(i/defcfn tgamma)
86+
(i/defcfn lgamma)
87+
88+
(i/defcfn j0)
89+
(i/defcfn j1)
90+
(i/defcfn jn)
91+
(i/defcfn y0)
92+
(i/defcfn y1)
93+
(i/defcfn yn)
5594

95+
(i/defcfn erf)
96+
(i/defcfn erfc))

0 commit comments

Comments
 (0)