1 /*
2 
3 cm_arith.h - macros for arithmetic kernel
4 
5 Copyright (C) 2015, 2016 Andreas Enge
6 
7 This file is part of CM.
8 
9 CM is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the license, or (at your
12 option) any later version.
13 
14 CM is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License along
20 with CM; see the file COPYING. If not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23 
24 #ifndef __CM_ARITH_H
25 #define __CM_ARITH_H
26 
27 #include <mpc.h>
28 
29 #define ctype              mpc_t
30 #define cptr               mpc_ptr
31 #define csrcptr            mpc_srcptr
32 #define cinit(z,n)         mpc_init2((z),(n))
33 #define cclear(z)          mpc_clear((z))
34 #define cset_prec(z,n)     mpc_set_prec((z),(n))
35 #define cget_prec(z)       mpc_get_prec((z))
36 #define crealref(z)        mpc_realref((z))
37 #define cimagref(z)        mpc_imagref((z))
38 #define cset(z,x)          mpc_set((z),(x),MPC_RNDNN)
39 #define cset_ui(z,x)       mpc_set_ui((z),(x),MPC_RNDNN)
40 #define cset_si(z,x)       mpc_set_si((z),(x),MPC_RNDNN)
41 #define cset_ui_ui(z,x,y)  mpc_set_ui_ui((z),(x),(y),MPC_RNDNN)
42 #define cneg(z,x)          mpc_neg((z),(x),MPC_RNDNN)
43 #define cconj(z,x)         mpc_conj((z),(x),MPC_RNDNN)
44 #define cadd(z,x,y)        mpc_add((z),(x),(y),MPC_RNDNN)
45 #define cadd_ui(z,x,y)     mpc_add_ui((z),(x),(y),MPC_RNDNN)
46 #define cadd_si(z,x,y)     mpc_add_si((z),(x),(y),MPC_RNDNN)
47 #define csub(z,x,y)        mpc_sub((z),(x),(y),MPC_RNDNN)
48 #define cmul(z,x,y)        mpc_mul((z),(x),(y),MPC_RNDNN)
49 #define cmul_ui(z,x,y)     mpc_mul_ui((z),(x),(y),MPC_RNDNN)
50 #define cmul_si(z,x,y)     mpc_mul_si((z),(x),(y),MPC_RNDNN)
51 #define cmul_fr(z,x,y)     mpc_mul_fr((z),(x),(y),MPC_RNDNN)
52 #define csqr(z,x)          mpc_sqr((z),(x),MPC_RNDNN)
53 #define cdiv(z,x,y)        mpc_div((z),(x),(y),MPC_RNDNN)
54 #define cdiv_ui(z,x,y)     mpc_div_ui((z),(x),(y),MPC_RNDNN)
55 #define cui_div(z,x,y)     mpc_ui_div((z),(x),(y),MPC_RNDNN)
56 #define csqrt(z,x)         mpc_sqrt((z),(x),MPC_RNDNN)
57 #define cnorm(z,x)         mpc_norm((z),(x),MPC_RNDNN)
58 #define cpow_ui(z,x,y)     mpc_pow_ui((z),(x),(y),MPC_RNDNN)
59 #define cexp(z,x)          mpc_exp((z),(x),MPC_RNDNN)
60 #define cinp_str(z,x,y,t)  mpc_inp_str((z),(x),(y),(t),MPC_RNDNN)
61 #define cout_str(z,x,y,t)  mpc_out_str((z),(x),(y),(t),MPC_RNDNN)
62 
63 #define ftype              mpfr_t
64 #define fptr               mpfr_ptr
65 #define fsrcptr            mpfr_srcptr
66 #define fprec_t            mpfr_prec_t
67 #define finit(z,n)         mpfr_init2((z),(n))
68 #define fclear(z)          mpfr_clear((z))
69 #define ffree_cache()      mpfr_free_cache()
70 #define fset_prec(z,n)     mpfr_set_prec((z),(n))
71 #define fget_prec(z)       mpfr_get_prec((z))
72 #define fget_exp(z)        mpfr_get_exp((z))
73 #define fget_z_exp(z,x)    mpfr_get_z_exp((z),(x))
74 #define fget_si(z)         mpfr_get_si((z),MPFR_RNDN)
75 #define fget_d_2exp(n,z)   mpfr_get_d_2exp((n),(z),MPFR_RNDN)
76 #define fget_emin()        mpfr_get_emin()
77 #define fzero_p(z)         mpfr_zero_p((z))
78 #define fsgn(z)            mpfr_sgn((z))
79 #define fcmp_d(z,x)        mpfr_cmp_d((z),(x))
80 #define fconst_pi(z)       mpfr_const_pi((z),MPFR_RNDN)
81 #define fset(z,x)          mpfr_set((z),(x),MPFR_RNDN)
82 #define fset_ui(z,x)       mpfr_set_ui((z),(x),MPFR_RNDN)
83 #define fset_si(z,x)       mpfr_set_si((z),(x),MPFR_RNDN)
84 #define fset_z(z,x)        mpfr_set_z((z),(x),MPFR_RNDN)
85 #define fneg(z,x)          mpfr_neg((z),(x),MPFR_RNDN)
86 #define fadd(z,x,y)        mpfr_add((z),(x),(y),MPFR_RNDN)
87 #define fsub(z,x,y)        mpfr_sub((z),(x),(y),MPFR_RNDN)
88 #define fmul(z,x,y)        mpfr_mul((z),(x),(y),MPFR_RNDN)
89 #define fmul_si(z,x,y)     mpfr_mul_si((z),(x),(y),MPFR_RNDN)
90 #define fmul_2ui(z,x,y)    mpfr_mul_2ui((z),(x),(y),MPFR_RNDN)
91 #define fsqr(z,x)          mpfr_sqr((z),(x),MPFR_RNDN)
92 #define fdiv(z,x,y)        mpfr_div((z),(x),(y),MPFR_RNDN)
93 #define fdiv_ui(z,x,y)     mpfr_div_ui((z),(x),(y),MPFR_RNDN)
94 #define fdiv_2ui(z,x,y)    mpfr_div_2ui((z),(x),(y),MPFR_RNDN)
95 #define fsqrt(z,x)         mpfr_sqrt((z),(x),MPFR_RNDN)
96 #define fsqrt_ui(z,x)      mpfr_sqrt_ui((z),(x),MPFR_RNDN)
97 #define fpow_ui(z,x,y)     mpfr_pow_ui((z),(x),(y),MPFR_RNDN)
98 #define fexp(z,x)          mpfr_exp((z),(x),MPFR_RNDN)
99 #define fsin_cos(z,y, x)   mpfr_sin_cos((z),(y),(x),MPFR_RNDN)
100 #define fround(z,x)        mpfr_round((z),(x))
101 #define fout_str(z,x,y,t)  mpfr_out_str((z),(x),(y),(t),MPFR_RNDN)
102 
103 #if defined (__cplusplus)
104 }
105 #endif
106 #endif /* ifndef __CM_ARITH_H */
107