Nife version Beta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

83 lines
2.4 KiB

  1. /* Copyright (C) 2011-2016 Patrick H. E. Foubet - S.E.R.I.A.N.E.
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or any
  5. later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>
  12. *******************************************************************/
  13. /* libmath.c */
  14. #include "conf.h"
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <inttypes.h>
  18. #include <math.h>
  19. #include "stackN.h"
  20. static double inv(double a)
  21. {
  22. double v;
  23. if (a==0.0) v=HUGE;
  24. else v = (double)1.0/a;
  25. return v;
  26. }
  27. static long long L_round(double v) { return (long long)rint(v); }
  28. static long long L_floor(double v) { return (long long)floor(v); }
  29. static long long L_ceil(double v) { return (long long)ceil(v); }
  30. static long long L_sgn(double v)
  31. {
  32. if (v > 0.0) return (long long)1;
  33. if (v < 0.0) return (long long)-1;
  34. return (long long)0;
  35. }
  36. void IF_pi(void)
  37. {
  38. putDouble(M_PI);
  39. }
  40. void IF_inv(void) { IF_fctD_1(inv); }
  41. void IF_sqrt(void) { IF_fctD_1(sqrt); }
  42. void IF_cbrt(void) { IF_fctD_1(cbrt); }
  43. void IF_round(void) { IF_fctD_1L(L_round); }
  44. void IF_floor(void) { IF_fctD_1L(L_floor); }
  45. void IF_ceil(void) { IF_fctD_1L(L_ceil); }
  46. void IF_sgn(void) { IF_fctD_1LB(L_sgn); }
  47. /* fct trigonometriques */
  48. void IF_sin(void) { IF_fctD_1(sin); }
  49. void IF_asin(void) { IF_fctD_1(asin); }
  50. void IF_cos(void) { IF_fctD_1(cos); }
  51. void IF_acos(void) { IF_fctD_1(acos); }
  52. void IF_tan(void) { IF_fctD_1(tan); }
  53. void IF_atan(void) { IF_fctD_1(atan); }
  54. void IF_sinh(void) { IF_fctD_1(sinh); }
  55. void IF_asinh(void) { IF_fctD_1(asinh); }
  56. void IF_cosh(void) { IF_fctD_1(cosh); }
  57. void IF_acosh(void) { IF_fctD_1(acosh); }
  58. void IF_tanh(void) { IF_fctD_1(tanh); }
  59. void IF_atanh(void) { IF_fctD_1(atanh); }
  60. /* fct logarithmiques et exponentielles */
  61. void IF_ln(void) { IF_fctD_1(log); }
  62. void IF_log(void) { IF_fctD_1(log10); }
  63. void IF_exp(void) { IF_fctD_1(exp); }
  64. /* fonctions de Bessel */
  65. void IF_j0(void) { IF_fctD_1(j0); }
  66. void IF_j1(void) { IF_fctD_1(j1); }
  67. void IF_y0(void) { IF_fctD_1(y0); }
  68. void IF_y1(void) { IF_fctD_1(y1); }