1 /* Data definitions for sinf, cosf and sincosf. 2 Copyright (c) 2018 Arm Ltd. All rights reserved. 3 4 SPDX-License-Identifier: BSD-3-Clause 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions 8 are met: 9 1. Redistributions of source code must retain the above copyright 10 notice, this list of conditions and the following disclaimer. 11 2. Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in the 13 documentation and/or other materials provided with the distribution. 14 3. The name of the company may not be used to endorse or promote 15 products derived from this software without specific prior written 16 permission. 17 18 THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 28 29 #include "fdlibm.h" 30 #if !__OBSOLETE_MATH_FLOAT 31 32 #include <stdint.h> 33 #include <math.h> 34 #include "math_config.h" 35 #include "sincosf.h" 36 37 /* The constants and polynomials for sine and cosine. The 2nd entry 38 computes -cos (x) rather than cos (x) to get negation for free. */ 39 const sincos_t __sincosf_table[2] = 40 { 41 { 42 { 1.0, -1.0, -1.0, 1.0 }, 43 #if TOINT_INTRINSICS 44 0x1.45F306DC9C883p-1, 45 #else 46 0x1.45F306DC9C883p+23, 47 #endif 48 0x1.921FB54442D18p0, 49 0x1p0, 50 -0x1.ffffffd0c621cp-2, 51 0x1.55553e1068f19p-5, 52 -0x1.6c087e89a359dp-10, 53 0x1.99343027bf8c3p-16, 54 -0x1.555545995a603p-3, 55 0x1.1107605230bc4p-7, 56 -0x1.994eb3774cf24p-13 57 }, 58 { 59 { 1.0, -1.0, -1.0, 1.0 }, 60 #if TOINT_INTRINSICS 61 0x1.45F306DC9C883p-1, 62 #else 63 0x1.45F306DC9C883p+23, 64 #endif 65 0x1.921FB54442D18p0, 66 -0x1p0, 67 0x1.ffffffd0c621cp-2, 68 -0x1.55553e1068f19p-5, 69 0x1.6c087e89a359dp-10, 70 -0x1.99343027bf8c3p-16, 71 -0x1.555545995a603p-3, 72 0x1.1107605230bc4p-7, 73 -0x1.994eb3774cf24p-13 74 } 75 }; 76 77 /* Table with 4/PI to 192 bit precision. To avoid unaligned accesses 78 only 8 new bits are added per entry, making the table 4 times larger. */ 79 const uint32_t __inv_pio4[24] = 80 { 81 0xa2, 0xa2f9, 0xa2f983, 0xa2f9836e, 82 0xf9836e4e, 0x836e4e44, 0x6e4e4415, 0x4e441529, 83 0x441529fc, 0x1529fc27, 0x29fc2757, 0xfc2757d1, 84 0x2757d1f5, 0x57d1f534, 0xd1f534dd, 0xf534ddc0, 85 0x34ddc0db, 0xddc0db62, 0xc0db6295, 0xdb629599, 86 0x6295993c, 0x95993c43, 0x993c4390, 0x3c439041 87 }; 88 89 #endif 90