- Timestamp:
- May 2, 2012, 1:36:49 PM (14 years ago)
- Children:
- 6fee21
- Parents:
- 728149
- File:
-
- 1 edited
-
src/base/polynomial.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/base/polynomial.hpp
r728149 r759a6a 42 42 vmg_float operator()(const vmg_float& val) const 43 43 { 44 vmg_float result = coeff.back(); 45 for (int i=coeff.size()-2; i>=0; --i) 46 result = coeff[i] + result * val; 47 return result; 44 switch (coeff.size()) 45 { 46 case 1: 47 return coeff[0]; 48 case 2: 49 return coeff[1] * val + coeff[0]; 50 case 3: 51 return (coeff[2] * val + coeff[1]) * val + coeff[0]; 52 case 4: 53 return ((coeff[3] * val + coeff[2]) * val + coeff[1]) * val + coeff[0]; 54 case 5: 55 return (((coeff[4] * val + coeff[3]) * val + coeff[2]) * val + coeff[1]) * val + coeff[0]; 56 case 6: 57 return ((((coeff[5] * val + coeff[4]) * val + coeff[3]) * val + coeff[2]) * val + coeff[1]) * val + coeff[0]; 58 case 7: 59 return (((((coeff[6]*val+coeff[5])*val+coeff[4])*val+coeff[3])*val+coeff[2])*val+coeff[1])*val+coeff[0]; 60 case 8: 61 return ((((((coeff[7]*val+coeff[6])*val+coeff[5])*val+coeff[4])*val+coeff[3])*val+coeff[2])*val+coeff[1])*val+coeff[0]; 62 default: 63 vmg_float result = coeff.back(); 64 for (int i=coeff.size()-2; i>=0; --i) 65 result = coeff[i] + result * val; 66 return result; 67 } 68 48 69 } 49 70
Note:
See TracChangeset
for help on using the changeset viewer.
