mpf2mpfr.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /* mpf2mpfr.h -- Compatibility include file with mpf.
  2. Copyright 1999-2002, 2004-2019 Free Software Foundation, Inc.
  3. Contributed by the AriC and Caramba projects, INRIA.
  4. This file is part of the GNU MPFR Library.
  5. The GNU MPFR Library is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or (at your
  8. option) any later version.
  9. The GNU MPFR Library is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  12. License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
  15. https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
  16. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
  17. #ifndef __MPFR_FROM_MPF__
  18. #define __MPFR_FROM_MPF__
  19. /* types */
  20. #define mpf_t mpfr_t
  21. #define mpf_srcptr mpfr_srcptr
  22. #define mpf_ptr mpfr_ptr
  23. /* Get current Rounding Mode */
  24. #ifndef MPFR_DEFAULT_RND
  25. # define MPFR_DEFAULT_RND mpfr_get_default_rounding_mode ()
  26. #endif
  27. /* mpf_init initializes at 0 */
  28. #undef mpf_init
  29. #define mpf_init(x) mpfr_init_set_ui ((x), 0, MPFR_DEFAULT_RND)
  30. #undef mpf_init2
  31. #define mpf_init2(x,p) (mpfr_init2((x),(p)), mpfr_set_ui ((x), 0, MPFR_DEFAULT_RND))
  32. /* Warning! This assumes that all pointer types have the same representation. */
  33. #undef mpf_inits
  34. #define mpf_inits mpfr_inits
  35. #undef mpf_clears
  36. #define mpf_clears mpfr_clears
  37. /* functions which don't take as argument the rounding mode */
  38. #undef mpf_ceil
  39. #define mpf_ceil mpfr_ceil
  40. #undef mpf_clear
  41. #define mpf_clear mpfr_clear
  42. #undef mpf_cmp
  43. #define mpf_cmp mpfr_cmp
  44. #undef mpf_cmp_si
  45. #define mpf_cmp_si mpfr_cmp_si
  46. #undef mpf_cmp_ui
  47. #define mpf_cmp_ui mpfr_cmp_ui
  48. #undef mpf_cmp_d
  49. #define mpf_cmp_d mpfr_cmp_d
  50. /* mpf_cmp_z appeared in GMP 6.1.0 */
  51. #if __GNU_MP_VERSION > 6 || (__GNU_MP_VERSION == 6 && __GNU_MP_VERSION_MINOR >= 1)
  52. #undef mpf_cmp_z
  53. #define mpf_cmp_z mpfr_cmp_z
  54. #endif
  55. #undef mpf_eq
  56. #define mpf_eq mpfr_eq
  57. #undef mpf_floor
  58. #define mpf_floor mpfr_floor
  59. #undef mpf_get_prec
  60. #define mpf_get_prec mpfr_get_prec
  61. #undef mpf_integer_p
  62. #define mpf_integer_p mpfr_integer_p
  63. #undef mpf_random2
  64. #define mpf_random2 mpfr_random2
  65. #undef mpf_set_default_prec
  66. #define mpf_set_default_prec mpfr_set_default_prec
  67. #undef mpf_get_default_prec
  68. #define mpf_get_default_prec mpfr_get_default_prec
  69. #undef mpf_set_prec
  70. #define mpf_set_prec mpfr_set_prec
  71. #undef mpf_set_prec_raw
  72. #define mpf_set_prec_raw(x,p) mpfr_prec_round(x,p,MPFR_DEFAULT_RND)
  73. #undef mpf_trunc
  74. #define mpf_trunc mpfr_trunc
  75. #undef mpf_sgn
  76. #define mpf_sgn mpfr_sgn
  77. #undef mpf_swap
  78. #define mpf_swap mpfr_swap
  79. #undef mpf_dump
  80. #define mpf_dump mpfr_dump
  81. /* functions which take as argument the rounding mode */
  82. #undef mpf_abs
  83. #define mpf_abs(x,y) mpfr_abs(x,y,MPFR_DEFAULT_RND)
  84. #undef mpf_add
  85. #define mpf_add(x,y,z) mpfr_add(x,y,z,MPFR_DEFAULT_RND)
  86. #undef mpf_add_ui
  87. #define mpf_add_ui(x,y,z) mpfr_add_ui(x,y,z,MPFR_DEFAULT_RND)
  88. #undef mpf_div
  89. #define mpf_div(x,y,z) mpfr_div(x,y,z,MPFR_DEFAULT_RND)
  90. #undef mpf_div_ui
  91. #define mpf_div_ui(x,y,z) mpfr_div_ui(x,y,z,MPFR_DEFAULT_RND)
  92. #undef mpf_div_2exp
  93. #define mpf_div_2exp(x,y,z) mpfr_div_2exp(x,y,z,MPFR_DEFAULT_RND)
  94. #undef mpf_fits_slong_p
  95. #define mpf_fits_slong_p(x) mpfr_fits_slong_p(x,MPFR_DEFAULT_RND)
  96. #undef mpf_fits_ulong_p
  97. #define mpf_fits_ulong_p(x) mpfr_fits_ulong_p(x,MPFR_DEFAULT_RND)
  98. #undef mpf_fits_sint_p
  99. #define mpf_fits_sint_p(x) mpfr_fits_sint_p(x,MPFR_DEFAULT_RND)
  100. #undef mpf_fits_uint_p
  101. #define mpf_fits_uint_p(x) mpfr_fits_uint_p(x,MPFR_DEFAULT_RND)
  102. #undef mpf_fits_sshort_p
  103. #define mpf_fits_sshort_p(x) mpfr_fits_sshort_p(x,MPFR_DEFAULT_RND)
  104. #undef mpf_fits_ushort_p
  105. #define mpf_fits_ushort_p(x) mpfr_fits_ushort_p(x,MPFR_DEFAULT_RND)
  106. #undef mpf_get_str
  107. #define mpf_get_str(x,y,z,t,u) mpfr_get_str(x,y,z,t,u,MPFR_DEFAULT_RND)
  108. #undef mpf_get_d
  109. #define mpf_get_d(x) mpfr_get_d(x,MPFR_DEFAULT_RND)
  110. #undef mpf_get_d_2exp
  111. #define mpf_get_d_2exp(e,x) mpfr_get_d_2exp(e,x,MPFR_DEFAULT_RND)
  112. #undef mpf_get_ui
  113. #define mpf_get_ui(x) mpfr_get_ui(x,MPFR_DEFAULT_RND)
  114. #undef mpf_get_si
  115. #define mpf_get_si(x) mpfr_get_si(x,MPFR_DEFAULT_RND)
  116. #undef mpf_inp_str
  117. #define mpf_inp_str(x,y,z) mpfr_inp_str(x,y,z,MPFR_DEFAULT_RND)
  118. #undef mpf_set_str
  119. #define mpf_set_str(x,y,z) mpfr_set_str(x,y,z,MPFR_DEFAULT_RND)
  120. #undef mpf_init_set
  121. #define mpf_init_set(x,y) mpfr_init_set(x,y,MPFR_DEFAULT_RND)
  122. #undef mpf_init_set_d
  123. #define mpf_init_set_d(x,y) mpfr_init_set_d(x,y,MPFR_DEFAULT_RND)
  124. #undef mpf_init_set_si
  125. #define mpf_init_set_si(x,y) mpfr_init_set_si(x,y,MPFR_DEFAULT_RND)
  126. #undef mpf_init_set_str
  127. #define mpf_init_set_str(x,y,z) mpfr_init_set_str(x,y,z,MPFR_DEFAULT_RND)
  128. #undef mpf_init_set_ui
  129. #define mpf_init_set_ui(x,y) mpfr_init_set_ui(x,y,MPFR_DEFAULT_RND)
  130. #undef mpf_mul
  131. #define mpf_mul(x,y,z) mpfr_mul(x,y,z,MPFR_DEFAULT_RND)
  132. #undef mpf_mul_2exp
  133. #define mpf_mul_2exp(x,y,z) mpfr_mul_2exp(x,y,z,MPFR_DEFAULT_RND)
  134. #undef mpf_mul_ui
  135. #define mpf_mul_ui(x,y,z) mpfr_mul_ui(x,y,z,MPFR_DEFAULT_RND)
  136. #undef mpf_neg
  137. #define mpf_neg(x,y) mpfr_neg(x,y,MPFR_DEFAULT_RND)
  138. #undef mpf_out_str
  139. #define mpf_out_str(x,y,z,t) mpfr_out_str(x,y,z,t,MPFR_DEFAULT_RND)
  140. #undef mpf_pow_ui
  141. #define mpf_pow_ui(x,y,z) mpfr_pow_ui(x,y,z,MPFR_DEFAULT_RND)
  142. #undef mpf_reldiff
  143. #define mpf_reldiff(x,y,z) mpfr_reldiff(x,y,z,MPFR_DEFAULT_RND)
  144. #undef mpf_set
  145. #define mpf_set(x,y) mpfr_set(x,y,MPFR_DEFAULT_RND)
  146. #undef mpf_set_d
  147. #define mpf_set_d(x,y) mpfr_set_d(x,y,MPFR_DEFAULT_RND)
  148. #undef mpf_set_q
  149. #define mpf_set_q(x,y) mpfr_set_q(x,y,MPFR_DEFAULT_RND)
  150. #undef mpf_set_si
  151. #define mpf_set_si(x,y) mpfr_set_si(x,y,MPFR_DEFAULT_RND)
  152. #undef mpf_set_ui
  153. #define mpf_set_ui(x,y) mpfr_set_ui(x,y,MPFR_DEFAULT_RND)
  154. #undef mpf_set_z
  155. #define mpf_set_z(x,y) mpfr_set_z(x,y,MPFR_DEFAULT_RND)
  156. #undef mpf_sqrt
  157. #define mpf_sqrt(x,y) mpfr_sqrt(x,y,MPFR_DEFAULT_RND)
  158. #undef mpf_sqrt_ui
  159. #define mpf_sqrt_ui(x,y) mpfr_sqrt_ui(x,y,MPFR_DEFAULT_RND)
  160. #undef mpf_sub
  161. #define mpf_sub(x,y,z) mpfr_sub(x,y,z,MPFR_DEFAULT_RND)
  162. #undef mpf_sub_ui
  163. #define mpf_sub_ui(x,y,z) mpfr_sub_ui(x,y,z,MPFR_DEFAULT_RND)
  164. #undef mpf_ui_div
  165. #define mpf_ui_div(x,y,z) mpfr_ui_div(x,y,z,MPFR_DEFAULT_RND)
  166. #undef mpf_ui_sub
  167. #define mpf_ui_sub(x,y,z) mpfr_ui_sub(x,y,z,MPFR_DEFAULT_RND)
  168. #undef mpf_urandomb
  169. #define mpf_urandomb(x,y,n) mpfr_urandomb(x,y)
  170. #undef mpz_set_f
  171. #define mpz_set_f(z,f) mpfr_get_z(z,f,MPFR_DEFAULT_RND)
  172. #undef mpq_set_f
  173. #define mpq_set_f(q,f) mpfr_get_q(q,f)
  174. #endif /* __MPFR_FROM_MPF__ */