source: project/wiki/eggref/5/mathh @ 36245

Last change on this file since 36245 was 36245, checked in by Kon Lovett, 2 years ago

fix integer types

File size: 7.4 KB
Line 
1[[tags: egg]]
2
3== mathh
4
5[[toc:]]
6
7
8== Documentation
9
10Provides access to ISO C math functions in <math.h> that are not defined by
11the Chicken core. Please refer to your documentation for <math.h> for a
12description of the various calls.
13
14
15=== Math Functions
16
17{{O}} is a {{fixnum}}.
18
19{{P2}} is an {{integer}}.
20
21{{N}}, {{M}}, {{N1}}, {{N2}} are {{float}}.
22
23==== Usage
24
25<enscript language=scheme>
26(import "mathh")
27</enscript>
28
29==== bessel-j0
30==== bessel-j1
31==== bessel-jn
32==== bessel-jn
33==== bessel-y0
34==== bessel-y1
35==== bessel-yn
36
37<procedure>(bessel-j0 N) --> float</procedure>
38<procedure>(bessel-j1 N) --> float</procedure>
39<procedure>(bessel-jn O N) --> float</procedure>
40<procedure>(bessel-y0 N) --> float</procedure>
41<procedure>(bessel-y1 N) --> float</procedure>
42<procedure>(bessel-yn O N) --> float</procedure>
43
44==== cosh
45==== sinh
46==== tanh
47==== acosh
48==== asinh
49==== atanh
50
51<procedure>(cosh N) --> float</procedure>
52<procedure>(sinh N) --> float</procedure>
53<procedure>(tanh N) --> float</procedure>
54<procedure>(acosh N) --> float</procedure>
55<procedure>(asinh N) --> float</procedure>
56<procedure>(atanh N) --> float</procedure>
57
58==== hypot
59
60<procedure>(hypot N1 N2) --> float</procedure>
61
62==== gamma
63==== lgamma
64
65<procedure>(gamma N) --> float</procedure>
66<procedure>(lgamma N) --> float</procedure>
67
68==== erf
69==== erfc
70
71<procedure>(erf N) --> float</procedure>
72<procedure>(erfc N) --> float</procedure>
73
74==== log10
75==== log2
76==== log1p
77
78<procedure>(log10 N) --> float</procedure>
79<procedure>(log2 N) --> float</procedure>
80<procedure>(log1p N) --> float</procedure>
81
82==== log-with-base
83==== log/base
84
85<procedure>(log-with-base N) --> (procedure (float) float)</procedure>
86<procedure>(log/base N) --> (procedure (float) float)</procedure>
87
88Returns a function for the logarithm of base {{N}}.
89
90==== ldexp
91==== scalbn
92
93<procedure>(ldexp N P2) --> float</procedure>
94<procedure>(scalbn N P2) --> float</procedure>
95
96==== cbrt
97
98<procedure>(cbrt N) --> float</procedure>
99
100==== nextafter
101
102<procedure>(nextafter N M) --> float</procedure>
103
104Returns the next {{N}} in the direction of {{M}}.
105
106==== fpmod
107
108<procedure>(fpmod N M) --> float</procedure>
109
110Returns the modulus of {{N}} for {{M}}.
111
112==== modf
113
114<procedure>(modf N) --> float float</procedure>
115
116Returns two values, the integral and fractional components of {{N}}.
117
118==== frexp
119
120<procedure>(frexp N) --> float float</procedure>
121
122Returns two values, the fraction and the exponent components of {{N}}.
123
124==== signbit
125
126<procedure>(signbit N) --> boolean</procedure>
127
128Returns {{#t}} when negative, {{#f}} otherwise.
129
130==== copysign
131
132<procedure>(copysign N M) --> float</procedure>
133
134Returns {{N}} with same sign as {{M}}.
135
136==== fpclassify
137
138<procedure>(fpclassify N) --> symbol</procedure>
139
140Returns a symbol denoting the floating-point kind of {{N}}.
141
142; infinite :
143; nan :
144; normal :
145; subnormal :
146; zero :
147; unclassified :
148
149==== fpclass
150
151<procedure>(fpclass N) --> symbol</procedure>
152
153Returns a symbol denoting the floating-point kind of {{N}}.
154
155; positive-infinite :
156; negative-infinite :
157; quiet-nan :
158; signaling-nan :
159; positive-normal :
160; negative-normal :
161; positive-subnormal :
162; negative-subnormal :
163; positive-zero :
164; negative-zero :
165; unclassified :
166
167
168=== Math Constants (Module)
169
170==== Usage
171
172<enscript language=scheme>
173(import mathh-consts)
174</enscript>
175
176==== Constants
177
178These are all {{float}}.
179
180; e : e
181; 1/e : 1/e
182; e^2 : e^2
183; e^pi/4 : e^(pi/4)
184; log2e : log2(e)
185; log10e : log10(e)
186; ln2 : log(2)
187; ln3 : ln(3)
188; lnpi : ln(pi)
189; ln10 : log(10)
190; 1/ln2 : 1/ln(2)
191; 1/ln10 : 1/ln(10)
192; pi : pi
193; pi/2 : pi/2
194; pi/4 : pi/4
195; 1/pi : 1/pi
196; 2/pi : 2/pi
197; 2/sqrtpi : 2/sqrt(pi)
198; sqrtpi : sqrt(pi)
199; pi^2 : pi^2
200; degree : pi/180
201; sqrt2 : sqrt(2)
202; 1/sqrt2 : 1/sqrt(2)
203; sqrt3 : sqrt(3)
204; sqrt5 : sqrt(5)
205; sqrt10 : sqrt(10)
206; cubert2 : cubert(2)
207; cubert3 : cubert(3)
208; 4thrt2 : fourthrt(2)
209; gamma1/2 : gamma(1/2)
210; gamma1/3 : gamma(1/3)
211; gamma2/3 : gamma(2/3)
212; phi : phi
213; lnphi : ln(phi)
214; 1/lnphi : 1/ln(phi)
215; euler : euler
216; e^euler : e^euler
217; sin1 : sin(1)
218; cos1 : cos(1)
219; zeta3 : theta(3)
220
221
222=== Math Constants (Include)
223
224Common constants, using 'define-constant'. As such they must be textually
225included.
226
227==== Usage
228
229<enscript language=scheme>
230(include "mathh-constants")
231</enscript>
232
233==== Constants
234
235; E : e
236; 1/E : 1/e
237; E^2 : e^2
238; E^PI/4 : e^(pi/4)
239; LOG2E : log2(e)
240; LOG10E : log10(e)
241; LN2 : log(2)
242; LN3 : ln(3)
243; LNPI : ln(pi)
244; LN10 : log(10)
245; 1/LN2 : 1/ln(2)
246; 1/LN10 : 1/ln(10)
247; PI : pi
248; PI/2 : pi/2
249; PI/4 : pi/4
250; 1/PI : 1/pi
251; 2/PI : 2/pi
252; 2/SQRTPI : 2/sqrt(pi)
253; SQRTPI : sqrt(pi)
254; PI^2 : pi^2
255; DEGREE : pi/180
256; SQRT2 : sqrt(2)
257; 1/SQRT2 : 1/sqrt(2)
258; SQRT3 : sqrt(3)
259; SQRT5 : sqrt(5)
260; SQRT10 : sqrt(10)
261; CUBERT2 : cubert(2)
262; CUBERT3 : cubert(3)
263; 4THRT2 : fourthrt(2)
264; GAMMA1/2 : gamma(1/2)
265; GAMMA1/3 : gamma(1/3)
266; GAMMA2/3 : gamma(2/3)
267; PHI : phi
268; LNPHI : ln(phi)
269; 1/LNPHI : 1/ln(phi)
270; EULER : euler
271; E^EULER : e^euler
272; SIN1 : sin(1)
273; COS1 : cos(1)
274; ZETA3 : theta(3)
275
276
277== Notes
278
279* The C library call {{gamma}} is deprecated in favor of {{tgamma}} but not
280available yet on some platforms, so we use {{gamma}} where necessary.
281
282* Some library calls that are not supplied by the platform have rough
283implementations supplied. See {{Bugs and Limitations}}.
284
285* The general naming convention is to use the C library call name as the Scheme
286name. But there are exceptions:
287
288; fmod : fpmod
289; j0 : bessel-j0 (Prefixed to distinguish the names from common variables)
290; j1 : bessel-j1
291; jn : bessel-jn
292; y0 : bessel-y0
293; y1 : bessel-y1
294; yn : bessel-yn
295
296
297== Bugs and Limitations
298
299* Given the notes above not current.
300
301* Support for the full numeric tower is '''not''' provided.
302
303* Windows library calls {{lgamma}}, {{gamma}}, {{acosh}}, {{asinh}},
304{{atanh}}, {{cbrt}} & {{signbit}} are not provided.
305
306* FreeBSD does not provide the library call {{log2}}. A usable {{log2}} is
307supplied.
308
309* The {{fpclass}} {{quiet-nan}} is only distinguished on Windows.
310
311
312== Author
313
314[[/users/kon-lovett|Kon Lovett]]
315[[/users/john cowan|John Cowan]]
316
317
318== Version history
319
320; 4.0.0 : CHICKEN 5 release.
321; 3.4.2 : Fix foreign-declare use. Fix {{fpzero?}}, {{fppositive?}}, {{fpnegative?}}, {{fpcardinal?}} again.
322; 3.4.1 : Remove unneeded dependency.
323; 3.4.0 ; Fix {{fppositive?}}, {{fpnegative?}}, {{fpcardinal?}}, {{fpeven?}}, {{fpodd?}}.
324; 3.3.3 ; Remove Windows {{log2}}, {{log1p}}, {{erf}}, {{erfc}}, {{scalbn}}.
325; 3.3.2 ;
326; 3.3.1 ;
327; 3.3.0 ; Add {{log-with-base}}. Deprecate {{make-log/base}}. Fix {{fprandom}} sign preservation.
328; 3.2.4 ; Add {{fxlog2}}, fix {{fxpow2log2}}.
329; 3.2.3 ; Fix {{4THRT2}}, {{1/LNPHI}}, extend {{1/SQRT2}}.
330; 3.2.2 ; Remove ''inline'' generation for mathh.
331; 3.2.1 ; Add types. Fix {{signbit}} & {{fpclass}}.
332; 3.2.0 ; Fix {{fpodd?}}. Add ''fx-utils.scm''. Extend ''fp-utils.scm''.
333; 3.1.0 ; Added module for ''mathh-constants.scm''.
334; 3.0.0 ; Moved copy of ''mathh-constants.scm'' to {{(chicken-home)}}. Ticket #1327
335; 2.2.6 ; better argvector chicken test
336; 2.2.5 ; argvector chicken support
337; 2.2.4 ;
338; 2.2.3 ; Fix for ticket #630
339; 2.2.2 ; ''mathh-constants.scm'' copied to Chicken Repository. Produces shared+static object files.
340; 2.2.1 : Better ''no-install'' support.
341; 2.2.0 : Added {{acosh}}, {{asinh}}, {{atanh}}, {{erf}} & {{erfc}}. Includes <sunmath.h> on Sun platform for {{log2}}.
342; 2.1.0 : Added {{signbit}}, {{copysign}}, {{nextafter}} & {{cbrt}}.
343; 2.0.0 : Chicken 4 release. {{fpclass}} and {{fpclassify}} are now part of the '''mathh''' extension.
344
345
346== License
347
348This code is in the public domain.
Note: See TracBrowser for help on using the repository browser.