25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

56 satır
1.2 KiB

  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. };