polynomial_horner3_6.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // (C) Copyright John Maddock 2007.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. //
  6. // This file is machine generated, do not edit by hand
  7. // Unrolled polynomial evaluation using second order Horners rule
  8. #ifndef BOOST_MATH_TOOLS_POLY_EVAL_6_HPP
  9. #define BOOST_MATH_TOOLS_POLY_EVAL_6_HPP
  10. namespace boost{ namespace math{ namespace tools{ namespace detail{
  11. template <class T, class V>
  12. inline V evaluate_polynomial_c_imp(const T*, const V&, const mpl::int_<0>*) BOOST_MATH_NOEXCEPT(V)
  13. {
  14. return static_cast<V>(0);
  15. }
  16. template <class T, class V>
  17. inline V evaluate_polynomial_c_imp(const T* a, const V&, const mpl::int_<1>*) BOOST_MATH_NOEXCEPT(V)
  18. {
  19. return static_cast<V>(a[0]);
  20. }
  21. template <class T, class V>
  22. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<2>*) BOOST_MATH_NOEXCEPT(V)
  23. {
  24. return static_cast<V>(a[1] * x + a[0]);
  25. }
  26. template <class T, class V>
  27. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<3>*) BOOST_MATH_NOEXCEPT(V)
  28. {
  29. return static_cast<V>((a[2] * x + a[1]) * x + a[0]);
  30. }
  31. template <class T, class V>
  32. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<4>*) BOOST_MATH_NOEXCEPT(V)
  33. {
  34. return static_cast<V>(((a[3] * x + a[2]) * x + a[1]) * x + a[0]);
  35. }
  36. template <class T, class V>
  37. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<5>*) BOOST_MATH_NOEXCEPT(V)
  38. {
  39. V x2 = x * x;
  40. V t[2];
  41. t[0] = static_cast<V>(a[4] * x2 + a[2]);
  42. t[1] = static_cast<V>(a[3] * x2 + a[1]);
  43. t[0] *= x2;
  44. t[0] += static_cast<V>(a[0]);
  45. t[1] *= x;
  46. return t[0] + t[1];
  47. }
  48. template <class T, class V>
  49. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<6>*) BOOST_MATH_NOEXCEPT(V)
  50. {
  51. V x2 = x * x;
  52. V t[2];
  53. t[0] = a[5] * x2 + a[3];
  54. t[1] = a[4] * x2 + a[2];
  55. t[0] *= x2;
  56. t[1] *= x2;
  57. t[0] += static_cast<V>(a[1]);
  58. t[1] += static_cast<V>(a[0]);
  59. t[0] *= x;
  60. return t[0] + t[1];
  61. }
  62. }}}} // namespaces
  63. #endif // include guard