polynomial_horner3_20.hpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  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_20_HPP
  9. #define BOOST_MATH_TOOLS_POLY_EVAL_20_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. template <class T, class V>
  97. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<9>*) BOOST_MATH_NOEXCEPT(V)
  98. {
  99. V x2 = x * x;
  100. V t[2];
  101. t[0] = static_cast<V>(a[8] * x2 + a[6]);
  102. t[1] = static_cast<V>(a[7] * x2 + a[5]);
  103. t[0] *= x2;
  104. t[1] *= x2;
  105. t[0] += static_cast<V>(a[4]);
  106. t[1] += static_cast<V>(a[3]);
  107. t[0] *= x2;
  108. t[1] *= x2;
  109. t[0] += static_cast<V>(a[2]);
  110. t[1] += static_cast<V>(a[1]);
  111. t[0] *= x2;
  112. t[0] += static_cast<V>(a[0]);
  113. t[1] *= x;
  114. return t[0] + t[1];
  115. }
  116. template <class T, class V>
  117. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<10>*) BOOST_MATH_NOEXCEPT(V)
  118. {
  119. V x2 = x * x;
  120. V t[2];
  121. t[0] = a[9] * x2 + a[7];
  122. t[1] = a[8] * x2 + a[6];
  123. t[0] *= x2;
  124. t[1] *= x2;
  125. t[0] += static_cast<V>(a[5]);
  126. t[1] += static_cast<V>(a[4]);
  127. t[0] *= x2;
  128. t[1] *= x2;
  129. t[0] += static_cast<V>(a[3]);
  130. t[1] += static_cast<V>(a[2]);
  131. t[0] *= x2;
  132. t[1] *= x2;
  133. t[0] += static_cast<V>(a[1]);
  134. t[1] += static_cast<V>(a[0]);
  135. t[0] *= x;
  136. return t[0] + t[1];
  137. }
  138. template <class T, class V>
  139. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<11>*) BOOST_MATH_NOEXCEPT(V)
  140. {
  141. V x2 = x * x;
  142. V t[2];
  143. t[0] = static_cast<V>(a[10] * x2 + a[8]);
  144. t[1] = static_cast<V>(a[9] * x2 + a[7]);
  145. t[0] *= x2;
  146. t[1] *= x2;
  147. t[0] += static_cast<V>(a[6]);
  148. t[1] += static_cast<V>(a[5]);
  149. t[0] *= x2;
  150. t[1] *= x2;
  151. t[0] += static_cast<V>(a[4]);
  152. t[1] += static_cast<V>(a[3]);
  153. t[0] *= x2;
  154. t[1] *= x2;
  155. t[0] += static_cast<V>(a[2]);
  156. t[1] += static_cast<V>(a[1]);
  157. t[0] *= x2;
  158. t[0] += static_cast<V>(a[0]);
  159. t[1] *= x;
  160. return t[0] + t[1];
  161. }
  162. template <class T, class V>
  163. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<12>*) BOOST_MATH_NOEXCEPT(V)
  164. {
  165. V x2 = x * x;
  166. V t[2];
  167. t[0] = a[11] * x2 + a[9];
  168. t[1] = a[10] * x2 + a[8];
  169. t[0] *= x2;
  170. t[1] *= x2;
  171. t[0] += static_cast<V>(a[7]);
  172. t[1] += static_cast<V>(a[6]);
  173. t[0] *= x2;
  174. t[1] *= x2;
  175. t[0] += static_cast<V>(a[5]);
  176. t[1] += static_cast<V>(a[4]);
  177. t[0] *= x2;
  178. t[1] *= x2;
  179. t[0] += static_cast<V>(a[3]);
  180. t[1] += static_cast<V>(a[2]);
  181. t[0] *= x2;
  182. t[1] *= x2;
  183. t[0] += static_cast<V>(a[1]);
  184. t[1] += static_cast<V>(a[0]);
  185. t[0] *= x;
  186. return t[0] + t[1];
  187. }
  188. template <class T, class V>
  189. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<13>*) BOOST_MATH_NOEXCEPT(V)
  190. {
  191. V x2 = x * x;
  192. V t[2];
  193. t[0] = static_cast<V>(a[12] * x2 + a[10]);
  194. t[1] = static_cast<V>(a[11] * x2 + a[9]);
  195. t[0] *= x2;
  196. t[1] *= x2;
  197. t[0] += static_cast<V>(a[8]);
  198. t[1] += static_cast<V>(a[7]);
  199. t[0] *= x2;
  200. t[1] *= x2;
  201. t[0] += static_cast<V>(a[6]);
  202. t[1] += static_cast<V>(a[5]);
  203. t[0] *= x2;
  204. t[1] *= x2;
  205. t[0] += static_cast<V>(a[4]);
  206. t[1] += static_cast<V>(a[3]);
  207. t[0] *= x2;
  208. t[1] *= x2;
  209. t[0] += static_cast<V>(a[2]);
  210. t[1] += static_cast<V>(a[1]);
  211. t[0] *= x2;
  212. t[0] += static_cast<V>(a[0]);
  213. t[1] *= x;
  214. return t[0] + t[1];
  215. }
  216. template <class T, class V>
  217. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<14>*) BOOST_MATH_NOEXCEPT(V)
  218. {
  219. V x2 = x * x;
  220. V t[2];
  221. t[0] = a[13] * x2 + a[11];
  222. t[1] = a[12] * x2 + a[10];
  223. t[0] *= x2;
  224. t[1] *= x2;
  225. t[0] += static_cast<V>(a[9]);
  226. t[1] += static_cast<V>(a[8]);
  227. t[0] *= x2;
  228. t[1] *= x2;
  229. t[0] += static_cast<V>(a[7]);
  230. t[1] += static_cast<V>(a[6]);
  231. t[0] *= x2;
  232. t[1] *= x2;
  233. t[0] += static_cast<V>(a[5]);
  234. t[1] += static_cast<V>(a[4]);
  235. t[0] *= x2;
  236. t[1] *= x2;
  237. t[0] += static_cast<V>(a[3]);
  238. t[1] += static_cast<V>(a[2]);
  239. t[0] *= x2;
  240. t[1] *= x2;
  241. t[0] += static_cast<V>(a[1]);
  242. t[1] += static_cast<V>(a[0]);
  243. t[0] *= x;
  244. return t[0] + t[1];
  245. }
  246. template <class T, class V>
  247. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<15>*) BOOST_MATH_NOEXCEPT(V)
  248. {
  249. V x2 = x * x;
  250. V t[2];
  251. t[0] = static_cast<V>(a[14] * x2 + a[12]);
  252. t[1] = static_cast<V>(a[13] * x2 + a[11]);
  253. t[0] *= x2;
  254. t[1] *= x2;
  255. t[0] += static_cast<V>(a[10]);
  256. t[1] += static_cast<V>(a[9]);
  257. t[0] *= x2;
  258. t[1] *= x2;
  259. t[0] += static_cast<V>(a[8]);
  260. t[1] += static_cast<V>(a[7]);
  261. t[0] *= x2;
  262. t[1] *= x2;
  263. t[0] += static_cast<V>(a[6]);
  264. t[1] += static_cast<V>(a[5]);
  265. t[0] *= x2;
  266. t[1] *= x2;
  267. t[0] += static_cast<V>(a[4]);
  268. t[1] += static_cast<V>(a[3]);
  269. t[0] *= x2;
  270. t[1] *= x2;
  271. t[0] += static_cast<V>(a[2]);
  272. t[1] += static_cast<V>(a[1]);
  273. t[0] *= x2;
  274. t[0] += static_cast<V>(a[0]);
  275. t[1] *= x;
  276. return t[0] + t[1];
  277. }
  278. template <class T, class V>
  279. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<16>*) BOOST_MATH_NOEXCEPT(V)
  280. {
  281. V x2 = x * x;
  282. V t[2];
  283. t[0] = a[15] * x2 + a[13];
  284. t[1] = a[14] * x2 + a[12];
  285. t[0] *= x2;
  286. t[1] *= x2;
  287. t[0] += static_cast<V>(a[11]);
  288. t[1] += static_cast<V>(a[10]);
  289. t[0] *= x2;
  290. t[1] *= x2;
  291. t[0] += static_cast<V>(a[9]);
  292. t[1] += static_cast<V>(a[8]);
  293. t[0] *= x2;
  294. t[1] *= x2;
  295. t[0] += static_cast<V>(a[7]);
  296. t[1] += static_cast<V>(a[6]);
  297. t[0] *= x2;
  298. t[1] *= x2;
  299. t[0] += static_cast<V>(a[5]);
  300. t[1] += static_cast<V>(a[4]);
  301. t[0] *= x2;
  302. t[1] *= x2;
  303. t[0] += static_cast<V>(a[3]);
  304. t[1] += static_cast<V>(a[2]);
  305. t[0] *= x2;
  306. t[1] *= x2;
  307. t[0] += static_cast<V>(a[1]);
  308. t[1] += static_cast<V>(a[0]);
  309. t[0] *= x;
  310. return t[0] + t[1];
  311. }
  312. template <class T, class V>
  313. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<17>*) BOOST_MATH_NOEXCEPT(V)
  314. {
  315. V x2 = x * x;
  316. V t[2];
  317. t[0] = static_cast<V>(a[16] * x2 + a[14]);
  318. t[1] = static_cast<V>(a[15] * x2 + a[13]);
  319. t[0] *= x2;
  320. t[1] *= x2;
  321. t[0] += static_cast<V>(a[12]);
  322. t[1] += static_cast<V>(a[11]);
  323. t[0] *= x2;
  324. t[1] *= x2;
  325. t[0] += static_cast<V>(a[10]);
  326. t[1] += static_cast<V>(a[9]);
  327. t[0] *= x2;
  328. t[1] *= x2;
  329. t[0] += static_cast<V>(a[8]);
  330. t[1] += static_cast<V>(a[7]);
  331. t[0] *= x2;
  332. t[1] *= x2;
  333. t[0] += static_cast<V>(a[6]);
  334. t[1] += static_cast<V>(a[5]);
  335. t[0] *= x2;
  336. t[1] *= x2;
  337. t[0] += static_cast<V>(a[4]);
  338. t[1] += static_cast<V>(a[3]);
  339. t[0] *= x2;
  340. t[1] *= x2;
  341. t[0] += static_cast<V>(a[2]);
  342. t[1] += static_cast<V>(a[1]);
  343. t[0] *= x2;
  344. t[0] += static_cast<V>(a[0]);
  345. t[1] *= x;
  346. return t[0] + t[1];
  347. }
  348. template <class T, class V>
  349. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<18>*) BOOST_MATH_NOEXCEPT(V)
  350. {
  351. V x2 = x * x;
  352. V t[2];
  353. t[0] = a[17] * x2 + a[15];
  354. t[1] = a[16] * x2 + a[14];
  355. t[0] *= x2;
  356. t[1] *= x2;
  357. t[0] += static_cast<V>(a[13]);
  358. t[1] += static_cast<V>(a[12]);
  359. t[0] *= x2;
  360. t[1] *= x2;
  361. t[0] += static_cast<V>(a[11]);
  362. t[1] += static_cast<V>(a[10]);
  363. t[0] *= x2;
  364. t[1] *= x2;
  365. t[0] += static_cast<V>(a[9]);
  366. t[1] += static_cast<V>(a[8]);
  367. t[0] *= x2;
  368. t[1] *= x2;
  369. t[0] += static_cast<V>(a[7]);
  370. t[1] += static_cast<V>(a[6]);
  371. t[0] *= x2;
  372. t[1] *= x2;
  373. t[0] += static_cast<V>(a[5]);
  374. t[1] += static_cast<V>(a[4]);
  375. t[0] *= x2;
  376. t[1] *= x2;
  377. t[0] += static_cast<V>(a[3]);
  378. t[1] += static_cast<V>(a[2]);
  379. t[0] *= x2;
  380. t[1] *= x2;
  381. t[0] += static_cast<V>(a[1]);
  382. t[1] += static_cast<V>(a[0]);
  383. t[0] *= x;
  384. return t[0] + t[1];
  385. }
  386. template <class T, class V>
  387. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<19>*) BOOST_MATH_NOEXCEPT(V)
  388. {
  389. V x2 = x * x;
  390. V t[2];
  391. t[0] = static_cast<V>(a[18] * x2 + a[16]);
  392. t[1] = static_cast<V>(a[17] * x2 + a[15]);
  393. t[0] *= x2;
  394. t[1] *= x2;
  395. t[0] += static_cast<V>(a[14]);
  396. t[1] += static_cast<V>(a[13]);
  397. t[0] *= x2;
  398. t[1] *= x2;
  399. t[0] += static_cast<V>(a[12]);
  400. t[1] += static_cast<V>(a[11]);
  401. t[0] *= x2;
  402. t[1] *= x2;
  403. t[0] += static_cast<V>(a[10]);
  404. t[1] += static_cast<V>(a[9]);
  405. t[0] *= x2;
  406. t[1] *= x2;
  407. t[0] += static_cast<V>(a[8]);
  408. t[1] += static_cast<V>(a[7]);
  409. t[0] *= x2;
  410. t[1] *= x2;
  411. t[0] += static_cast<V>(a[6]);
  412. t[1] += static_cast<V>(a[5]);
  413. t[0] *= x2;
  414. t[1] *= x2;
  415. t[0] += static_cast<V>(a[4]);
  416. t[1] += static_cast<V>(a[3]);
  417. t[0] *= x2;
  418. t[1] *= x2;
  419. t[0] += static_cast<V>(a[2]);
  420. t[1] += static_cast<V>(a[1]);
  421. t[0] *= x2;
  422. t[0] += static_cast<V>(a[0]);
  423. t[1] *= x;
  424. return t[0] + t[1];
  425. }
  426. template <class T, class V>
  427. inline V evaluate_polynomial_c_imp(const T* a, const V& x, const mpl::int_<20>*) BOOST_MATH_NOEXCEPT(V)
  428. {
  429. V x2 = x * x;
  430. V t[2];
  431. t[0] = a[19] * x2 + a[17];
  432. t[1] = a[18] * x2 + a[16];
  433. t[0] *= x2;
  434. t[1] *= x2;
  435. t[0] += static_cast<V>(a[15]);
  436. t[1] += static_cast<V>(a[14]);
  437. t[0] *= x2;
  438. t[1] *= x2;
  439. t[0] += static_cast<V>(a[13]);
  440. t[1] += static_cast<V>(a[12]);
  441. t[0] *= x2;
  442. t[1] *= x2;
  443. t[0] += static_cast<V>(a[11]);
  444. t[1] += static_cast<V>(a[10]);
  445. t[0] *= x2;
  446. t[1] *= x2;
  447. t[0] += static_cast<V>(a[9]);
  448. t[1] += static_cast<V>(a[8]);
  449. t[0] *= x2;
  450. t[1] *= x2;
  451. t[0] += static_cast<V>(a[7]);
  452. t[1] += static_cast<V>(a[6]);
  453. t[0] *= x2;
  454. t[1] *= x2;
  455. t[0] += static_cast<V>(a[5]);
  456. t[1] += static_cast<V>(a[4]);
  457. t[0] *= x2;
  458. t[1] *= x2;
  459. t[0] += static_cast<V>(a[3]);
  460. t[1] += static_cast<V>(a[2]);
  461. t[0] *= x2;
  462. t[1] *= x2;
  463. t[0] += static_cast<V>(a[1]);
  464. t[1] += static_cast<V>(a[0]);
  465. t[0] *= x;
  466. return t[0] + t[1];
  467. }
  468. }}}} // namespaces
  469. #endif // include guard