GteExpEstimate.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 
12 // Minimax polynomial approximations to 2^x. The polynomial p(x) of
13 // degree D minimizes the quantity maximum{|2^x - p(x)| : x in [0,1]}
14 // over all polynomials of degree D. The natural exponential is
15 // computed using exp(x) = 2^{x log(2)}, where log(2) is the natural
16 // logarithm of 2.
17 
18 namespace gte
19 {
20 
21 template <typename Real>
23 {
24 public:
25  // The input constraint is x in [0,1]. For example,
26  // float x; // in [0,1]
27  // float result = ExpEstimate<float>::Degree<3>(x);
28  template <int D>
29  inline static Real Degree(Real x);
30 
31  // The input x can be any real number. Range reduction is used to
32  // generate a value y in [0,1], call Degree(y), and combine the output
33  // with the proper exponent to obtain the approximation. For example,
34  // float x; // x >= 0
35  // float result = ExpEstimate<float>::DegreeRR<3>(x);
36  template <int D>
37  inline static Real DegreeRR(Real x);
38 };
39 
40 
41 template <typename Real>
42 template <int D>
43 inline Real ExpEstimate<Real>::Degree(Real x)
44 {
45  return Exp2Estimate<Real>::Degree<D>((Real)GTE_C_LN_2 * x);
46 }
47 
48 template <typename Real>
49 template <int D>
50 inline Real ExpEstimate<Real>::DegreeRR(Real x)
51 {
52  return Exp2Estimate<Real>::DegreeRR<D>((Real)GTE_C_LN_2 * x);
53 }
54 
55 
56 }
GLint GLenum GLint x
Definition: glcorearb.h:404
#define GTE_C_LN_2
Definition: GteConstants.h:32
static Real DegreeRR(Real x)
static Real Degree(Real x)


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59