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.
 
 
 
 

86 lines
2.5 KiB

  1. /* Copyright (C) 2011-2022 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. #ifndef HUGE
  21. #define HUGE 3.40282347e+38F
  22. #endif
  23. static double inv(double a)
  24. {
  25. double v;
  26. if (a==0.0) v=HUGE;
  27. else v = (double)1.0/a;
  28. return v;
  29. }
  30. static long long L_round(double v) { return (long long)rint(v); }
  31. static long long L_floor(double v) { return (long long)floor(v); }
  32. static long long L_ceil(double v) { return (long long)ceil(v); }
  33. static long long L_sgn(double v)
  34. {
  35. if (v > 0.0) return (long long)1;
  36. if (v < 0.0) return (long long)-1;
  37. return (long long)0;
  38. }
  39. void IF_pi(void)
  40. {
  41. putDouble(M_PI);
  42. }
  43. void IF_inv(void) { IF_fctD_1(inv); }
  44. void IF_sqrt(void) { IF_fctD_1(sqrt); }
  45. void IF_cbrt(void) { IF_fctD_1(cbrt); }
  46. void IF_round(void) { IF_fctD_1L(L_round); }
  47. void IF_floor(void) { IF_fctD_1L(L_floor); }
  48. void IF_ceil(void) { IF_fctD_1L(L_ceil); }
  49. void IF_sgn(void) { IF_fctD_1LB(L_sgn); }
  50. /* fct trigonometriques */
  51. void IF_sin(void) { IF_fctD_1(sin); }
  52. void IF_asin(void) { IF_fctD_1(asin); }
  53. void IF_cos(void) { IF_fctD_1(cos); }
  54. void IF_acos(void) { IF_fctD_1(acos); }
  55. void IF_tan(void) { IF_fctD_1(tan); }
  56. void IF_atan(void) { IF_fctD_1(atan); }
  57. void IF_sinh(void) { IF_fctD_1(sinh); }
  58. void IF_asinh(void) { IF_fctD_1(asinh); }
  59. void IF_cosh(void) { IF_fctD_1(cosh); }
  60. void IF_acosh(void) { IF_fctD_1(acosh); }
  61. void IF_tanh(void) { IF_fctD_1(tanh); }
  62. void IF_atanh(void) { IF_fctD_1(atanh); }
  63. /* fct logarithmiques et exponentielles */
  64. void IF_ln(void) { IF_fctD_1(log); }
  65. void IF_log(void) { IF_fctD_1(log10); }
  66. void IF_exp(void) { IF_fctD_1(exp); }
  67. /* fonctions de Bessel */
  68. void IF_j0(void) { IF_fctD_1(j0); }
  69. void IF_j1(void) { IF_fctD_1(j1); }
  70. void IF_y0(void) { IF_fctD_1(y0); }
  71. void IF_y1(void) { IF_fctD_1(y1); }