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.

преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 10 години
преди 11 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // LolRemez - Remez algorithm implementation
  3. //
  4. // Copyright: (c) 2010-2013 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://www.wtfpl.net/ for more details.
  9. //
  10. #pragma once
  11. //
  12. // The RemezSolver class
  13. // ---------------------
  14. //
  15. #include <cstdio>
  16. class RemezSolver
  17. {
  18. public:
  19. typedef lol::real RealFunc(lol::real const &x);
  20. RemezSolver(int order, int decimals);
  21. void Run(lol::real a, lol::real b,
  22. RealFunc *func, RealFunc *weight = nullptr);
  23. private:
  24. lol::real EvalCheby(lol::real const &x);
  25. void Init();
  26. void FindZeroes();
  27. lol::real FindExtrema();
  28. void Step();
  29. int Cheby(int n, int k);
  30. int Comb(int n, int k);
  31. void PrintPoly();
  32. lol::real EvalFunc(lol::real const &x);
  33. lol::real Weight(lol::real const &x);
  34. private:
  35. int m_order;
  36. lol::array<lol::real> m_coeff;
  37. lol::array<lol::real> m_zeroes;
  38. lol::array<lol::real> m_control;
  39. RealFunc *m_func, *m_weight;
  40. lol::real m_k1, m_k2, m_invk1, m_invk2, m_epsilon;
  41. int m_decimals;
  42. };