GteLogEstimate.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 log2(x). The polynomial p(x) of
13 // degree D minimizes the quantity maximum{|log2(x) - p(x)| : x in [1,2]}
14 // over all polynomials of degree D. The natural logarithm is computed
15 // using log(x) = log2(x)/log2(e) = log2(x)*log(2).
16 
17 namespace gte
18 {
19 
20 template <typename Real>
22 {
23 public:
24  // The input constraint is x in [1,2]. For example,
25  // float x; // in [1,2]
26  // float result = LogEstimate<float>::Degree<3>(x);
27  template <int D>
28  inline static Real Degree(Real x);
29 
30  // The input constraint is x > 0. Range reduction is used to generate a
31  // value y in (0,1], call Degree(y), and add the exponent for the power
32  // of two in the binary scientific representation of x. For example,
33  // float x; // x > 0
34  // float result = LogEstimate<float>::DegreeRR<3>(x);
35  template <int D>
36  inline static Real DegreeRR(Real x);
37 };
38 
39 
40 template <typename Real>
41 template <int D>
42 inline Real LogEstimate<Real>::Degree(Real x)
43 {
44  return Log2Estimate<Real>::Degree<D>(x) * (Real)GTE_C_INV_LN_2;
45 }
46 
47 template <typename Real>
48 template <int D>
49 inline Real LogEstimate<Real>::DegreeRR(Real x)
50 {
52 }
53 
54 
55 }
#define GTE_C_INV_LN_2
Definition: GteConstants.h:33
static Real DegreeRR(Real x)
GLint GLenum GLint x
Definition: glcorearb.h:404
static Real Degree(Real x)


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00