File indexing completed on 2025-01-18 09:40:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_MATH_TOOLS_RAT_EVAL_11_HPP
0010 #define BOOST_MATH_TOOLS_RAT_EVAL_11_HPP
0011
0012 namespace boost{ namespace math{ namespace tools{ namespace detail{
0013
0014 template <class T, class U, class V>
0015 inline V evaluate_rational_c_imp(const T*, const U*, const V&, const std::integral_constant<int, 0>*) BOOST_MATH_NOEXCEPT(V)
0016 {
0017 return static_cast<V>(0);
0018 }
0019
0020 template <class T, class U, class V>
0021 inline V evaluate_rational_c_imp(const T* a, const U* b, const V&, const std::integral_constant<int, 1>*) BOOST_MATH_NOEXCEPT(V)
0022 {
0023 return static_cast<V>(a[0]) / static_cast<V>(b[0]);
0024 }
0025
0026 template <class T, class U, class V>
0027 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 2>*) BOOST_MATH_NOEXCEPT(V)
0028 {
0029 return static_cast<V>((a[1] * x + a[0]) / (b[1] * x + b[0]));
0030 }
0031
0032 template <class T, class U, class V>
0033 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 3>*) BOOST_MATH_NOEXCEPT(V)
0034 {
0035 return static_cast<V>(((a[2] * x + a[1]) * x + a[0]) / ((b[2] * x + b[1]) * x + b[0]));
0036 }
0037
0038 template <class T, class U, class V>
0039 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 4>*) BOOST_MATH_NOEXCEPT(V)
0040 {
0041 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]));
0042 }
0043
0044 template <class T, class U, class V>
0045 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 5>*) BOOST_MATH_NOEXCEPT(V)
0046 {
0047 if(x <= 1)
0048 {
0049 V x2 = x * x;
0050 V t[4];
0051 t[0] = a[4] * x2 + a[2];
0052 t[1] = a[3] * x2 + a[1];
0053 t[2] = b[4] * x2 + b[2];
0054 t[3] = b[3] * x2 + b[1];
0055 t[0] *= x2;
0056 t[2] *= x2;
0057 t[0] += static_cast<V>(a[0]);
0058 t[2] += static_cast<V>(b[0]);
0059 t[1] *= x;
0060 t[3] *= x;
0061 return (t[0] + t[1]) / (t[2] + t[3]);
0062 }
0063 else
0064 {
0065 V z = 1 / x;
0066 V z2 = 1 / (x * x);
0067 V t[4];
0068 t[0] = a[0] * z2 + a[2];
0069 t[1] = a[1] * z2 + a[3];
0070 t[2] = b[0] * z2 + b[2];
0071 t[3] = b[1] * z2 + b[3];
0072 t[0] *= z2;
0073 t[2] *= z2;
0074 t[0] += static_cast<V>(a[4]);
0075 t[2] += static_cast<V>(b[4]);
0076 t[1] *= z;
0077 t[3] *= z;
0078 return (t[0] + t[1]) / (t[2] + t[3]);
0079 }
0080 }
0081
0082 template <class T, class U, class V>
0083 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 6>*) BOOST_MATH_NOEXCEPT(V)
0084 {
0085 if(x <= 1)
0086 {
0087 V x2 = x * x;
0088 V t[4];
0089 t[0] = a[5] * x2 + a[3];
0090 t[1] = a[4] * x2 + a[2];
0091 t[2] = b[5] * x2 + b[3];
0092 t[3] = b[4] * x2 + b[2];
0093 t[0] *= x2;
0094 t[1] *= x2;
0095 t[2] *= x2;
0096 t[3] *= x2;
0097 t[0] += static_cast<V>(a[1]);
0098 t[1] += static_cast<V>(a[0]);
0099 t[2] += static_cast<V>(b[1]);
0100 t[3] += static_cast<V>(b[0]);
0101 t[0] *= x;
0102 t[2] *= x;
0103 return (t[0] + t[1]) / (t[2] + t[3]);
0104 }
0105 else
0106 {
0107 V z = 1 / x;
0108 V z2 = 1 / (x * x);
0109 V t[4];
0110 t[0] = a[0] * z2 + a[2];
0111 t[1] = a[1] * z2 + a[3];
0112 t[2] = b[0] * z2 + b[2];
0113 t[3] = b[1] * z2 + b[3];
0114 t[0] *= z2;
0115 t[1] *= z2;
0116 t[2] *= z2;
0117 t[3] *= z2;
0118 t[0] += static_cast<V>(a[4]);
0119 t[1] += static_cast<V>(a[5]);
0120 t[2] += static_cast<V>(b[4]);
0121 t[3] += static_cast<V>(b[5]);
0122 t[0] *= z;
0123 t[2] *= z;
0124 return (t[0] + t[1]) / (t[2] + t[3]);
0125 }
0126 }
0127
0128 template <class T, class U, class V>
0129 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 7>*) BOOST_MATH_NOEXCEPT(V)
0130 {
0131 if(x <= 1)
0132 {
0133 V x2 = x * x;
0134 V t[4];
0135 t[0] = a[6] * x2 + a[4];
0136 t[1] = a[5] * x2 + a[3];
0137 t[2] = b[6] * x2 + b[4];
0138 t[3] = b[5] * x2 + b[3];
0139 t[0] *= x2;
0140 t[1] *= x2;
0141 t[2] *= x2;
0142 t[3] *= x2;
0143 t[0] += static_cast<V>(a[2]);
0144 t[1] += static_cast<V>(a[1]);
0145 t[2] += static_cast<V>(b[2]);
0146 t[3] += static_cast<V>(b[1]);
0147 t[0] *= x2;
0148 t[2] *= x2;
0149 t[0] += static_cast<V>(a[0]);
0150 t[2] += static_cast<V>(b[0]);
0151 t[1] *= x;
0152 t[3] *= x;
0153 return (t[0] + t[1]) / (t[2] + t[3]);
0154 }
0155 else
0156 {
0157 V z = 1 / x;
0158 V z2 = 1 / (x * x);
0159 V t[4];
0160 t[0] = a[0] * z2 + a[2];
0161 t[1] = a[1] * z2 + a[3];
0162 t[2] = b[0] * z2 + b[2];
0163 t[3] = b[1] * z2 + b[3];
0164 t[0] *= z2;
0165 t[1] *= z2;
0166 t[2] *= z2;
0167 t[3] *= z2;
0168 t[0] += static_cast<V>(a[4]);
0169 t[1] += static_cast<V>(a[5]);
0170 t[2] += static_cast<V>(b[4]);
0171 t[3] += static_cast<V>(b[5]);
0172 t[0] *= z2;
0173 t[2] *= z2;
0174 t[0] += static_cast<V>(a[6]);
0175 t[2] += static_cast<V>(b[6]);
0176 t[1] *= z;
0177 t[3] *= z;
0178 return (t[0] + t[1]) / (t[2] + t[3]);
0179 }
0180 }
0181
0182 template <class T, class U, class V>
0183 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 8>*) BOOST_MATH_NOEXCEPT(V)
0184 {
0185 if(x <= 1)
0186 {
0187 V x2 = x * x;
0188 V t[4];
0189 t[0] = a[7] * x2 + a[5];
0190 t[1] = a[6] * x2 + a[4];
0191 t[2] = b[7] * x2 + b[5];
0192 t[3] = b[6] * x2 + b[4];
0193 t[0] *= x2;
0194 t[1] *= x2;
0195 t[2] *= x2;
0196 t[3] *= x2;
0197 t[0] += static_cast<V>(a[3]);
0198 t[1] += static_cast<V>(a[2]);
0199 t[2] += static_cast<V>(b[3]);
0200 t[3] += static_cast<V>(b[2]);
0201 t[0] *= x2;
0202 t[1] *= x2;
0203 t[2] *= x2;
0204 t[3] *= x2;
0205 t[0] += static_cast<V>(a[1]);
0206 t[1] += static_cast<V>(a[0]);
0207 t[2] += static_cast<V>(b[1]);
0208 t[3] += static_cast<V>(b[0]);
0209 t[0] *= x;
0210 t[2] *= x;
0211 return (t[0] + t[1]) / (t[2] + t[3]);
0212 }
0213 else
0214 {
0215 V z = 1 / x;
0216 V z2 = 1 / (x * x);
0217 V t[4];
0218 t[0] = a[0] * z2 + a[2];
0219 t[1] = a[1] * z2 + a[3];
0220 t[2] = b[0] * z2 + b[2];
0221 t[3] = b[1] * z2 + b[3];
0222 t[0] *= z2;
0223 t[1] *= z2;
0224 t[2] *= z2;
0225 t[3] *= z2;
0226 t[0] += static_cast<V>(a[4]);
0227 t[1] += static_cast<V>(a[5]);
0228 t[2] += static_cast<V>(b[4]);
0229 t[3] += static_cast<V>(b[5]);
0230 t[0] *= z2;
0231 t[1] *= z2;
0232 t[2] *= z2;
0233 t[3] *= z2;
0234 t[0] += static_cast<V>(a[6]);
0235 t[1] += static_cast<V>(a[7]);
0236 t[2] += static_cast<V>(b[6]);
0237 t[3] += static_cast<V>(b[7]);
0238 t[0] *= z;
0239 t[2] *= z;
0240 return (t[0] + t[1]) / (t[2] + t[3]);
0241 }
0242 }
0243
0244 template <class T, class U, class V>
0245 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 9>*) BOOST_MATH_NOEXCEPT(V)
0246 {
0247 if(x <= 1)
0248 {
0249 V x2 = x * x;
0250 V t[4];
0251 t[0] = a[8] * x2 + a[6];
0252 t[1] = a[7] * x2 + a[5];
0253 t[2] = b[8] * x2 + b[6];
0254 t[3] = b[7] * x2 + b[5];
0255 t[0] *= x2;
0256 t[1] *= x2;
0257 t[2] *= x2;
0258 t[3] *= x2;
0259 t[0] += static_cast<V>(a[4]);
0260 t[1] += static_cast<V>(a[3]);
0261 t[2] += static_cast<V>(b[4]);
0262 t[3] += static_cast<V>(b[3]);
0263 t[0] *= x2;
0264 t[1] *= x2;
0265 t[2] *= x2;
0266 t[3] *= x2;
0267 t[0] += static_cast<V>(a[2]);
0268 t[1] += static_cast<V>(a[1]);
0269 t[2] += static_cast<V>(b[2]);
0270 t[3] += static_cast<V>(b[1]);
0271 t[0] *= x2;
0272 t[2] *= x2;
0273 t[0] += static_cast<V>(a[0]);
0274 t[2] += static_cast<V>(b[0]);
0275 t[1] *= x;
0276 t[3] *= x;
0277 return (t[0] + t[1]) / (t[2] + t[3]);
0278 }
0279 else
0280 {
0281 V z = 1 / x;
0282 V z2 = 1 / (x * x);
0283 V t[4];
0284 t[0] = a[0] * z2 + a[2];
0285 t[1] = a[1] * z2 + a[3];
0286 t[2] = b[0] * z2 + b[2];
0287 t[3] = b[1] * z2 + b[3];
0288 t[0] *= z2;
0289 t[1] *= z2;
0290 t[2] *= z2;
0291 t[3] *= z2;
0292 t[0] += static_cast<V>(a[4]);
0293 t[1] += static_cast<V>(a[5]);
0294 t[2] += static_cast<V>(b[4]);
0295 t[3] += static_cast<V>(b[5]);
0296 t[0] *= z2;
0297 t[1] *= z2;
0298 t[2] *= z2;
0299 t[3] *= z2;
0300 t[0] += static_cast<V>(a[6]);
0301 t[1] += static_cast<V>(a[7]);
0302 t[2] += static_cast<V>(b[6]);
0303 t[3] += static_cast<V>(b[7]);
0304 t[0] *= z2;
0305 t[2] *= z2;
0306 t[0] += static_cast<V>(a[8]);
0307 t[2] += static_cast<V>(b[8]);
0308 t[1] *= z;
0309 t[3] *= z;
0310 return (t[0] + t[1]) / (t[2] + t[3]);
0311 }
0312 }
0313
0314 template <class T, class U, class V>
0315 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 10>*) BOOST_MATH_NOEXCEPT(V)
0316 {
0317 if(x <= 1)
0318 {
0319 V x2 = x * x;
0320 V t[4];
0321 t[0] = a[9] * x2 + a[7];
0322 t[1] = a[8] * x2 + a[6];
0323 t[2] = b[9] * x2 + b[7];
0324 t[3] = b[8] * x2 + b[6];
0325 t[0] *= x2;
0326 t[1] *= x2;
0327 t[2] *= x2;
0328 t[3] *= x2;
0329 t[0] += static_cast<V>(a[5]);
0330 t[1] += static_cast<V>(a[4]);
0331 t[2] += static_cast<V>(b[5]);
0332 t[3] += static_cast<V>(b[4]);
0333 t[0] *= x2;
0334 t[1] *= x2;
0335 t[2] *= x2;
0336 t[3] *= x2;
0337 t[0] += static_cast<V>(a[3]);
0338 t[1] += static_cast<V>(a[2]);
0339 t[2] += static_cast<V>(b[3]);
0340 t[3] += static_cast<V>(b[2]);
0341 t[0] *= x2;
0342 t[1] *= x2;
0343 t[2] *= x2;
0344 t[3] *= x2;
0345 t[0] += static_cast<V>(a[1]);
0346 t[1] += static_cast<V>(a[0]);
0347 t[2] += static_cast<V>(b[1]);
0348 t[3] += static_cast<V>(b[0]);
0349 t[0] *= x;
0350 t[2] *= x;
0351 return (t[0] + t[1]) / (t[2] + t[3]);
0352 }
0353 else
0354 {
0355 V z = 1 / x;
0356 V z2 = 1 / (x * x);
0357 V t[4];
0358 t[0] = a[0] * z2 + a[2];
0359 t[1] = a[1] * z2 + a[3];
0360 t[2] = b[0] * z2 + b[2];
0361 t[3] = b[1] * z2 + b[3];
0362 t[0] *= z2;
0363 t[1] *= z2;
0364 t[2] *= z2;
0365 t[3] *= z2;
0366 t[0] += static_cast<V>(a[4]);
0367 t[1] += static_cast<V>(a[5]);
0368 t[2] += static_cast<V>(b[4]);
0369 t[3] += static_cast<V>(b[5]);
0370 t[0] *= z2;
0371 t[1] *= z2;
0372 t[2] *= z2;
0373 t[3] *= z2;
0374 t[0] += static_cast<V>(a[6]);
0375 t[1] += static_cast<V>(a[7]);
0376 t[2] += static_cast<V>(b[6]);
0377 t[3] += static_cast<V>(b[7]);
0378 t[0] *= z2;
0379 t[1] *= z2;
0380 t[2] *= z2;
0381 t[3] *= z2;
0382 t[0] += static_cast<V>(a[8]);
0383 t[1] += static_cast<V>(a[9]);
0384 t[2] += static_cast<V>(b[8]);
0385 t[3] += static_cast<V>(b[9]);
0386 t[0] *= z;
0387 t[2] *= z;
0388 return (t[0] + t[1]) / (t[2] + t[3]);
0389 }
0390 }
0391
0392 template <class T, class U, class V>
0393 inline V evaluate_rational_c_imp(const T* a, const U* b, const V& x, const std::integral_constant<int, 11>*) BOOST_MATH_NOEXCEPT(V)
0394 {
0395 if(x <= 1)
0396 {
0397 V x2 = x * x;
0398 V t[4];
0399 t[0] = a[10] * x2 + a[8];
0400 t[1] = a[9] * x2 + a[7];
0401 t[2] = b[10] * x2 + b[8];
0402 t[3] = b[9] * x2 + b[7];
0403 t[0] *= x2;
0404 t[1] *= x2;
0405 t[2] *= x2;
0406 t[3] *= x2;
0407 t[0] += static_cast<V>(a[6]);
0408 t[1] += static_cast<V>(a[5]);
0409 t[2] += static_cast<V>(b[6]);
0410 t[3] += static_cast<V>(b[5]);
0411 t[0] *= x2;
0412 t[1] *= x2;
0413 t[2] *= x2;
0414 t[3] *= x2;
0415 t[0] += static_cast<V>(a[4]);
0416 t[1] += static_cast<V>(a[3]);
0417 t[2] += static_cast<V>(b[4]);
0418 t[3] += static_cast<V>(b[3]);
0419 t[0] *= x2;
0420 t[1] *= x2;
0421 t[2] *= x2;
0422 t[3] *= x2;
0423 t[0] += static_cast<V>(a[2]);
0424 t[1] += static_cast<V>(a[1]);
0425 t[2] += static_cast<V>(b[2]);
0426 t[3] += static_cast<V>(b[1]);
0427 t[0] *= x2;
0428 t[2] *= x2;
0429 t[0] += static_cast<V>(a[0]);
0430 t[2] += static_cast<V>(b[0]);
0431 t[1] *= x;
0432 t[3] *= x;
0433 return (t[0] + t[1]) / (t[2] + t[3]);
0434 }
0435 else
0436 {
0437 V z = 1 / x;
0438 V z2 = 1 / (x * x);
0439 V t[4];
0440 t[0] = a[0] * z2 + a[2];
0441 t[1] = a[1] * z2 + a[3];
0442 t[2] = b[0] * z2 + b[2];
0443 t[3] = b[1] * z2 + b[3];
0444 t[0] *= z2;
0445 t[1] *= z2;
0446 t[2] *= z2;
0447 t[3] *= z2;
0448 t[0] += static_cast<V>(a[4]);
0449 t[1] += static_cast<V>(a[5]);
0450 t[2] += static_cast<V>(b[4]);
0451 t[3] += static_cast<V>(b[5]);
0452 t[0] *= z2;
0453 t[1] *= z2;
0454 t[2] *= z2;
0455 t[3] *= z2;
0456 t[0] += static_cast<V>(a[6]);
0457 t[1] += static_cast<V>(a[7]);
0458 t[2] += static_cast<V>(b[6]);
0459 t[3] += static_cast<V>(b[7]);
0460 t[0] *= z2;
0461 t[1] *= z2;
0462 t[2] *= z2;
0463 t[3] *= z2;
0464 t[0] += static_cast<V>(a[8]);
0465 t[1] += static_cast<V>(a[9]);
0466 t[2] += static_cast<V>(b[8]);
0467 t[3] += static_cast<V>(b[9]);
0468 t[0] *= z2;
0469 t[2] *= z2;
0470 t[0] += static_cast<V>(a[10]);
0471 t[2] += static_cast<V>(b[10]);
0472 t[1] *= z;
0473 t[3] *= z;
0474 return (t[0] + t[1]) / (t[2] + t[3]);
0475 }
0476 }
0477
0478
0479 }}}}
0480
0481 #endif
0482