polynomial_horner3_8.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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_8_HPP
  9. #define BOOST_MATH_TOOLS_POLY_EVAL_8_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. template <class T, class V>
  63. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<7>*) BOOST_MATH_NOEXCEPT(V)
  64. {
  65. V x2 = x * x;
  66. V t[2];
  67. t[0] = static_cast<V>(a[6] * x2 + a[4]);
  68. t[1] = static_cast<V>(a[5] * x2 + a[3]);
  69. t[0] *= x2;
  70. t[1] *= x2;
  71. t[0] += static_cast<V>(a[2]);
  72. t[1] += static_cast<V>(a[1]);
  73. t[0] *= x2;
  74. t[0] += static_cast<V>(a[0]);
  75. t[1] *= x;
  76. return t[0] + t[1];
  77. }
  78. template <class T, class V>
  79. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<8>*) BOOST_MATH_NOEXCEPT(V)
  80. {
  81. V x2 = x * x;
  82. V t[2];
  83. t[0] = a[7] * x2 + a[5];
  84. t[1] = a[6] * x2 + a[4];
  85. t[0] *= x2;
  86. t[1] *= x2;
  87. t[0] += static_cast<V>(a[3]);
  88. t[1] += static_cast<V>(a[2]);
  89. t[0] *= x2;
  90. t[1] *= x2;
  91. t[0] += static_cast<V>(a[1]);
  92. t[1] += static_cast<V>(a[0]);
  93. t[0] *= x;
  94. return t[0] + t[1];
  95. }
  96. }}}} // namespaces
  97. #endif // include guard