File indexing completed on 2025-01-18 09:40:39
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_MATH_TOOLS_RAT_EVAL_9_HPP
0010 #define BOOST_MATH_TOOLS_RAT_EVAL_9_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
0315 }}}}
0316
0317 #endif
0318