Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

50 lignes
1.1 KiB

  1. //
  2. // Lol Engine - Sample math program: Chebyshev polynomials
  3. //
  4. // Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstring>
  14. #include <cstdio>
  15. #include "core.h"
  16. using namespace lol;
  17. using namespace std;
  18. #include "remez-matrix.h"
  19. #include "remez-solver.h"
  20. /* The function we want to approximate */
  21. static real myfun(real const &x)
  22. {
  23. real y = sqrt(x);
  24. if (!y)
  25. return real::R_PI_2;
  26. return sin(real::R_PI_2 * y) / y;
  27. }
  28. static real myerr(real const &x)
  29. {
  30. return real::R_1;
  31. }
  32. int main(int argc, char **argv)
  33. {
  34. RemezSolver<4> solver;
  35. solver.Run(0, 1, myfun, myfun, 15);
  36. //solver.Run(-1, 1, myfun, myfun, 15);
  37. //solver.Run(0, real::R_PI * real::R_PI >> 4, myfun, myfun, 15);
  38. return EXIT_SUCCESS;
  39. }