Mercurial > emacs
comparison src/floatfns.c @ 683:7f4d77d29804
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 04 Jun 1992 04:22:08 +0000 |
parents | 40b255f55df3 |
children | 714b8017cc6b |
comparison
equal
deleted
inserted
replaced
682:71f59bd24996 | 683:7f4d77d29804 |
---|---|
75 | 75 |
76 if (XTYPE (num) == Lisp_Float) | 76 if (XTYPE (num) == Lisp_Float) |
77 return XFLOAT (num)->data; | 77 return XFLOAT (num)->data; |
78 return (double) XINT (num); | 78 return (double) XINT (num); |
79 } | 79 } |
80 | |
81 /* Trig functions. */ | |
80 | 82 |
81 DEFUN ("acos", Facos, Sacos, 1, 1, 0, | 83 DEFUN ("acos", Facos, Sacos, 1, 1, 0, |
82 "Return the inverse cosine of ARG.") | 84 "Return the inverse cosine of ARG.") |
83 (num) | 85 (num) |
84 register Lisp_Object num; | 86 register Lisp_Object num; |
86 double d = extract_float (num); | 88 double d = extract_float (num); |
87 IN_FLOAT (d = acos (d), num); | 89 IN_FLOAT (d = acos (d), num); |
88 return make_float (d); | 90 return make_float (d); |
89 } | 91 } |
90 | 92 |
91 DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, | |
92 "Return the inverse hyperbolic cosine of ARG.") | |
93 (num) | |
94 register Lisp_Object num; | |
95 { | |
96 double d = extract_float (num); | |
97 IN_FLOAT (d = acosh (d), num); | |
98 return make_float (d); | |
99 } | |
100 | |
101 DEFUN ("asin", Fasin, Sasin, 1, 1, 0, | 93 DEFUN ("asin", Fasin, Sasin, 1, 1, 0, |
102 "Return the inverse sine of ARG.") | 94 "Return the inverse sine of ARG.") |
103 (num) | 95 (num) |
104 register Lisp_Object num; | 96 register Lisp_Object num; |
105 { | 97 { |
106 double d = extract_float (num); | 98 double d = extract_float (num); |
107 IN_FLOAT (d = asin (d), num); | 99 IN_FLOAT (d = asin (d), num); |
108 return make_float (d); | 100 return make_float (d); |
109 } | 101 } |
110 | 102 |
111 DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, | |
112 "Return the inverse hyperbolic sine of ARG.") | |
113 (num) | |
114 register Lisp_Object num; | |
115 { | |
116 double d = extract_float (num); | |
117 IN_FLOAT (d = asinh (d), num); | |
118 return make_float (d); | |
119 } | |
120 | |
121 DEFUN ("atan", Fatan, Satan, 1, 1, 0, | 103 DEFUN ("atan", Fatan, Satan, 1, 1, 0, |
122 "Return the inverse tangent of ARG.") | 104 "Return the inverse tangent of ARG.") |
123 (num) | 105 (num) |
124 register Lisp_Object num; | 106 register Lisp_Object num; |
125 { | 107 { |
126 double d = extract_float (num); | 108 double d = extract_float (num); |
127 IN_FLOAT (d = atan (d), num); | 109 IN_FLOAT (d = atan (d), num); |
128 return make_float (d); | 110 return make_float (d); |
129 } | 111 } |
130 | 112 |
131 DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, | 113 DEFUN ("cos", Fcos, Scos, 1, 1, 0, |
132 "Return the inverse hyperbolic tangent of ARG.") | 114 "Return the cosine of ARG.") |
133 (num) | 115 (num) |
134 register Lisp_Object num; | 116 register Lisp_Object num; |
135 { | 117 { |
136 double d = extract_float (num); | 118 double d = extract_float (num); |
137 IN_FLOAT (d = atanh (d), num); | 119 IN_FLOAT (d = cos (d), num); |
138 return make_float (d); | 120 return make_float (d); |
139 } | 121 } |
140 | 122 |
123 DEFUN ("sin", Fsin, Ssin, 1, 1, 0, | |
124 "Return the sine of ARG.") | |
125 (num) | |
126 register Lisp_Object num; | |
127 { | |
128 double d = extract_float (num); | |
129 IN_FLOAT (d = sin (d), num); | |
130 return make_float (d); | |
131 } | |
132 | |
133 DEFUN ("tan", Ftan, Stan, 1, 1, 0, | |
134 "Return the tangent of ARG.") | |
135 (num) | |
136 register Lisp_Object num; | |
137 { | |
138 double d = extract_float (num); | |
139 IN_FLOAT (d = tan (d), num); | |
140 return make_float (d); | |
141 } | |
142 | |
143 #if 0 /* Leave these out unless we find there's a reason for them. */ | |
144 | |
141 DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, | 145 DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, |
142 "Return the bessel function j0 of ARG.") | 146 "Return the bessel function j0 of ARG.") |
143 (num) | 147 (num) |
144 register Lisp_Object num; | 148 register Lisp_Object num; |
145 { | 149 { |
201 double f2 = extract_float (num2); | 205 double f2 = extract_float (num2); |
202 | 206 |
203 IN_FLOAT (f2 = yn (i1, f2), num1); | 207 IN_FLOAT (f2 = yn (i1, f2), num1); |
204 return make_float (f2); | 208 return make_float (f2); |
205 } | 209 } |
210 | |
211 #endif | |
212 | |
213 #if 0 /* Leave these out unless we see they are worth having. */ | |
214 | |
215 DEFUN ("erf", Ferf, Serf, 1, 1, 0, | |
216 "Return the mathematical error function of ARG.") | |
217 (num) | |
218 register Lisp_Object num; | |
219 { | |
220 double d = extract_float (num); | |
221 IN_FLOAT (d = erf (d), num); | |
222 return make_float (d); | |
223 } | |
224 | |
225 DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, | |
226 "Return the complementary error function of ARG.") | |
227 (num) | |
228 register Lisp_Object num; | |
229 { | |
230 double d = extract_float (num); | |
231 IN_FLOAT (d = erfc (d), num); | |
232 return make_float (d); | |
233 } | |
234 | |
235 DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, | |
236 "Return the log gamma of ARG.") | |
237 (num) | |
238 register Lisp_Object num; | |
239 { | |
240 double d = extract_float (num); | |
241 IN_FLOAT (d = lgamma (d), num); | |
242 return make_float (d); | |
243 } | |
244 | |
245 #endif | |
206 | 246 |
207 DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, | 247 DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0, |
208 "Return the cube root of ARG.") | 248 "Return the cube root of ARG.") |
209 (num) | 249 (num) |
210 register Lisp_Object num; | 250 register Lisp_Object num; |
212 double d = extract_float (num); | 252 double d = extract_float (num); |
213 IN_FLOAT (d = cbrt (d), num); | 253 IN_FLOAT (d = cbrt (d), num); |
214 return make_float (d); | 254 return make_float (d); |
215 } | 255 } |
216 | 256 |
217 DEFUN ("cos", Fcos, Scos, 1, 1, 0, | |
218 "Return the cosine of ARG.") | |
219 (num) | |
220 register Lisp_Object num; | |
221 { | |
222 double d = extract_float (num); | |
223 IN_FLOAT (d = cos (d), num); | |
224 return make_float (d); | |
225 } | |
226 | |
227 DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, | |
228 "Return the hyperbolic cosine of ARG.") | |
229 (num) | |
230 register Lisp_Object num; | |
231 { | |
232 double d = extract_float (num); | |
233 IN_FLOAT (d = cosh (d), num); | |
234 return make_float (d); | |
235 } | |
236 | |
237 DEFUN ("erf", Ferf, Serf, 1, 1, 0, | |
238 "Return the mathematical error function of ARG.") | |
239 (num) | |
240 register Lisp_Object num; | |
241 { | |
242 double d = extract_float (num); | |
243 IN_FLOAT (d = erf (d), num); | |
244 return make_float (d); | |
245 } | |
246 | |
247 DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0, | |
248 "Return the complementary error function of ARG.") | |
249 (num) | |
250 register Lisp_Object num; | |
251 { | |
252 double d = extract_float (num); | |
253 IN_FLOAT (d = erfc (d), num); | |
254 return make_float (d); | |
255 } | |
256 | |
257 DEFUN ("exp", Fexp, Sexp, 1, 1, 0, | 257 DEFUN ("exp", Fexp, Sexp, 1, 1, 0, |
258 "Return the exponential base e of ARG.") | 258 "Return the exponential base e of ARG.") |
259 (num) | 259 (num) |
260 register Lisp_Object num; | 260 register Lisp_Object num; |
261 { | 261 { |
271 { | 271 { |
272 double d = extract_float (num); | 272 double d = extract_float (num); |
273 IN_FLOAT (d = expm1 (d), num); | 273 IN_FLOAT (d = expm1 (d), num); |
274 return make_float (d); | 274 return make_float (d); |
275 } | 275 } |
276 | |
277 DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, | |
278 "Return the log gamma of ARG.") | |
279 (num) | |
280 register Lisp_Object num; | |
281 { | |
282 double d = extract_float (num); | |
283 IN_FLOAT (d = lgamma (d), num); | |
284 return make_float (d); | |
285 } | |
286 | |
287 DEFUN ("log", Flog, Slog, 1, 1, 0, | |
288 "Return the natural logarithm of ARG.") | |
289 (num) | |
290 register Lisp_Object num; | |
291 { | |
292 double d = extract_float (num); | |
293 IN_FLOAT (d = log (d), num); | |
294 return make_float (d); | |
295 } | |
296 | |
297 DEFUN ("log10", Flog10, Slog10, 1, 1, 0, | |
298 "Return the logarithm base 10 of ARG.") | |
299 (num) | |
300 register Lisp_Object num; | |
301 { | |
302 double d = extract_float (num); | |
303 IN_FLOAT (d = log10 (d), num); | |
304 return make_float (d); | |
305 } | |
306 | |
307 DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0, | |
308 "Return the log (1+x) of ARG.") | |
309 (num) | |
310 register Lisp_Object num; | |
311 { | |
312 double d = extract_float (num); | |
313 IN_FLOAT (d = log1p (d), num); | |
314 return make_float (d); | |
315 } | |
316 | 276 |
317 DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, | 277 DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, |
318 "Return the exponential x ** y.") | 278 "Return the exponential X ** Y.") |
319 (num1, num2) | 279 (num1, num2) |
320 register Lisp_Object num1, num2; | 280 register Lisp_Object num1, num2; |
321 { | 281 { |
322 double f1, f2; | 282 double f1, f2; |
323 | 283 |
347 f1 = (XTYPE (num1) == Lisp_Float) ? XFLOAT (num1)->data : XINT (num1); | 307 f1 = (XTYPE (num1) == Lisp_Float) ? XFLOAT (num1)->data : XINT (num1); |
348 f2 = (XTYPE (num2) == Lisp_Float) ? XFLOAT (num2)->data : XINT (num2); | 308 f2 = (XTYPE (num2) == Lisp_Float) ? XFLOAT (num2)->data : XINT (num2); |
349 IN_FLOAT (f1 = pow (f1, f2), num1); | 309 IN_FLOAT (f1 = pow (f1, f2), num1); |
350 return make_float (f1); | 310 return make_float (f1); |
351 } | 311 } |
352 | 312 |
353 DEFUN ("sin", Fsin, Ssin, 1, 1, 0, | 313 DEFUN ("log", Flog, Slog, 1, 1, 0, |
354 "Return the sine of ARG.") | 314 "Return the natural logarithm of ARG.") |
355 (num) | 315 (num) |
356 register Lisp_Object num; | 316 register Lisp_Object num; |
357 { | 317 { |
358 double d = extract_float (num); | 318 double d = extract_float (num); |
359 IN_FLOAT (d = sin (d), num); | 319 IN_FLOAT (d = log (d), num); |
320 return make_float (d); | |
321 } | |
322 | |
323 DEFUN ("log10", Flog10, Slog10, 1, 1, 0, | |
324 "Return the logarithm base 10 of ARG.") | |
325 (num) | |
326 register Lisp_Object num; | |
327 { | |
328 double d = extract_float (num); | |
329 IN_FLOAT (d = log10 (d), num); | |
330 return make_float (d); | |
331 } | |
332 | |
333 DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0, | |
334 "Return the log (1+x) of ARG.") | |
335 (num) | |
336 register Lisp_Object num; | |
337 { | |
338 double d = extract_float (num); | |
339 IN_FLOAT (d = log1p (d), num); | |
340 return make_float (d); | |
341 } | |
342 | |
343 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, | |
344 "Return the square root of ARG.") | |
345 (num) | |
346 register Lisp_Object num; | |
347 { | |
348 double d = extract_float (num); | |
349 IN_FLOAT (d = sqrt (d), num); | |
350 return make_float (d); | |
351 } | |
352 | |
353 #ifndef /* Not clearly worth adding. */ | |
354 | |
355 DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, | |
356 "Return the inverse hyperbolic cosine of ARG.") | |
357 (num) | |
358 register Lisp_Object num; | |
359 { | |
360 double d = extract_float (num); | |
361 IN_FLOAT (d = acosh (d), num); | |
362 return make_float (d); | |
363 } | |
364 | |
365 DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, | |
366 "Return the inverse hyperbolic sine of ARG.") | |
367 (num) | |
368 register Lisp_Object num; | |
369 { | |
370 double d = extract_float (num); | |
371 IN_FLOAT (d = asinh (d), num); | |
372 return make_float (d); | |
373 } | |
374 | |
375 DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, | |
376 "Return the inverse hyperbolic tangent of ARG.") | |
377 (num) | |
378 register Lisp_Object num; | |
379 { | |
380 double d = extract_float (num); | |
381 IN_FLOAT (d = atanh (d), num); | |
382 return make_float (d); | |
383 } | |
384 | |
385 DEFUN ("cosh", Fcosh, Scosh, 1, 1, 0, | |
386 "Return the hyperbolic cosine of ARG.") | |
387 (num) | |
388 register Lisp_Object num; | |
389 { | |
390 double d = extract_float (num); | |
391 IN_FLOAT (d = cosh (d), num); | |
360 return make_float (d); | 392 return make_float (d); |
361 } | 393 } |
362 | 394 |
363 DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, | 395 DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, |
364 "Return the hyperbolic sine of ARG.") | 396 "Return the hyperbolic sine of ARG.") |
368 double d = extract_float (num); | 400 double d = extract_float (num); |
369 IN_FLOAT (d = sinh (d), num); | 401 IN_FLOAT (d = sinh (d), num); |
370 return make_float (d); | 402 return make_float (d); |
371 } | 403 } |
372 | 404 |
373 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, | |
374 "Return the square root of ARG.") | |
375 (num) | |
376 register Lisp_Object num; | |
377 { | |
378 double d = extract_float (num); | |
379 IN_FLOAT (d = sqrt (d), num); | |
380 return make_float (d); | |
381 } | |
382 | |
383 DEFUN ("tan", Ftan, Stan, 1, 1, 0, | |
384 "Return the tangent of ARG.") | |
385 (num) | |
386 register Lisp_Object num; | |
387 { | |
388 double d = extract_float (num); | |
389 IN_FLOAT (d = tan (d), num); | |
390 return make_float (d); | |
391 } | |
392 | |
393 DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, | 405 DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0, |
394 "Return the hyperbolic tangent of ARG.") | 406 "Return the hyperbolic tangent of ARG.") |
395 (num) | 407 (num) |
396 register Lisp_Object num; | 408 register Lisp_Object num; |
397 { | 409 { |
398 double d = extract_float (num); | 410 double d = extract_float (num); |
399 IN_FLOAT (d = tanh (d), num); | 411 IN_FLOAT (d = tanh (d), num); |
400 return make_float (d); | 412 return make_float (d); |
401 } | 413 } |
414 #endif | |
402 | 415 |
403 DEFUN ("abs", Fabs, Sabs, 1, 1, 0, | 416 DEFUN ("abs", Fabs, Sabs, 1, 1, 0, |
404 "Return the absolute value of ARG.") | 417 "Return the absolute value of ARG.") |
405 (num) | 418 (num) |
406 register Lisp_Object num; | 419 register Lisp_Object num; |
529 } | 542 } |
530 | 543 |
531 syms_of_floatfns () | 544 syms_of_floatfns () |
532 { | 545 { |
533 defsubr (&Sacos); | 546 defsubr (&Sacos); |
547 defsubr (&Sasin); | |
548 defsubr (&Satan); | |
549 defsubr (&Scos); | |
550 defsubr (&Ssin); | |
551 defsubr (&Stan); | |
552 #if 0 | |
534 defsubr (&Sacosh); | 553 defsubr (&Sacosh); |
535 defsubr (&Sasin); | |
536 defsubr (&Sasinh); | 554 defsubr (&Sasinh); |
537 defsubr (&Satan); | |
538 defsubr (&Satanh); | 555 defsubr (&Satanh); |
556 defsubr (&Scosh); | |
557 defsubr (&Ssinh); | |
558 defsubr (&Stanh); | |
539 defsubr (&Sbessel_y0); | 559 defsubr (&Sbessel_y0); |
540 defsubr (&Sbessel_y1); | 560 defsubr (&Sbessel_y1); |
541 defsubr (&Sbessel_yn); | 561 defsubr (&Sbessel_yn); |
542 defsubr (&Sbessel_j0); | 562 defsubr (&Sbessel_j0); |
543 defsubr (&Sbessel_j1); | 563 defsubr (&Sbessel_j1); |
544 defsubr (&Sbessel_jn); | 564 defsubr (&Sbessel_jn); |
545 defsubr (&Scube_root); | |
546 defsubr (&Scos); | |
547 defsubr (&Scosh); | |
548 defsubr (&Serf); | 565 defsubr (&Serf); |
549 defsubr (&Serfc); | 566 defsubr (&Serfc); |
567 defsubr (&Slog_gamma); | |
568 #endif | |
569 defsubr (&Scube_root); | |
550 defsubr (&Sexp); | 570 defsubr (&Sexp); |
551 defsubr (&Sexpm1); | 571 defsubr (&Sexpm1); |
552 defsubr (&Slog_gamma); | 572 defsubr (&Sexpt); |
553 defsubr (&Slog); | 573 defsubr (&Slog); |
554 defsubr (&Slog10); | 574 defsubr (&Slog10); |
555 defsubr (&Slog1p); | 575 defsubr (&Slog1p); |
556 defsubr (&Sexpt); | |
557 defsubr (&Ssin); | |
558 defsubr (&Ssinh); | |
559 defsubr (&Ssqrt); | 576 defsubr (&Ssqrt); |
560 defsubr (&Stan); | |
561 defsubr (&Stanh); | |
562 | 577 |
563 defsubr (&Sabs); | 578 defsubr (&Sabs); |
564 defsubr (&Sfloat); | 579 defsubr (&Sfloat); |
565 defsubr (&Slogb); | 580 defsubr (&Slogb); |
566 defsubr (&Sceiling); | 581 defsubr (&Sceiling); |