您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

47 行
967 B

  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. real myfun(real const &y)
  22. {
  23. real x = sqrt(y);
  24. return (sin(x) - x) / (x * y);
  25. }
  26. real myerr(real const &y)
  27. {
  28. real x = sqrt(y);
  29. return sin(x) / (x * y);
  30. }
  31. int main(void)
  32. {
  33. RemezSolver<6> solver;
  34. solver.Run(real::R_1 >> 400, real::R_PI_2 * real::R_PI_2, myfun, myerr, 40);
  35. return EXIT_SUCCESS;
  36. }