mathX_c.h (3294B)
1 /* Copyright (C) 2014-2019, 2021, 2023, 2025 Vincent Forest (vaplv@free.fr) 2 * 3 * The RSIMD library is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published 5 * by the Free Software Foundation, either version 3 of the License, or 6 * (at your option) any later version. 7 * 8 * The RSIMD library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */ 15 16 #include "rsimd.h" 17 18 #ifdef COMPILER_GCC 19 #pragma GCC diagnostic push 20 #pragma GCC diagnostic ignored "-Wignored-qualifiers" 21 #endif 22 23 #include <sleef.h> 24 25 #ifdef COMPILER_GCC 26 #pragma GCC diagnostic pop 27 #endif 28 29 RSIMD_vXf_T__ 30 RSIMD_vXf__(copysign)(const RSIMD_vXf_T__ x, const RSIMD_vXf_T__ y) 31 { 32 return RSIMD_Sleef__(copysignf)(x, y); 33 } 34 35 RSIMD_vXf_T__ 36 RSIMD_vXf__(floor)(const RSIMD_vXf_T__ x) 37 { 38 return RSIMD_Sleef__(floorf)(x); 39 } 40 41 RSIMD_vXf_T__ 42 RSIMD_vXf__(pow)(const RSIMD_vXf_T__ x, const RSIMD_vXf_T__ y) 43 { 44 return RSIMD_Sleef_ULP__(powf, u10)(x, y); 45 } 46 47 /******************************************************************************* 48 * Exponentatial functions 49 ******************************************************************************/ 50 RSIMD_vXf_T__ 51 RSIMD_vXf__(exp2)(const RSIMD_vXf_T__ x) 52 { 53 return RSIMD_Sleef_ULP__(exp2f, u10)(x); 54 } 55 56 RSIMD_vXf_T__ 57 RSIMD_vXf__(exp)(const RSIMD_vXf_T__ x) 58 { 59 return RSIMD_Sleef_ULP__(expf, u10)(x); 60 } 61 62 RSIMD_vXf_T__ 63 RSIMD_vXf__(exp10)(const RSIMD_vXf_T__ x) 64 { 65 return RSIMD_Sleef_ULP__(exp10f, u10)(x); 66 } 67 68 /******************************************************************************* 69 * Log functions 70 ******************************************************************************/ 71 RSIMD_vXf_T__ 72 RSIMD_vXf__(log2)(const RSIMD_vXf_T__ x) 73 { 74 return RSIMD_Sleef_ULP__(log2f, u10)(x); 75 } 76 77 RSIMD_vXf_T__ 78 RSIMD_vXf__(log)(const RSIMD_vXf_T__ x) 79 { 80 return RSIMD_Sleef_ULP__(logf, u10)(x); 81 } 82 83 RSIMD_vXf_T__ 84 RSIMD_vXf__(log10)(const RSIMD_vXf_T__ x) 85 { 86 return RSIMD_Sleef_ULP__(log10f, u10)(x); 87 } 88 89 /******************************************************************************* 90 * Trigonometric functions 91 ******************************************************************************/ 92 RSIMD_vXf_T__ 93 RSIMD_vXf__(sin)(const RSIMD_vXf_T__ v) 94 { 95 return RSIMD_Sleef_ULP__(sinf, u10)(v); 96 } 97 98 RSIMD_vXf_T__ 99 RSIMD_vXf__(asin)(const RSIMD_vXf_T__ v) 100 { 101 return RSIMD_Sleef_ULP__(asinf, u10)(v); 102 } 103 104 RSIMD_vXf_T__ 105 RSIMD_vXf__(cos)(const RSIMD_vXf_T__ v) 106 { 107 return RSIMD_Sleef_ULP__(cosf, u10)(v); 108 } 109 110 RSIMD_vXf_T__ 111 RSIMD_vXf__(acos)(const RSIMD_vXf_T__ v) 112 { 113 return RSIMD_Sleef_ULP__(acosf, u10)(v); 114 } 115 116 void 117 RSIMD_vXf__(sincos) 118 (const RSIMD_vXf_T__ v, RSIMD_vXf_T__* RESTRICT s, RSIMD_vXf_T__* RESTRICT c) 119 { 120 const RSIMD_Sleef_vecf__(2) r = RSIMD_Sleef_ULP__(sincosf, u10)(v); 121 *s = r.x; 122 *c = r.y; 123 } 124 125 RSIMD_vXf_T__ 126 RSIMD_vXf__(tan)(const RSIMD_vXf_T__ v) 127 { 128 return RSIMD_Sleef_ULP__(tanf, u10)(v); 129 } 130 131 RSIMD_vXf_T__ 132 RSIMD_vXf__(atan)(const RSIMD_vXf_T__ v) 133 { 134 return RSIMD_Sleef_ULP__(atanf, u10)(v); 135 }