aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorRichard M. Stallman1992-06-04 04:22:08 +0000
committerRichard M. Stallman1992-06-04 04:22:08 +0000
commitc2d4ea7421ca2fc572179704725ef83b8303aeb2 (patch)
treef0a186668c7a9a8e9d25eccb456aff9528d5ee4f /src/floatfns.c
parent3371bdfcb62354eb8ce68f5636edeab379bf0eab (diff)
downloademacs-c2d4ea7421ca2fc572179704725ef83b8303aeb2.tar.gz
emacs-c2d4ea7421ca2fc572179704725ef83b8303aeb2.zip
*** empty log message ***
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c205
1 files changed, 110 insertions, 95 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 20b90e63a85..c0d052aabae 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -77,6 +77,8 @@ extract_float (num)
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
81DEFUN ("acos", Facos, Sacos, 1, 1, 0, 83DEFUN ("acos", Facos, Sacos, 1, 1, 0,
82 "Return the inverse cosine of ARG.") 84 "Return the inverse cosine of ARG.")
@@ -88,56 +90,58 @@ DEFUN ("acos", Facos, Sacos, 1, 1, 0,
88 return make_float (d); 90 return make_float (d);
89} 91}
90 92
91DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0, 93DEFUN ("asin", Fasin, Sasin, 1, 1, 0,
92 "Return the inverse hyperbolic cosine of ARG.") 94 "Return the inverse sine of ARG.")
93 (num) 95 (num)
94 register Lisp_Object num; 96 register Lisp_Object num;
95{ 97{
96 double d = extract_float (num); 98 double d = extract_float (num);
97 IN_FLOAT (d = acosh (d), num); 99 IN_FLOAT (d = asin (d), num);
98 return make_float (d); 100 return make_float (d);
99} 101}
100 102
101DEFUN ("asin", Fasin, Sasin, 1, 1, 0, 103DEFUN ("atan", Fatan, Satan, 1, 1, 0,
102 "Return the inverse sine of ARG.") 104 "Return the inverse tangent of ARG.")
103 (num) 105 (num)
104 register Lisp_Object num; 106 register Lisp_Object num;
105{ 107{
106 double d = extract_float (num); 108 double d = extract_float (num);
107 IN_FLOAT (d = asin (d), num); 109 IN_FLOAT (d = atan (d), num);
108 return make_float (d); 110 return make_float (d);
109} 111}
110 112
111DEFUN ("asinh", Fasinh, Sasinh, 1, 1, 0, 113DEFUN ("cos", Fcos, Scos, 1, 1, 0,
112 "Return the inverse hyperbolic sine of ARG.") 114 "Return the cosine of ARG.")
113 (num) 115 (num)
114 register Lisp_Object num; 116 register Lisp_Object num;
115{ 117{
116 double d = extract_float (num); 118 double d = extract_float (num);
117 IN_FLOAT (d = asinh (d), num); 119 IN_FLOAT (d = cos (d), num);
118 return make_float (d); 120 return make_float (d);
119} 121}
120 122
121DEFUN ("atan", Fatan, Satan, 1, 1, 0, 123DEFUN ("sin", Fsin, Ssin, 1, 1, 0,
122 "Return the inverse tangent of ARG.") 124 "Return the sine of ARG.")
123 (num) 125 (num)
124 register Lisp_Object num; 126 register Lisp_Object num;
125{ 127{
126 double d = extract_float (num); 128 double d = extract_float (num);
127 IN_FLOAT (d = atan (d), num); 129 IN_FLOAT (d = sin (d), num);
128 return make_float (d); 130 return make_float (d);
129} 131}
130 132
131DEFUN ("atanh", Fatanh, Satanh, 1, 1, 0, 133DEFUN ("tan", Ftan, Stan, 1, 1, 0,
132 "Return the inverse hyperbolic tangent of ARG.") 134 "Return the tangent of ARG.")
133 (num) 135 (num)
134 register Lisp_Object num; 136 register Lisp_Object num;
135{ 137{
136 double d = extract_float (num); 138 double d = extract_float (num);
137 IN_FLOAT (d = atanh (d), num); 139 IN_FLOAT (d = tan (d), num);
138 return make_float (d); 140 return make_float (d);
139} 141}
140 142
143#if 0 /* Leave these out unless we find there's a reason for them. */
144
141DEFUN ("bessel-j0", Fbessel_j0, Sbessel_j0, 1, 1, 0, 145DEFUN ("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)
@@ -203,36 +207,10 @@ The first arg (the order) is truncated to an integer.")
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}
206
207DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
208 "Return the cube root of ARG.")
209 (num)
210 register Lisp_Object num;
211{
212 double d = extract_float (num);
213 IN_FLOAT (d = cbrt (d), num);
214 return make_float (d);
215}
216 210
217DEFUN ("cos", Fcos, Scos, 1, 1, 0, 211#endif
218 "Return the cosine of ARG.") 212
219 (num) 213#if 0 /* Leave these out unless we see they are worth having. */
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
227DEFUN ("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 214
237DEFUN ("erf", Ferf, Serf, 1, 1, 0, 215DEFUN ("erf", Ferf, Serf, 1, 1, 0,
238 "Return the mathematical error function of ARG.") 216 "Return the mathematical error function of ARG.")
@@ -254,26 +232,6 @@ DEFUN ("erfc", Ferfc, Serfc, 1, 1, 0,
254 return make_float (d); 232 return make_float (d);
255} 233}
256 234
257DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
258 "Return the exponential base e of ARG.")
259 (num)
260 register Lisp_Object num;
261{
262 double d = extract_float (num);
263 IN_FLOAT (d = exp (d), num);
264 return make_float (d);
265}
266
267DEFUN ("expm1", Fexpm1, Sexpm1, 1, 1, 0,
268 "Return the exp (x)-1 of ARG.")
269 (num)
270 register Lisp_Object num;
271{
272 double d = extract_float (num);
273 IN_FLOAT (d = expm1 (d), num);
274 return make_float (d);
275}
276
277DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0, 235DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
278 "Return the log gamma of ARG.") 236 "Return the log gamma of ARG.")
279 (num) 237 (num)
@@ -284,38 +242,40 @@ DEFUN ("log-gamma", Flog_gamma, Slog_gamma, 1, 1, 0,
284 return make_float (d); 242 return make_float (d);
285} 243}
286 244
287DEFUN ("log", Flog, Slog, 1, 1, 0, 245#endif
288 "Return the natural logarithm of ARG.") 246
247DEFUN ("cube-root", Fcube_root, Scube_root, 1, 1, 0,
248 "Return the cube root of ARG.")
289 (num) 249 (num)
290 register Lisp_Object num; 250 register Lisp_Object num;
291{ 251{
292 double d = extract_float (num); 252 double d = extract_float (num);
293 IN_FLOAT (d = log (d), num); 253 IN_FLOAT (d = cbrt (d), num);
294 return make_float (d); 254 return make_float (d);
295} 255}
296 256
297DEFUN ("log10", Flog10, Slog10, 1, 1, 0, 257DEFUN ("exp", Fexp, Sexp, 1, 1, 0,
298 "Return the logarithm base 10 of ARG.") 258 "Return the exponential base e of ARG.")
299 (num) 259 (num)
300 register Lisp_Object num; 260 register Lisp_Object num;
301{ 261{
302 double d = extract_float (num); 262 double d = extract_float (num);
303 IN_FLOAT (d = log10 (d), num); 263 IN_FLOAT (d = exp (d), num);
304 return make_float (d); 264 return make_float (d);
305} 265}
306 266
307DEFUN ("log1p", Flog1p, Slog1p, 1, 1, 0, 267DEFUN ("expm1", Fexpm1, Sexpm1, 1, 1, 0,
308 "Return the log (1+x) of ARG.") 268 "Return the exp (x)-1 of ARG.")
309 (num) 269 (num)
310 register Lisp_Object num; 270 register Lisp_Object num;
311{ 271{
312 double d = extract_float (num); 272 double d = extract_float (num);
313 IN_FLOAT (d = log1p (d), num); 273 IN_FLOAT (d = expm1 (d), num);
314 return make_float (d); 274 return make_float (d);
315} 275}
316 276
317DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, 277DEFUN ("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{
@@ -349,24 +309,34 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0,
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
353DEFUN ("sin", Fsin, Ssin, 1, 1, 0, 313DEFUN ("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);
360 return make_float (d); 320 return make_float (d);
361} 321}
362 322
363DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0, 323DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
364 "Return the hyperbolic sine of ARG.") 324 "Return the logarithm base 10 of ARG.")
365 (num) 325 (num)
366 register Lisp_Object num; 326 register Lisp_Object num;
367{ 327{
368 double d = extract_float (num); 328 double d = extract_float (num);
369 IN_FLOAT (d = sinh (d), num); 329 IN_FLOAT (d = log10 (d), num);
330 return make_float (d);
331}
332
333DEFUN ("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);
370 return make_float (d); 340 return make_float (d);
371} 341}
372 342
@@ -379,14 +349,56 @@ DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
379 IN_FLOAT (d = sqrt (d), num); 349 IN_FLOAT (d = sqrt (d), num);
380 return make_float (d); 350 return make_float (d);
381} 351}
352
353#ifndef /* Not clearly worth adding. */
382 354
383DEFUN ("tan", Ftan, Stan, 1, 1, 0, 355DEFUN ("acosh", Facosh, Sacosh, 1, 1, 0,
384 "Return the tangent of ARG.") 356 "Return the inverse hyperbolic cosine of ARG.")
385 (num) 357 (num)
386 register Lisp_Object num; 358 register Lisp_Object num;
387{ 359{
388 double d = extract_float (num); 360 double d = extract_float (num);
389 IN_FLOAT (d = tan (d), num); 361 IN_FLOAT (d = acosh (d), num);
362 return make_float (d);
363}
364
365DEFUN ("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
375DEFUN ("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
385DEFUN ("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);
392 return make_float (d);
393}
394
395DEFUN ("sinh", Fsinh, Ssinh, 1, 1, 0,
396 "Return the hyperbolic sine of ARG.")
397 (num)
398 register Lisp_Object num;
399{
400 double d = extract_float (num);
401 IN_FLOAT (d = sinh (d), num);
390 return make_float (d); 402 return make_float (d);
391} 403}
392 404
@@ -399,6 +411,7 @@ DEFUN ("tanh", Ftanh, Stanh, 1, 1, 0,
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
403DEFUN ("abs", Fabs, Sabs, 1, 1, 0, 416DEFUN ("abs", Fabs, Sabs, 1, 1, 0,
404 "Return the absolute value of ARG.") 417 "Return the absolute value of ARG.")
@@ -531,34 +544,36 @@ init_floatfns ()
531syms_of_floatfns () 544syms_of_floatfns ()
532{ 545{
533 defsubr (&Sacos); 546 defsubr (&Sacos);
534 defsubr (&Sacosh);
535 defsubr (&Sasin); 547 defsubr (&Sasin);
536 defsubr (&Sasinh);
537 defsubr (&Satan); 548 defsubr (&Satan);
549 defsubr (&Scos);
550 defsubr (&Ssin);
551 defsubr (&Stan);
552#if 0
553 defsubr (&Sacosh);
554 defsubr (&Sasinh);
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);