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)
6 // This file is machine generated, do not edit by hand
8 // Polynomial evaluation using second order Horners rule
9 #ifndef BOOST_MATH_TOOLS_RAT_EVAL_8_HPP
10 #define BOOST_MATH_TOOLS_RAT_EVAL_8_HPP
12 namespace boost{ namespace math{ namespace tools{ namespace detail{
14 template <class T, class U, class V>
15 inline V evaluate_rational_c_imp(const T*, const U*, const V&, const mpl::int_<0>*)
17 return static_cast<V>(0);
20 template <class T, class U, class V>
21 inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const mpl::int_<1>*)
23 return static_cast<V>(a[0]) / static_cast<V>(b[0]);
26 template <class T, class U, class V>
27 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<2>*)
29 return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
32 template <class T, class U, class V>
33 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<3>*)
35 return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
38 template <class T, class U, class V>
39 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<4>*)
41 return static_cast<V>((((a[3] * x + a[2]) * x + a[1]) * x + a[0]) / (((b[3] * x + b[2]) * x + b[1]) * x + b[0]));
44 template <class T, class U, class V>
45 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<5>*)
51 t[0] = a[4] * x2 + a[2];
52 t[1] = a[3] * x2 + a[1];
53 t[2] = b[4] * x2 + b[2];
54 t[3] = b[3] * x2 + b[1];
57 t[0] += static_cast<V>(a[0]);
58 t[2] += static_cast<V>(b[0]);
61 return (t[0] + t[1]) / (t[2] + t[3]);
68 t[0] = a[0] * z2 + a[2];
69 t[1] = a[1] * z2 + a[3];
70 t[2] = b[0] * z2 + b[2];
71 t[3] = b[1] * z2 + b[3];
74 t[0] += static_cast<V>(a[4]);
75 t[2] += static_cast<V>(b[4]);
78 return (t[0] + t[1]) / (t[2] + t[3]);
82 template <class T, class U, class V>
83 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<6>*)
89 t[0] = a[5] * x2 + a[3];
90 t[1] = a[4] * x2 + a[2];
91 t[2] = b[5] * x2 + b[3];
92 t[3] = b[4] * x2 + b[2];
97 t[0] += static_cast<V>(a[1]);
98 t[1] += static_cast<V>(a[0]);
99 t[2] += static_cast<V>(b[1]);
100 t[3] += static_cast<V>(b[0]);
103 return (t[0] + t[1]) / (t[2] + t[3]);
110 t[0] = a[0] * z2 + a[2];
111 t[1] = a[1] * z2 + a[3];
112 t[2] = b[0] * z2 + b[2];
113 t[3] = b[1] * z2 + b[3];
118 t[0] += static_cast<V>(a[4]);
119 t[1] += static_cast<V>(a[5]);
120 t[2] += static_cast<V>(b[4]);
121 t[3] += static_cast<V>(b[5]);
124 return (t[0] + t[1]) / (t[2] + t[3]);
128 template <class T, class U, class V>
129 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<7>*)
135 t[0] = a[6] * x2 + a[4];
136 t[1] = a[5] * x2 + a[3];
137 t[2] = b[6] * x2 + b[4];
138 t[3] = b[5] * x2 + b[3];
143 t[0] += static_cast<V>(a[2]);
144 t[1] += static_cast<V>(a[1]);
145 t[2] += static_cast<V>(b[2]);
146 t[3] += static_cast<V>(b[1]);
149 t[0] += static_cast<V>(a[0]);
150 t[2] += static_cast<V>(b[0]);
153 return (t[0] + t[1]) / (t[2] + t[3]);
160 t[0] = a[0] * z2 + a[2];
161 t[1] = a[1] * z2 + a[3];
162 t[2] = b[0] * z2 + b[2];
163 t[3] = b[1] * z2 + b[3];
168 t[0] += static_cast<V>(a[4]);
169 t[1] += static_cast<V>(a[5]);
170 t[2] += static_cast<V>(b[4]);
171 t[3] += static_cast<V>(b[5]);
174 t[0] += static_cast<V>(a[6]);
175 t[2] += static_cast<V>(b[6]);
178 return (t[0] + t[1]) / (t[2] + t[3]);
182 template <class T, class U, class V>
183 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const mpl::int_<8>*)
189 t[0] = a[7] * x2 + a[5];
190 t[1] = a[6] * x2 + a[4];
191 t[2] = b[7] * x2 + b[5];
192 t[3] = b[6] * x2 + b[4];
197 t[0] += static_cast<V>(a[3]);
198 t[1] += static_cast<V>(a[2]);
199 t[2] += static_cast<V>(b[3]);
200 t[3] += static_cast<V>(b[2]);
205 t[0] += static_cast<V>(a[1]);
206 t[1] += static_cast<V>(a[0]);
207 t[2] += static_cast<V>(b[1]);
208 t[3] += static_cast<V>(b[0]);
211 return (t[0] + t[1]) / (t[2] + t[3]);
218 t[0] = a[0] * z2 + a[2];
219 t[1] = a[1] * z2 + a[3];
220 t[2] = b[0] * z2 + b[2];
221 t[3] = b[1] * z2 + b[3];
226 t[0] += static_cast<V>(a[4]);
227 t[1] += static_cast<V>(a[5]);
228 t[2] += static_cast<V>(b[4]);
229 t[3] += static_cast<V>(b[5]);
234 t[0] += static_cast<V>(a[6]);
235 t[1] += static_cast<V>(a[7]);
236 t[2] += static_cast<V>(b[6]);
237 t[3] += static_cast<V>(b[7]);
240 return (t[0] + t[1]) / (t[2] + t[3]);
247 #endif // include guard