/ src / optmized / expm1f_data.h
expm1f_data.h
 1  /*
 2   * Copyright (C) 2008-2020 Advanced Micro Devices, Inc. All rights reserved.
 3   *
 4   * Redistribution and use in source and binary forms, with or without modification,
 5   * are permitted provided that the following conditions are met:
 6   * 1. Redistributions of source code must retain the above copyright notice,
 7   *    this list of conditions and the following disclaimer.
 8   * 2. Redistributions in binary form must reproduce the above copyright notice,
 9   *    this list of conditions and the following disclaimer in the documentation
10   *    and/or other materials provided with the distribution.
11   * 3. Neither the name of the copyright holder nor the names of its contributors
12   *    may be used to endorse or promote products derived from this software without
13   *    specific prior written permission.
14   *
15   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18   * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
19   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20   * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
21   * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24   * POSSIBILITY OF SUCH DAMAGE.
25   *
26   */
27  
28  #ifndef __LIBM_OPTIMIZED_SINGLE_EXPM1F_H__
29  #define __LIBM_OPTIMIZED_SINGLE_EXPM1F_H__
30  
31  #include <stdint.h>
32  
33  #include <libm_macros.h>
34  #include <libm/types.h>
35  
36  #include <libm/typehelper.h>
37  #include <libm/compiler.h>
38  
39  #define EXPM1F_N 6
40  
41  #if EXPM1F_N == 6
42  extern const uint64_t __two_to_jby64[64];
43  #elif EXPM1F_N == 7
44  extern const double __two_to_jby128[128];
45  #endif
46  
47  
48  static const struct {
49      double _64_by_ln2, ln2_by_64;
50      double Huge;
51  #if 1
52      struct {                            /* Min/Max values that can be passed */
53          float min, max;
54      } x;
55      struct {                            /* Around 1 threshold to take different path */
56          double hi, lo;
57      } threshold;
58  #endif
59      float poly[5];
60      /* The pre-computed double-precision table */
61      //double tab[1 << EXPM1F_N];
62      const uint64_t *tab;
63  } expm1f_v2_data =  {
64      .Huge       = 0x1.8p+52,	/* 2^52 * (1.0 + 0.5) */
65  #if 1
66      .x          = {
67          .min = -0x1.154244p+4f,	/* ~= -17.32867 */
68          .max =  0x1.633332p+6f,	/* ~=  88.79999 */
69      },
70      .threshold  = {
71          .hi = 0x3E647FBF,	/* log(1 + 1/4) =  0.223144 */
72          .lo = 0xBE934B11	/* log(1 - 1/4) = -0.287682 */
73      },
74  #endif
75      ._64_by_ln2 = 0x1.71547652b82fep+6,
76      .ln2_by_64  = 0x1.62e42fefa39efp-7,
77      .poly       = {
78          0x1.555554p-3f,			/* 0x3E2AAAAA */
79          0x1.55554p-5f,			/* 0x3D2AAAA0 */
80          0x1.1113fep-7f,			/* 0x3C0889FF */
81          0x1.6c9bcap-10f,		/* 0x3AB64DE5 */
82          0x1.95664ep-13f,		/* 0x394AB327 */
83      },
84  
85      .tab = __two_to_jby64,
86  };
87  
88  #endif 					/* LIBM_OPTIMIZED_SINGLE_EXPM1F_H */