1 /* 2 * Copyright (C) 2004-2011 David Defour, Catherine Daramy-Loirat, 3 * Florent de Dinechin, Matthieu Gallet, Nicolas Gast, Christoph Quirin Lauter, 4 * and Jean-Michel Muller 5 * 6 * Author : David Defour, Catherine Daramy, Florent de Dinechin, Christoph Lauter 7 * Contact: David.Defour@ens-lyon.fr, catherine_daramy@ens-lyon.fr 8 * 9 * This file is part of crlibm, the correctly rounded mathematical library, 10 * which has been developed by the Arénaire project at École normale supérieure 11 * de Lyon. 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or (at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 26 */ 27 28 #ifndef CRLIBM_H 29 #define CRLIBM_H 30 31 #if defined (__cplusplus) 32 extern "C" { 33 #endif 34 35 36 /* An init function which sets FPU flags when needed (mostly on Intel 37 architectures with default double extended) */ 38 extern unsigned long long crlibm_init(void); 39 40 /* An exit function which restores FPU flags when needed (mostly on Intel 41 architectures with default double extended) */ 42 extern void crlibm_exit(unsigned long long); 43 44 45 /* Finished functions */ 46 /* These functions are computed in two steps and have an average 47 execution time comparable to that of a standard libm 48 */ 49 50 /* exponential */ 51 extern double exp_rn(double); /* to nearest */ 52 extern double exp_rd(double); /* toward -inf */ 53 extern double exp_ru(double); /* toward +inf */ 54 #define exp_rz exp_rd /* toward zero */ 55 56 /* logarithm */ 57 extern double log_rn(double); /* to nearest */ 58 extern double log_rd(double); /* toward -inf */ 59 extern double log_ru(double); /* toward +inf */ 60 extern double log_rz(double); /* toward zero */ 61 62 /* cosine */ 63 extern double cos_rn(double); /* to nearest */ 64 extern double cos_rd(double); /* toward -inf */ 65 extern double cos_ru(double); /* toward +inf */ 66 extern double cos_rz(double); /* toward zero */ 67 68 /* sine */ 69 extern double sin_rn(double); /* to nearest */ 70 extern double sin_rd(double); /* toward -inf */ 71 extern double sin_ru(double); /* toward +inf */ 72 extern double sin_rz(double); /* toward zero */ 73 74 /* tangent */ 75 extern double tan_rn(double); /* to nearest */ 76 extern double tan_rd(double); /* toward -inf */ 77 extern double tan_ru(double); /* toward +inf */ 78 extern double tan_rz(double); /* toward zero */ 79 80 /* cosine of pi times x */ 81 extern double cospi_rn(double); /* to nearest */ 82 extern double cospi_rd(double); /* toward -inf */ 83 extern double cospi_ru(double); /* toward +inf */ 84 extern double cospi_rz(double); /* toward zero */ 85 86 /* sine of pi times x */ 87 extern double sinpi_rn(double); /* to nearest */ 88 extern double sinpi_rd(double); /* toward -inf */ 89 extern double sinpi_ru(double); /* toward +inf */ 90 extern double sinpi_rz(double); /* toward zero */ 91 92 /* tangent of pi times x */ 93 extern double tanpi_rn(double); /* to nearest */ 94 extern double tanpi_rd(double); /* toward -inf */ 95 extern double tanpi_ru(double); /* toward +inf */ 96 extern double tanpi_rz(double); /* toward zero */ 97 98 99 100 101 /* /\* cotangent *\/ */ 102 /* extern double cotan_rn(double); /\* to nearest *\/ */ 103 /* extern double cotan_rd(double); /\* toward -inf *\/ */ 104 /* extern double cotan_ru(double); /\* toward +inf *\/ */ 105 /* extern double cotan_rz(double); /\* toward zero *\/ */ 106 107 /* arctangent */ 108 extern double atan_rn(double); /* to nearest */ 109 extern double atan_rd(double); /* toward -inf */ 110 extern double atan_ru(double); /* toward +inf */ 111 extern double atan_rz(double); /* toward zero */ 112 113 /* arctangentPi */ 114 extern double atanpi_rn(double); /* to nearest */ 115 extern double atanpi_rd(double); /* toward -inf */ 116 extern double atanpi_ru(double); /* toward +inf */ 117 extern double atanpi_rz(double); /* toward zero */ 118 119 /* hyperbolic cosine*/ 120 extern double cosh_rn(double); /* to nearest */ 121 extern double cosh_rd(double); /* toward -inf */ 122 extern double cosh_ru(double); /* toward +inf */ 123 extern double cosh_rz(double); /* toward zero */ 124 125 /* hyperbolic sine */ 126 extern double sinh_rn(double); /* to nearest */ 127 extern double sinh_rd(double); /* toward -inf */ 128 extern double sinh_ru(double); /* toward +inf */ 129 extern double sinh_rz(double); /* toward zero */ 130 131 132 /* base 2 logarithm */ 133 extern double log2_rn(double); /* to nearest */ 134 extern double log2_rd(double); /* toward -inf */ 135 extern double log2_ru(double); /* toward +inf */ 136 extern double log2_rz(double); /* towards zero */ 137 138 /* base 10 logarithm */ 139 extern double log10_rn(double); /* to nearest */ 140 extern double log10_rd(double); /* toward -inf */ 141 extern double log10_ru(double); /* toward +inf */ 142 extern double log10_rz(double); /* towards zero */ 143 144 /* arcsine */ 145 extern double asin_rn(double); /* to nearest */ 146 extern double asin_rd(double); /* toward -inf */ 147 extern double asin_ru(double); /* toward +inf */ 148 extern double asin_rz(double); /* toward zero */ 149 150 /* arccosine */ 151 extern double acos_rn(double); /* to nearest */ 152 extern double acos_rd(double); /* toward -inf */ 153 extern double acos_ru(double); /* toward +inf */ 154 #define acos_rz acos_rd /* toward zero */ 155 156 /* arcsine/PI */ 157 extern double asinpi_rn(double); /* to nearest */ 158 extern double asinpi_rd(double); /* toward -inf */ 159 extern double asinpi_ru(double); /* toward +inf */ 160 extern double asinpi_rz(double); /* toward zero */ 161 162 /* arccosine/PI */ 163 extern double acospi_rn(double); /* to nearest */ 164 extern double acospi_rd(double); /* toward -inf */ 165 extern double acospi_ru(double); /* toward +inf */ 166 #define acospi_rz acospi_rd /* toward zero */ 167 168 /* expm1 = e^x -1 */ 169 extern double expm1_rn(double); /* to nearest */ 170 extern double expm1_rd(double); /* toward -inf */ 171 extern double expm1_ru(double); /* toward +inf */ 172 extern double expm1_rz(double); /* toward zero */ 173 174 /* log1p = log(1 + x) */ 175 extern double log1p_rn(double); /* to nearest */ 176 extern double log1p_rd(double); /* toward -inf */ 177 extern double log1p_ru(double); /* toward +inf */ 178 extern double log1p_rz(double); /* toward zero */ 179 180 181 /* Unfinished functions */ 182 /* These functions provide correct rounding but are very slow 183 (typically 100 times slower that the standard libm) */ 184 185 extern double exp2_rn(double); /* to nearest */ 186 extern double exp2_rd(double); /* toward -inf */ 187 extern double exp2_ru(double); /* toward +inf */ 188 189 /* pow */ 190 /* ATTENTION: THIS FUNCTION IS UNDER DEVELOPMENT 191 AND CURRENTLY NOT PROVEN CORRECTLY ROUNDED FOR ALL CASES 192 193 See the documentation 194 195 */ 196 extern double pow_rn(double, double); 197 198 199 /* fi_lib-compatible interval functions (EXPERIMENTAL) */ 200 201 #ifdef BUILD_INTERVAL_FUNCTIONS 202 #include "interval.h" 203 interval j_log(interval x); 204 interval j_exp(interval x); 205 #endif /* BUILD_INTERVAL_FUNCTIONS */ 206 207 #if defined (__cplusplus) 208 209 } 210 #endif 211 212 #endif /* ifdef CRLIBM_H*/ 213