53 lines
1.3 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. static real const a0 = real::R_1;
  24. static real const a1 = real(-11184811) >> 26;
  25. static real const b1 = real(-1) / real(6);
  26. static real const b2 = real(1) / real(120);
  27. real y = sqrt(x);
  28. return sin(y) / y;
  29. }
  30. static real myerr(real const &x)
  31. {
  32. return real::R_1;
  33. }
  34. int main(int argc, char **argv)
  35. {
  36. RemezSolver<6> solver;
  37. //solver.Run(0, 1, myfun, myfun, 15);
  38. solver.Run(exp((real)-100), real::R_PI * real::R_PI >> 2, myfun, myfun, 15);
  39. //solver.Run(-1, 1, myfun, myfun, 15);
  40. //solver.Run(0, real::R_PI * real::R_PI >> 4, myfun, myfun, 15);
  41. return EXIT_SUCCESS;
  42. }