123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #pragma once
- #include <Mathematics/Math.h>
- namespace WwiseGTE
- {
- template <typename Real>
- class Exp2Estimate
- {
- public:
-
-
-
- template <int D>
- inline static Real Degree(Real x)
- {
- return Evaluate(degree<D>(), x);
- }
-
-
-
-
-
- template <int D>
- inline static Real DegreeRR(Real x)
- {
- Real p = std::floor(x);
- Real y = x - p;
- Real poly = Degree<D>(y);
- Real result = std::ldexp(poly, (int)p);
- return result;
- }
- private:
-
-
- template <int D> struct degree {};
- inline static Real Evaluate(degree<1>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG1_C1;
- poly = (Real)GTE_C_EXP2_DEG1_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<2>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG2_C2;
- poly = (Real)GTE_C_EXP2_DEG2_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG2_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<3>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG3_C3;
- poly = (Real)GTE_C_EXP2_DEG3_C2 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG3_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG3_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<4>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG4_C4;
- poly = (Real)GTE_C_EXP2_DEG4_C3 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG4_C2 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG4_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG4_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<5>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG5_C5;
- poly = (Real)GTE_C_EXP2_DEG5_C4 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG5_C3 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG5_C2 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG5_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG5_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<6>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG6_C6;
- poly = (Real)GTE_C_EXP2_DEG6_C5 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG6_C4 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG6_C3 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG6_C2 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG6_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG6_C0 + poly * t;
- return poly;
- }
- inline static Real Evaluate(degree<7>, Real t)
- {
- Real poly;
- poly = (Real)GTE_C_EXP2_DEG7_C7;
- poly = (Real)GTE_C_EXP2_DEG7_C6 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C5 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C4 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C3 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C2 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C1 + poly * t;
- poly = (Real)GTE_C_EXP2_DEG7_C0 + poly * t;
- return poly;
- }
- };
- }
|