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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
module Float
( pi, (+.), (-.), (*.), (/.), (^.), i2f, truncate, round, recip, sqrt, log
, logBase, exp, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh
, asinh, acosh, atanh) where
infixr 8 ^.
infixl 7 *., /.
infixl 6 +., -.
pi :: Float
pi = 3.1415926535897927
(+.) :: Float -> Float -> Float
x +. y = (prim_Float_plus $# y) $# x
prim_Float_plus :: Float -> Float -> Float
prim_Float_plus external
(-.) :: Float -> Float -> Float
x -. y = (prim_Float_minus $# y) $# x
prim_Float_minus :: Float -> Float -> Float
prim_Float_minus external
(*.) :: Float -> Float -> Float
x *. y = (prim_Float_times $# y) $# x
prim_Float_times :: Float -> Float -> Float
prim_Float_times external
(/.) :: Float -> Float -> Float
x /. y = (prim_Float_div $# y) $# x
prim_Float_div :: Float -> Float -> Float
prim_Float_div external
(^.) :: Float -> Int -> Float
a ^. b | b < 0 = 1 /. a ^. (b * (-1))
| otherwise = powaux 1.0 a b
where
powaux n x y = if y == 0
then n
else powaux (n *. if (y `mod` 2 == 1) then x else 1.0)
(x *. x)
(y `div` 2)
i2f :: Int -> Float
i2f x = prim_i2f $# x
prim_i2f :: Int -> Float
prim_i2f external
truncate :: Float -> Int
truncate x = prim_truncate $# x
prim_truncate :: Float -> Int
prim_truncate external
round :: Float -> Int
round x = prim_round $# x
prim_round :: Float -> Int
prim_round external
recip :: Float -> Float
recip x = 1.0 /. x
sqrt :: Float -> Float
sqrt x = prim_sqrt $# x
prim_sqrt :: Float -> Float
prim_sqrt external
log :: Float -> Float
log x = prim_log $# x
prim_log :: Float -> Float
prim_log external
logBase :: Float -> Float -> Float
logBase x y = log y /. log x
exp :: Float -> Float
exp x = prim_exp $# x
prim_exp :: Float -> Float
prim_exp external
sin :: Float -> Float
sin x = prim_sin $# x
prim_sin :: Float -> Float
prim_sin external
cos :: Float -> Float
cos x = prim_cos $# x
prim_cos :: Float -> Float
prim_cos external
tan :: Float -> Float
tan x = prim_tan $# x
prim_tan :: Float -> Float
prim_tan external
asin :: Float -> Float
asin x = prim_asin $# x
prim_asin :: Float -> Float
prim_asin external
acos :: Float -> Float
acos x = prim_acos $# x
prim_acos :: Float -> Float
prim_acos external
atan :: Float -> Float
atan x = prim_atan $# x
prim_atan :: Float -> Float
prim_atan external
sinh :: Float -> Float
sinh x = prim_sinh $# x
prim_sinh :: Float -> Float
prim_sinh external
cosh :: Float -> Float
cosh x = prim_cosh $# x
prim_cosh :: Float -> Float
prim_cosh external
tanh :: Float -> Float
tanh x = prim_tanh $# x
prim_tanh :: Float -> Float
prim_tanh external
asinh :: Float -> Float
asinh x = prim_asinh $# x
prim_asinh :: Float -> Float
prim_asinh external
acosh :: Float -> Float
acosh x = prim_acosh $# x
prim_acosh :: Float -> Float
prim_acosh external
atanh :: Float -> Float
atanh x = prim_atanh $# x
prim_atanh :: Float -> Float
prim_atanh external
|