| 1 | /* mpc.h -- Include file for mpc. |
| 2 | |
| 3 | Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012, 2016, 2017, 2018, 2020, 2021, 2022 INRIA |
| 4 | |
| 5 | This file is part of GNU MPC. |
| 6 | |
| 7 | GNU MPC is free software; you can redistribute it and/or modify it under |
| 8 | the terms of the GNU Lesser General Public License as published by the |
| 9 | Free Software Foundation; either version 3 of the License, or (at your |
| 10 | option) any later version. |
| 11 | |
| 12 | GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 15 | more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public License |
| 18 | along with this program. If not, see http://www.gnu.org/licenses/ . |
| 19 | */ |
| 20 | |
| 21 | #ifndef __MPC_H |
| 22 | #define __MPC_H |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #include "gmp.h" |
| 26 | #include "mpfr.h" |
| 27 | |
| 28 | /* Define MPC version number */ |
| 29 | #define MPC_VERSION_MAJOR 1 |
| 30 | #define MPC_VERSION_MINOR 3 |
| 31 | #define MPC_VERSION_PATCHLEVEL 1 |
| 32 | #define MPC_VERSION_STRING "1.3.1" |
| 33 | |
| 34 | /* Macros dealing with MPC VERSION */ |
| 35 | #define MPC_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c)) |
| 36 | #define MPC_VERSION \ |
| 37 | MPC_VERSION_NUM(MPC_VERSION_MAJOR,MPC_VERSION_MINOR,MPC_VERSION_PATCHLEVEL) |
| 38 | |
| 39 | /* Check if stdint.h/inttypes.h is included */ |
| 40 | #if defined (INTMAX_C) && defined (UINTMAX_C) |
| 41 | #define _MPC_H_HAVE_INTMAX_T 1 |
| 42 | #endif |
| 43 | |
| 44 | /* Return values */ |
| 45 | |
| 46 | /* Transform negative to 2, positive to 1, leave 0 unchanged. |
| 47 | Warning: since inex is evaluated two times, we should avoid |
| 48 | MPC_INEX(mpc_mul (...), mpc_mul (...)) */ |
| 49 | #define MPC_INEX_POS(inex) (((inex) < 0) ? 2 : ((inex) == 0) ? 0 : 1) |
| 50 | /* Transform 2 to negative, 1 to positive, leave 0 unchanged */ |
| 51 | #define MPC_INEX_NEG(inex) (((inex) == 2) ? -1 : ((inex) == 0) ? 0 : 1) |
| 52 | |
| 53 | /* The global inexact flag is made of (real flag) + 4 * (imaginary flag), where |
| 54 | each of the real and imaginary inexact flag are: |
| 55 | 0 when the result is exact (no rounding error) |
| 56 | 1 when the result is larger than the exact value |
| 57 | 2 when the result is smaller than the exact value */ |
| 58 | #define MPC_INEX(inex_re, inex_im) \ |
| 59 | (MPC_INEX_POS(inex_re) | (MPC_INEX_POS(inex_im) << 2)) |
| 60 | #define MPC_INEX_RE(inex) MPC_INEX_NEG((inex) & 3) |
| 61 | #define MPC_INEX_IM(inex) MPC_INEX_NEG((inex) >> 2) |
| 62 | |
| 63 | /* For functions computing two results, the return value is |
| 64 | inexact1+16*inexact2, which is 0 iif both results are exact. */ |
| 65 | #define MPC_INEX12(inex1, inex2) (inex1 | (inex2 << 4)) |
| 66 | #define MPC_INEX1(inex) (inex & 15) |
| 67 | #define MPC_INEX2(inex) (inex >> 4) |
| 68 | |
| 69 | /* Definition of rounding modes */ |
| 70 | |
| 71 | /* a complex rounding mode is just a pair of two real rounding modes |
| 72 | we reserve four bits for a real rounding mode. */ |
| 73 | typedef int mpc_rnd_t; |
| 74 | |
| 75 | #define MPC_RND(r1,r2) (((int)(r1)) + ((int)(r2) << 4)) |
| 76 | #define MPC_RND_RE(x) ((mpfr_rnd_t)((x) & 0x0F)) |
| 77 | #define MPC_RND_IM(x) ((mpfr_rnd_t)((x) >> 4)) |
| 78 | |
| 79 | #define MPC_RNDNN MPC_RND (MPFR_RNDN,MPFR_RNDN) |
| 80 | #define MPC_RNDNZ MPC_RND (MPFR_RNDN,MPFR_RNDZ) |
| 81 | #define MPC_RNDNU MPC_RND (MPFR_RNDN,MPFR_RNDU) |
| 82 | #define MPC_RNDND MPC_RND (MPFR_RNDN,MPFR_RNDD) |
| 83 | #define MPC_RNDNA MPC_RND (MPFR_RNDN,MPFR_RNDA) |
| 84 | |
| 85 | #define MPC_RNDZN MPC_RND (MPFR_RNDZ,MPFR_RNDN) |
| 86 | #define MPC_RNDZZ MPC_RND (MPFR_RNDZ,MPFR_RNDZ) |
| 87 | #define MPC_RNDZU MPC_RND (MPFR_RNDZ,MPFR_RNDU) |
| 88 | #define MPC_RNDZD MPC_RND (MPFR_RNDZ,MPFR_RNDD) |
| 89 | #define MPC_RNDZA MPC_RND (MPFR_RNDZ,MPFR_RNDA) |
| 90 | |
| 91 | #define MPC_RNDUN MPC_RND (MPFR_RNDU,MPFR_RNDN) |
| 92 | #define MPC_RNDUZ MPC_RND (MPFR_RNDU,MPFR_RNDZ) |
| 93 | #define MPC_RNDUU MPC_RND (MPFR_RNDU,MPFR_RNDU) |
| 94 | #define MPC_RNDUD MPC_RND (MPFR_RNDU,MPFR_RNDD) |
| 95 | #define MPC_RNDUA MPC_RND (MPFR_RNDU,MPFR_RNDA) |
| 96 | |
| 97 | #define MPC_RNDDN MPC_RND (MPFR_RNDD,MPFR_RNDN) |
| 98 | #define MPC_RNDDZ MPC_RND (MPFR_RNDD,MPFR_RNDZ) |
| 99 | #define MPC_RNDDU MPC_RND (MPFR_RNDD,MPFR_RNDU) |
| 100 | #define MPC_RNDDD MPC_RND (MPFR_RNDD,MPFR_RNDD) |
| 101 | #define MPC_RNDDA MPC_RND (MPFR_RNDD,MPFR_RNDA) |
| 102 | |
| 103 | #define MPC_RNDAN MPC_RND (MPFR_RNDA,MPFR_RNDN) |
| 104 | #define MPC_RNDAZ MPC_RND (MPFR_RNDA,MPFR_RNDZ) |
| 105 | #define MPC_RNDAU MPC_RND (MPFR_RNDA,MPFR_RNDU) |
| 106 | #define MPC_RNDAD MPC_RND (MPFR_RNDA,MPFR_RNDD) |
| 107 | #define MPC_RNDAA MPC_RND (MPFR_RNDA,MPFR_RNDA) |
| 108 | |
| 109 | |
| 110 | /* Definitions of types and their semantics */ |
| 111 | |
| 112 | typedef struct { |
| 113 | mpfr_t re; |
| 114 | mpfr_t im; |
| 115 | } |
| 116 | __mpc_struct; |
| 117 | |
| 118 | typedef __mpc_struct mpc_t[1]; |
| 119 | typedef __mpc_struct *mpc_ptr; |
| 120 | typedef const __mpc_struct *mpc_srcptr; |
| 121 | |
| 122 | typedef struct { |
| 123 | int64_t mant; |
| 124 | int64_t exp; |
| 125 | } |
| 126 | __mpcr_struct; |
| 127 | |
| 128 | typedef __mpcr_struct mpcr_t [1]; |
| 129 | typedef __mpcr_struct *mpcr_ptr; |
| 130 | typedef const __mpcr_struct *mpcr_srcptr; |
| 131 | |
| 132 | typedef struct { |
| 133 | mpc_t c; |
| 134 | mpcr_t r; |
| 135 | } |
| 136 | __mpcb_struct; |
| 137 | |
| 138 | typedef __mpcb_struct mpcb_t [1]; |
| 139 | typedef __mpcb_struct *mpcb_ptr; |
| 140 | typedef const __mpcb_struct *mpcb_srcptr; |
| 141 | |
| 142 | /* Support for WINDOWS DLL, see |
| 143 | https://sympa.inria.fr/sympa/arc/mpc-discuss/2011-11/ ; |
| 144 | when building the DLL, export symbols, otherwise behave as GMP */ |
| 145 | #if defined (__MPC_LIBRARY_BUILD) && __GMP_LIBGMP_DLL |
| 146 | #define __MPC_DECLSPEC __GMP_DECLSPEC_EXPORT |
| 147 | #else |
| 148 | #define __MPC_DECLSPEC __GMP_DECLSPEC |
| 149 | #endif |
| 150 | |
| 151 | #if defined (__cplusplus) |
| 152 | extern "C" { |
| 153 | #endif |
| 154 | |
| 155 | __MPC_DECLSPEC int mpc_add (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 156 | __MPC_DECLSPEC int mpc_add_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 157 | __MPC_DECLSPEC int mpc_add_si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); |
| 158 | __MPC_DECLSPEC int mpc_add_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 159 | __MPC_DECLSPEC int mpc_sub (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 160 | __MPC_DECLSPEC int mpc_sub_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 161 | __MPC_DECLSPEC int mpc_fr_sub (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t); |
| 162 | __MPC_DECLSPEC int mpc_sub_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 163 | __MPC_DECLSPEC int mpc_ui_ui_sub (mpc_ptr, unsigned long int, unsigned long int, mpc_srcptr, mpc_rnd_t); |
| 164 | __MPC_DECLSPEC int mpc_mul (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 165 | __MPC_DECLSPEC int mpc_mul_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 166 | __MPC_DECLSPEC int mpc_mul_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 167 | __MPC_DECLSPEC int mpc_mul_si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); |
| 168 | __MPC_DECLSPEC int mpc_mul_i (mpc_ptr, mpc_srcptr, int, mpc_rnd_t); |
| 169 | __MPC_DECLSPEC int mpc_sqr (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 170 | __MPC_DECLSPEC int mpc_div (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 171 | __MPC_DECLSPEC int mpc_pow (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 172 | __MPC_DECLSPEC int mpc_pow_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 173 | __MPC_DECLSPEC int mpc_pow_ld (mpc_ptr, mpc_srcptr, long double, mpc_rnd_t); |
| 174 | __MPC_DECLSPEC int mpc_pow_d (mpc_ptr, mpc_srcptr, double, mpc_rnd_t); |
| 175 | __MPC_DECLSPEC int mpc_pow_si (mpc_ptr, mpc_srcptr, long, mpc_rnd_t); |
| 176 | __MPC_DECLSPEC int mpc_pow_ui (mpc_ptr, mpc_srcptr, unsigned long, mpc_rnd_t); |
| 177 | __MPC_DECLSPEC int mpc_pow_z (mpc_ptr, mpc_srcptr, mpz_srcptr, mpc_rnd_t); |
| 178 | __MPC_DECLSPEC int mpc_div_fr (mpc_ptr, mpc_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 179 | __MPC_DECLSPEC int mpc_fr_div (mpc_ptr, mpfr_srcptr, mpc_srcptr, mpc_rnd_t); |
| 180 | __MPC_DECLSPEC int mpc_div_ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 181 | __MPC_DECLSPEC int mpc_ui_div (mpc_ptr, unsigned long int, mpc_srcptr, mpc_rnd_t); |
| 182 | __MPC_DECLSPEC int mpc_div_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 183 | __MPC_DECLSPEC int mpc_mul_2ui (mpc_ptr, mpc_srcptr, unsigned long int, mpc_rnd_t); |
| 184 | __MPC_DECLSPEC int mpc_div_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); |
| 185 | __MPC_DECLSPEC int mpc_mul_2si (mpc_ptr, mpc_srcptr, long int, mpc_rnd_t); |
| 186 | __MPC_DECLSPEC int mpc_conj (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 187 | __MPC_DECLSPEC int mpc_neg (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 188 | __MPC_DECLSPEC int mpc_sum (mpc_ptr, const mpc_ptr *, unsigned long, mpc_rnd_t); |
| 189 | __MPC_DECLSPEC int mpc_dot (mpc_ptr, const mpc_ptr *, const mpc_ptr *, unsigned long, mpc_rnd_t); |
| 190 | __MPC_DECLSPEC int mpc_norm (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); |
| 191 | __MPC_DECLSPEC int mpc_abs (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); |
| 192 | __MPC_DECLSPEC int mpc_sqrt (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 193 | __MPC_DECLSPEC int mpc_set (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 194 | __MPC_DECLSPEC int mpc_set_d (mpc_ptr, double, mpc_rnd_t); |
| 195 | __MPC_DECLSPEC int mpc_set_d_d (mpc_ptr, double, double, mpc_rnd_t); |
| 196 | __MPC_DECLSPEC int mpc_set_ld (mpc_ptr, long double, mpc_rnd_t); |
| 197 | __MPC_DECLSPEC int mpc_set_ld_ld (mpc_ptr, long double, long double, mpc_rnd_t); |
| 198 | __MPC_DECLSPEC int mpc_set_f (mpc_ptr, mpf_srcptr, mpc_rnd_t); |
| 199 | __MPC_DECLSPEC int mpc_set_f_f (mpc_ptr, mpf_srcptr, mpf_srcptr, mpc_rnd_t); |
| 200 | __MPC_DECLSPEC int mpc_set_fr (mpc_ptr, mpfr_srcptr, mpc_rnd_t); |
| 201 | __MPC_DECLSPEC int mpc_set_fr_fr (mpc_ptr, mpfr_srcptr, mpfr_srcptr, mpc_rnd_t); |
| 202 | __MPC_DECLSPEC int mpc_set_q (mpc_ptr, mpq_srcptr, mpc_rnd_t); |
| 203 | __MPC_DECLSPEC int mpc_set_q_q (mpc_ptr, mpq_srcptr, mpq_srcptr, mpc_rnd_t); |
| 204 | __MPC_DECLSPEC int mpc_set_si (mpc_ptr, long int, mpc_rnd_t); |
| 205 | __MPC_DECLSPEC int mpc_set_si_si (mpc_ptr, long int, long int, mpc_rnd_t); |
| 206 | __MPC_DECLSPEC int mpc_set_ui (mpc_ptr, unsigned long int, mpc_rnd_t); |
| 207 | __MPC_DECLSPEC int mpc_set_ui_ui (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t); |
| 208 | __MPC_DECLSPEC int mpc_set_z (mpc_ptr, mpz_srcptr, mpc_rnd_t); |
| 209 | __MPC_DECLSPEC int mpc_set_z_z (mpc_ptr, mpz_srcptr, mpz_srcptr, mpc_rnd_t); |
| 210 | __MPC_DECLSPEC void mpc_swap (mpc_ptr, mpc_ptr); |
| 211 | __MPC_DECLSPEC int mpc_fma (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 212 | |
| 213 | __MPC_DECLSPEC void mpc_set_nan (mpc_ptr); |
| 214 | |
| 215 | __MPC_DECLSPEC int mpc_real (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); |
| 216 | __MPC_DECLSPEC int mpc_imag (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); |
| 217 | __MPC_DECLSPEC int mpc_arg (mpfr_ptr, mpc_srcptr, mpfr_rnd_t); |
| 218 | __MPC_DECLSPEC int mpc_proj (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 219 | __MPC_DECLSPEC int mpc_cmp (mpc_srcptr, mpc_srcptr); |
| 220 | __MPC_DECLSPEC int mpc_cmp_si_si (mpc_srcptr, long int, long int); |
| 221 | __MPC_DECLSPEC int mpc_cmp_abs (mpc_srcptr, mpc_srcptr); |
| 222 | __MPC_DECLSPEC int mpc_exp (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 223 | __MPC_DECLSPEC int mpc_log (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 224 | __MPC_DECLSPEC int mpc_log10 (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 225 | __MPC_DECLSPEC int mpc_agm (mpc_ptr, mpc_srcptr, mpc_srcptr, mpc_rnd_t); |
| 226 | __MPC_DECLSPEC int mpc_sin (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 227 | __MPC_DECLSPEC int mpc_cos (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 228 | __MPC_DECLSPEC int mpc_sin_cos (mpc_ptr, mpc_ptr, mpc_srcptr, mpc_rnd_t, mpc_rnd_t); |
| 229 | __MPC_DECLSPEC int mpc_tan (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 230 | __MPC_DECLSPEC int mpc_sinh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 231 | __MPC_DECLSPEC int mpc_cosh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 232 | __MPC_DECLSPEC int mpc_tanh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 233 | __MPC_DECLSPEC int mpc_asin (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 234 | __MPC_DECLSPEC int mpc_acos (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 235 | __MPC_DECLSPEC int mpc_atan (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 236 | __MPC_DECLSPEC int mpc_asinh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 237 | __MPC_DECLSPEC int mpc_acosh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 238 | __MPC_DECLSPEC int mpc_atanh (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 239 | __MPC_DECLSPEC int mpc_rootofunity (mpc_ptr, unsigned long int, unsigned long int, mpc_rnd_t); |
| 240 | __MPC_DECLSPEC void mpc_clear (mpc_ptr); |
| 241 | __MPC_DECLSPEC int mpc_urandom (mpc_ptr, gmp_randstate_t); |
| 242 | __MPC_DECLSPEC void mpc_init2 (mpc_ptr, mpfr_prec_t); |
| 243 | __MPC_DECLSPEC void mpc_init3 (mpc_ptr, mpfr_prec_t, mpfr_prec_t); |
| 244 | __MPC_DECLSPEC mpfr_prec_t mpc_get_prec (mpc_srcptr x); |
| 245 | __MPC_DECLSPEC void mpc_get_prec2 (mpfr_prec_t *pr, mpfr_prec_t *pi, mpc_srcptr x); |
| 246 | __MPC_DECLSPEC void mpc_set_prec (mpc_ptr, mpfr_prec_t); |
| 247 | __MPC_DECLSPEC const char * mpc_get_version (void); |
| 248 | |
| 249 | __MPC_DECLSPEC int mpc_strtoc (mpc_ptr, const char *, char **, int, mpc_rnd_t); |
| 250 | __MPC_DECLSPEC int mpc_set_str (mpc_ptr, const char *, int, mpc_rnd_t); |
| 251 | __MPC_DECLSPEC char * mpc_get_str (int, size_t, mpc_srcptr, mpc_rnd_t); |
| 252 | __MPC_DECLSPEC void mpc_free_str (char *); |
| 253 | |
| 254 | /* declare certain functions only if appropriate headers have been included */ |
| 255 | #ifdef _MPC_H_HAVE_INTMAX_T |
| 256 | __MPC_DECLSPEC int mpc_set_sj (mpc_ptr, intmax_t, mpc_rnd_t); |
| 257 | __MPC_DECLSPEC int mpc_set_uj (mpc_ptr, uintmax_t, mpc_rnd_t); |
| 258 | __MPC_DECLSPEC int mpc_set_sj_sj (mpc_ptr, intmax_t, intmax_t, mpc_rnd_t); |
| 259 | __MPC_DECLSPEC int mpc_set_uj_uj (mpc_ptr, uintmax_t, uintmax_t, mpc_rnd_t); |
| 260 | #endif |
| 261 | |
| 262 | #ifdef _Complex_I |
| 263 | __MPC_DECLSPEC int mpc_set_dc (mpc_ptr, double _Complex, mpc_rnd_t); |
| 264 | __MPC_DECLSPEC int mpc_set_ldc (mpc_ptr, long double _Complex, mpc_rnd_t); |
| 265 | __MPC_DECLSPEC double _Complex mpc_get_dc (mpc_srcptr, mpc_rnd_t); |
| 266 | __MPC_DECLSPEC long double _Complex mpc_get_ldc (mpc_srcptr, mpc_rnd_t); |
| 267 | #endif |
| 268 | |
| 269 | #ifdef _GMP_H_HAVE_FILE |
| 270 | __MPC_DECLSPEC int mpc_inp_str (mpc_ptr, FILE *, size_t *, int, mpc_rnd_t); |
| 271 | __MPC_DECLSPEC size_t mpc_out_str (FILE *, int, size_t, mpc_srcptr, mpc_rnd_t); |
| 272 | __MPC_DECLSPEC void mpcb_out_str (FILE *f, mpcb_srcptr); |
| 273 | __MPC_DECLSPEC void mpcr_out_str (FILE *f, mpcr_srcptr r); |
| 274 | #endif |
| 275 | |
| 276 | __MPC_DECLSPEC int mpcr_inf_p (mpcr_srcptr r); |
| 277 | __MPC_DECLSPEC int mpcr_zero_p (mpcr_srcptr r); |
| 278 | __MPC_DECLSPEC int mpcr_lt_half_p (mpcr_srcptr r); |
| 279 | __MPC_DECLSPEC int mpcr_cmp (mpcr_srcptr r, mpcr_srcptr s); |
| 280 | __MPC_DECLSPEC void mpcr_set_inf (mpcr_ptr r); |
| 281 | __MPC_DECLSPEC void mpcr_set_zero (mpcr_ptr r); |
| 282 | __MPC_DECLSPEC void mpcr_set_one (mpcr_ptr r); |
| 283 | __MPC_DECLSPEC void mpcr_set (mpcr_ptr r, mpcr_srcptr s); |
| 284 | __MPC_DECLSPEC void mpcr_set_ui64_2si64 (mpcr_ptr r, uint64_t mant, |
| 285 | int64_t exp); |
| 286 | __MPC_DECLSPEC void mpcr_max (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); |
| 287 | __MPC_DECLSPEC int64_t mpcr_get_exp (mpcr_srcptr r); |
| 288 | __MPC_DECLSPEC void mpcr_mul (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); |
| 289 | __MPC_DECLSPEC void mpcr_mul_2ui (mpcr_ptr r, mpcr_srcptr s, |
| 290 | unsigned long int e); |
| 291 | __MPC_DECLSPEC void mpcr_sqr (mpcr_ptr r, mpcr_srcptr s); |
| 292 | __MPC_DECLSPEC void mpcr_add (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); |
| 293 | __MPC_DECLSPEC void mpcr_sub (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); |
| 294 | __MPC_DECLSPEC void mpcr_sub_rnd (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t, |
| 295 | mpfr_rnd_t rnd); |
| 296 | __MPC_DECLSPEC void mpcr_div (mpcr_ptr r, mpcr_srcptr s, mpcr_srcptr t); |
| 297 | __MPC_DECLSPEC void mpcr_div_2ui (mpcr_ptr r, mpcr_srcptr s, |
| 298 | unsigned long int e); |
| 299 | __MPC_DECLSPEC int64_t sqrt_int64 (int64_t n); |
| 300 | __MPC_DECLSPEC void mpcr_sqrt (mpcr_ptr r, mpcr_srcptr s); |
| 301 | __MPC_DECLSPEC void mpcr_add_rounding_error (mpcr_ptr r, mpfr_prec_t p, |
| 302 | mpfr_rnd_t rnd); |
| 303 | __MPC_DECLSPEC void mpcr_c_abs_rnd (mpcr_ptr r, mpc_srcptr z, |
| 304 | mpfr_rnd_t rnd); |
| 305 | |
| 306 | __MPC_DECLSPEC void mpcb_init (mpcb_ptr); |
| 307 | __MPC_DECLSPEC void mpcb_clear (mpcb_ptr); |
| 308 | __MPC_DECLSPEC mpfr_prec_t mpcb_get_prec (mpcb_srcptr); |
| 309 | __MPC_DECLSPEC void mpcb_set_prec (mpcb_ptr, mpfr_prec_t); |
| 310 | __MPC_DECLSPEC void mpcb_set (mpcb_ptr, mpcb_srcptr); |
| 311 | __MPC_DECLSPEC void mpcb_set_inf (mpcb_ptr); |
| 312 | __MPC_DECLSPEC void mpcb_set_c (mpcb_ptr, mpc_srcptr, mpfr_prec_t, |
| 313 | unsigned long int, unsigned long int); |
| 314 | __MPC_DECLSPEC void mpcb_set_ui_ui (mpcb_ptr, unsigned long int, |
| 315 | unsigned long int, mpfr_prec_t); |
| 316 | __MPC_DECLSPEC void mpcb_neg (mpcb_ptr, mpcb_srcptr); |
| 317 | __MPC_DECLSPEC void mpcb_mul (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); |
| 318 | __MPC_DECLSPEC void mpcb_sqr (mpcb_ptr, mpcb_srcptr); |
| 319 | __MPC_DECLSPEC void mpcb_pow_ui (mpcb_ptr, mpcb_srcptr, unsigned long int); |
| 320 | __MPC_DECLSPEC void mpcb_add (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); |
| 321 | __MPC_DECLSPEC void mpcb_sqrt (mpcb_ptr, mpcb_srcptr); |
| 322 | __MPC_DECLSPEC void mpcb_div (mpcb_ptr, mpcb_srcptr, mpcb_srcptr); |
| 323 | __MPC_DECLSPEC void mpcb_div_2ui (mpcb_ptr, mpcb_srcptr, unsigned long int); |
| 324 | __MPC_DECLSPEC int mpcb_can_round (mpcb_srcptr, mpfr_prec_t, mpfr_prec_t, |
| 325 | mpc_rnd_t); |
| 326 | __MPC_DECLSPEC int mpcb_round (mpc_ptr, mpcb_srcptr, mpc_rnd_t); |
| 327 | __MPC_DECLSPEC int mpc_eta_fund (mpc_ptr, mpc_srcptr, mpc_rnd_t); |
| 328 | |
| 329 | #if defined (__cplusplus) |
| 330 | } |
| 331 | #endif |
| 332 | |
| 333 | #define mpc_realref(x) ((x)->re) |
| 334 | #define mpc_imagref(x) ((x)->im) |
| 335 | |
| 336 | #define mpc_cmp_si(x, y) \ |
| 337 | ( mpc_cmp_si_si ((x), (y), 0l) ) |
| 338 | #define mpc_ui_sub(x, y, z, r) mpc_ui_ui_sub (x, y, 0ul, z, r) |
| 339 | |
| 340 | /* |
| 341 | Define a fake mpfr_set_fr so that, for instance, mpc_set_fr_z would |
| 342 | be defined as follows: |
| 343 | mpc_set_fr_z (mpc_t rop, mpfr_t x, mpz_t y, mpc_rnd_t rnd) |
| 344 | MPC_SET_X_Y (fr, z, rop, x, y, rnd) |
| 345 | */ |
| 346 | #ifndef mpfr_set_fr |
| 347 | #define mpfr_set_fr mpfr_set |
| 348 | #endif |
| 349 | #define MPC_SET_X_Y(real_t, imag_t, z, real_value, imag_value, rnd) \ |
| 350 | { \ |
| 351 | int _inex_re, _inex_im; \ |
| 352 | _inex_re = (mpfr_set_ ## real_t) (mpc_realref (z), (real_value), MPC_RND_RE (rnd)); \ |
| 353 | _inex_im = (mpfr_set_ ## imag_t) (mpc_imagref (z), (imag_value), MPC_RND_IM (rnd)); \ |
| 354 | return MPC_INEX (_inex_re, _inex_im); \ |
| 355 | } |
| 356 | |
| 357 | #endif /* ifndef __MPC_H */ |
| 358 | |