mqt-core 3.3.2__cp313-cp313t-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (537) hide show
  1. mqt/core/__init__.py +89 -0
  2. mqt/core/__main__.py +55 -0
  3. mqt/core/_commands.py +52 -0
  4. mqt/core/_compat/__init__.py +11 -0
  5. mqt/core/_compat/typing.py +29 -0
  6. mqt/core/_version.py +34 -0
  7. mqt/core/_version.pyi +12 -0
  8. mqt/core/bin/mqt-core-algorithms.dll +0 -0
  9. mqt/core/bin/mqt-core-circuit-optimizer.dll +0 -0
  10. mqt/core/bin/mqt-core-dd.dll +0 -0
  11. mqt/core/bin/mqt-core-ds.dll +0 -0
  12. mqt/core/bin/mqt-core-fomac.dll +0 -0
  13. mqt/core/bin/mqt-core-ir.dll +0 -0
  14. mqt/core/bin/mqt-core-na-fomac.dll +0 -0
  15. mqt/core/bin/mqt-core-na.dll +0 -0
  16. mqt/core/bin/mqt-core-qasm.dll +0 -0
  17. mqt/core/bin/mqt-core-qdmi-driver.dll +0 -0
  18. mqt/core/bin/mqt-core-qdmi-na-device.dll +0 -0
  19. mqt/core/bin/mqt-core-zx.dll +0 -0
  20. mqt/core/dd.cp313t-win_amd64.pyd +0 -0
  21. mqt/core/dd.pyi +1016 -0
  22. mqt/core/dd_evaluation.py +368 -0
  23. mqt/core/fomac.cp313t-win_amd64.pyd +0 -0
  24. mqt/core/fomac.pyi +125 -0
  25. mqt/core/include/mqt-core/algorithms/BernsteinVazirani.hpp +39 -0
  26. mqt/core/include/mqt-core/algorithms/GHZState.hpp +18 -0
  27. mqt/core/include/mqt-core/algorithms/Grover.hpp +33 -0
  28. mqt/core/include/mqt-core/algorithms/QFT.hpp +21 -0
  29. mqt/core/include/mqt-core/algorithms/QPE.hpp +30 -0
  30. mqt/core/include/mqt-core/algorithms/RandomCliffordCircuit.hpp +22 -0
  31. mqt/core/include/mqt-core/algorithms/StatePreparation.hpp +43 -0
  32. mqt/core/include/mqt-core/algorithms/WState.hpp +18 -0
  33. mqt/core/include/mqt-core/algorithms/mqt_core_algorithms_export.h +43 -0
  34. mqt/core/include/mqt-core/boost/config/abi/borland_prefix.hpp +27 -0
  35. mqt/core/include/mqt-core/boost/config/abi/borland_suffix.hpp +12 -0
  36. mqt/core/include/mqt-core/boost/config/abi/msvc_prefix.hpp +22 -0
  37. mqt/core/include/mqt-core/boost/config/abi/msvc_suffix.hpp +8 -0
  38. mqt/core/include/mqt-core/boost/config/abi_prefix.hpp +25 -0
  39. mqt/core/include/mqt-core/boost/config/abi_suffix.hpp +25 -0
  40. mqt/core/include/mqt-core/boost/config/assert_cxx03.hpp +211 -0
  41. mqt/core/include/mqt-core/boost/config/assert_cxx11.hpp +212 -0
  42. mqt/core/include/mqt-core/boost/config/assert_cxx14.hpp +47 -0
  43. mqt/core/include/mqt-core/boost/config/assert_cxx17.hpp +65 -0
  44. mqt/core/include/mqt-core/boost/config/assert_cxx20.hpp +59 -0
  45. mqt/core/include/mqt-core/boost/config/assert_cxx23.hpp +41 -0
  46. mqt/core/include/mqt-core/boost/config/assert_cxx98.hpp +23 -0
  47. mqt/core/include/mqt-core/boost/config/auto_link.hpp +525 -0
  48. mqt/core/include/mqt-core/boost/config/compiler/borland.hpp +342 -0
  49. mqt/core/include/mqt-core/boost/config/compiler/clang.hpp +370 -0
  50. mqt/core/include/mqt-core/boost/config/compiler/clang_version.hpp +89 -0
  51. mqt/core/include/mqt-core/boost/config/compiler/codegear.hpp +389 -0
  52. mqt/core/include/mqt-core/boost/config/compiler/comeau.hpp +59 -0
  53. mqt/core/include/mqt-core/boost/config/compiler/common_edg.hpp +185 -0
  54. mqt/core/include/mqt-core/boost/config/compiler/compaq_cxx.hpp +19 -0
  55. mqt/core/include/mqt-core/boost/config/compiler/cray.hpp +446 -0
  56. mqt/core/include/mqt-core/boost/config/compiler/diab.hpp +26 -0
  57. mqt/core/include/mqt-core/boost/config/compiler/digitalmars.hpp +146 -0
  58. mqt/core/include/mqt-core/boost/config/compiler/gcc.hpp +386 -0
  59. mqt/core/include/mqt-core/boost/config/compiler/gcc_xml.hpp +115 -0
  60. mqt/core/include/mqt-core/boost/config/compiler/greenhills.hpp +28 -0
  61. mqt/core/include/mqt-core/boost/config/compiler/hp_acc.hpp +153 -0
  62. mqt/core/include/mqt-core/boost/config/compiler/intel.hpp +577 -0
  63. mqt/core/include/mqt-core/boost/config/compiler/kai.hpp +33 -0
  64. mqt/core/include/mqt-core/boost/config/compiler/metrowerks.hpp +201 -0
  65. mqt/core/include/mqt-core/boost/config/compiler/mpw.hpp +143 -0
  66. mqt/core/include/mqt-core/boost/config/compiler/nvcc.hpp +64 -0
  67. mqt/core/include/mqt-core/boost/config/compiler/pathscale.hpp +141 -0
  68. mqt/core/include/mqt-core/boost/config/compiler/pgi.hpp +23 -0
  69. mqt/core/include/mqt-core/boost/config/compiler/sgi_mipspro.hpp +29 -0
  70. mqt/core/include/mqt-core/boost/config/compiler/sunpro_cc.hpp +225 -0
  71. mqt/core/include/mqt-core/boost/config/compiler/vacpp.hpp +189 -0
  72. mqt/core/include/mqt-core/boost/config/compiler/visualc.hpp +398 -0
  73. mqt/core/include/mqt-core/boost/config/compiler/xlcpp.hpp +303 -0
  74. mqt/core/include/mqt-core/boost/config/compiler/xlcpp_zos.hpp +174 -0
  75. mqt/core/include/mqt-core/boost/config/detail/cxx_composite.hpp +218 -0
  76. mqt/core/include/mqt-core/boost/config/detail/posix_features.hpp +95 -0
  77. mqt/core/include/mqt-core/boost/config/detail/select_compiler_config.hpp +157 -0
  78. mqt/core/include/mqt-core/boost/config/detail/select_platform_config.hpp +147 -0
  79. mqt/core/include/mqt-core/boost/config/detail/select_stdlib_config.hpp +121 -0
  80. mqt/core/include/mqt-core/boost/config/detail/suffix.hpp +1334 -0
  81. mqt/core/include/mqt-core/boost/config/header_deprecated.hpp +26 -0
  82. mqt/core/include/mqt-core/boost/config/helper_macros.hpp +37 -0
  83. mqt/core/include/mqt-core/boost/config/no_tr1/cmath.hpp +28 -0
  84. mqt/core/include/mqt-core/boost/config/no_tr1/complex.hpp +28 -0
  85. mqt/core/include/mqt-core/boost/config/no_tr1/functional.hpp +28 -0
  86. mqt/core/include/mqt-core/boost/config/no_tr1/memory.hpp +28 -0
  87. mqt/core/include/mqt-core/boost/config/no_tr1/utility.hpp +28 -0
  88. mqt/core/include/mqt-core/boost/config/platform/aix.hpp +33 -0
  89. mqt/core/include/mqt-core/boost/config/platform/amigaos.hpp +15 -0
  90. mqt/core/include/mqt-core/boost/config/platform/beos.hpp +26 -0
  91. mqt/core/include/mqt-core/boost/config/platform/bsd.hpp +83 -0
  92. mqt/core/include/mqt-core/boost/config/platform/cloudabi.hpp +18 -0
  93. mqt/core/include/mqt-core/boost/config/platform/cray.hpp +18 -0
  94. mqt/core/include/mqt-core/boost/config/platform/cygwin.hpp +71 -0
  95. mqt/core/include/mqt-core/boost/config/platform/haiku.hpp +31 -0
  96. mqt/core/include/mqt-core/boost/config/platform/hpux.hpp +87 -0
  97. mqt/core/include/mqt-core/boost/config/platform/irix.hpp +31 -0
  98. mqt/core/include/mqt-core/boost/config/platform/linux.hpp +106 -0
  99. mqt/core/include/mqt-core/boost/config/platform/macos.hpp +87 -0
  100. mqt/core/include/mqt-core/boost/config/platform/qnxnto.hpp +31 -0
  101. mqt/core/include/mqt-core/boost/config/platform/solaris.hpp +31 -0
  102. mqt/core/include/mqt-core/boost/config/platform/symbian.hpp +97 -0
  103. mqt/core/include/mqt-core/boost/config/platform/vms.hpp +25 -0
  104. mqt/core/include/mqt-core/boost/config/platform/vxworks.hpp +422 -0
  105. mqt/core/include/mqt-core/boost/config/platform/wasm.hpp +23 -0
  106. mqt/core/include/mqt-core/boost/config/platform/win32.hpp +90 -0
  107. mqt/core/include/mqt-core/boost/config/platform/zos.hpp +32 -0
  108. mqt/core/include/mqt-core/boost/config/pragma_message.hpp +31 -0
  109. mqt/core/include/mqt-core/boost/config/requires_threads.hpp +92 -0
  110. mqt/core/include/mqt-core/boost/config/stdlib/dinkumware.hpp +324 -0
  111. mqt/core/include/mqt-core/boost/config/stdlib/libcomo.hpp +93 -0
  112. mqt/core/include/mqt-core/boost/config/stdlib/libcpp.hpp +180 -0
  113. mqt/core/include/mqt-core/boost/config/stdlib/libstdcpp3.hpp +482 -0
  114. mqt/core/include/mqt-core/boost/config/stdlib/modena.hpp +79 -0
  115. mqt/core/include/mqt-core/boost/config/stdlib/msl.hpp +98 -0
  116. mqt/core/include/mqt-core/boost/config/stdlib/roguewave.hpp +208 -0
  117. mqt/core/include/mqt-core/boost/config/stdlib/sgi.hpp +168 -0
  118. mqt/core/include/mqt-core/boost/config/stdlib/stlport.hpp +258 -0
  119. mqt/core/include/mqt-core/boost/config/stdlib/vacpp.hpp +74 -0
  120. mqt/core/include/mqt-core/boost/config/stdlib/xlcpp_zos.hpp +61 -0
  121. mqt/core/include/mqt-core/boost/config/user.hpp +133 -0
  122. mqt/core/include/mqt-core/boost/config/warning_disable.hpp +47 -0
  123. mqt/core/include/mqt-core/boost/config/workaround.hpp +305 -0
  124. mqt/core/include/mqt-core/boost/config.hpp +67 -0
  125. mqt/core/include/mqt-core/boost/cstdint.hpp +556 -0
  126. mqt/core/include/mqt-core/boost/cxx11_char_types.hpp +70 -0
  127. mqt/core/include/mqt-core/boost/detail/workaround.hpp +10 -0
  128. mqt/core/include/mqt-core/boost/limits.hpp +146 -0
  129. mqt/core/include/mqt-core/boost/multiprecision/complex128.hpp +24 -0
  130. mqt/core/include/mqt-core/boost/multiprecision/complex_adaptor.hpp +1046 -0
  131. mqt/core/include/mqt-core/boost/multiprecision/concepts/mp_number_archetypes.hpp +257 -0
  132. mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/io.hpp +698 -0
  133. mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/transcendental.hpp +157 -0
  134. mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float.hpp +2297 -0
  135. mqt/core/include/mqt-core/boost/multiprecision/cpp_complex.hpp +12 -0
  136. mqt/core/include/mqt-core/boost/multiprecision/cpp_dec_float.hpp +3690 -0
  137. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add.hpp +368 -0
  138. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add_unsigned.hpp +387 -0
  139. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/bitwise.hpp +889 -0
  140. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/checked.hpp +178 -0
  141. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/comparison.hpp +374 -0
  142. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/cpp_int_config.hpp +161 -0
  143. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/divide.hpp +703 -0
  144. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/import_export.hpp +248 -0
  145. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/intel_intrinsics.hpp +138 -0
  146. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/limits.hpp +282 -0
  147. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/literals.hpp +295 -0
  148. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/misc.hpp +1457 -0
  149. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/multiply.hpp +848 -0
  150. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/serialize.hpp +211 -0
  151. mqt/core/include/mqt-core/boost/multiprecision/cpp_int/value_pack.hpp +42 -0
  152. mqt/core/include/mqt-core/boost/multiprecision/cpp_int.hpp +2360 -0
  153. mqt/core/include/mqt-core/boost/multiprecision/debug_adaptor.hpp +760 -0
  154. mqt/core/include/mqt-core/boost/multiprecision/detail/assert.hpp +29 -0
  155. mqt/core/include/mqt-core/boost/multiprecision/detail/atomic.hpp +62 -0
  156. mqt/core/include/mqt-core/boost/multiprecision/detail/bitscan.hpp +317 -0
  157. mqt/core/include/mqt-core/boost/multiprecision/detail/check_cpp11_config.hpp +64 -0
  158. mqt/core/include/mqt-core/boost/multiprecision/detail/constexpr.hpp +88 -0
  159. mqt/core/include/mqt-core/boost/multiprecision/detail/default_ops.hpp +4052 -0
  160. mqt/core/include/mqt-core/boost/multiprecision/detail/digits.hpp +49 -0
  161. mqt/core/include/mqt-core/boost/multiprecision/detail/dynamic_array.hpp +44 -0
  162. mqt/core/include/mqt-core/boost/multiprecision/detail/empty_value.hpp +87 -0
  163. mqt/core/include/mqt-core/boost/multiprecision/detail/endian.hpp +35 -0
  164. mqt/core/include/mqt-core/boost/multiprecision/detail/et_ops.hpp +1831 -0
  165. mqt/core/include/mqt-core/boost/multiprecision/detail/float128_functions.hpp +95 -0
  166. mqt/core/include/mqt-core/boost/multiprecision/detail/float_string_cvt.hpp +333 -0
  167. mqt/core/include/mqt-core/boost/multiprecision/detail/fpclassify.hpp +101 -0
  168. mqt/core/include/mqt-core/boost/multiprecision/detail/functions/constants.hpp +288 -0
  169. mqt/core/include/mqt-core/boost/multiprecision/detail/functions/pow.hpp +905 -0
  170. mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trig.hpp +1058 -0
  171. mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trunc.hpp +82 -0
  172. mqt/core/include/mqt-core/boost/multiprecision/detail/generic_interconvert.hpp +687 -0
  173. mqt/core/include/mqt-core/boost/multiprecision/detail/hash.hpp +56 -0
  174. mqt/core/include/mqt-core/boost/multiprecision/detail/integer_ops.hpp +474 -0
  175. mqt/core/include/mqt-core/boost/multiprecision/detail/itos.hpp +39 -0
  176. mqt/core/include/mqt-core/boost/multiprecision/detail/min_max.hpp +106 -0
  177. mqt/core/include/mqt-core/boost/multiprecision/detail/no_et_ops.hpp +661 -0
  178. mqt/core/include/mqt-core/boost/multiprecision/detail/no_exceptions_support.hpp +55 -0
  179. mqt/core/include/mqt-core/boost/multiprecision/detail/number_base.hpp +1656 -0
  180. mqt/core/include/mqt-core/boost/multiprecision/detail/number_compare.hpp +848 -0
  181. mqt/core/include/mqt-core/boost/multiprecision/detail/precision.hpp +313 -0
  182. mqt/core/include/mqt-core/boost/multiprecision/detail/rebind.hpp +19 -0
  183. mqt/core/include/mqt-core/boost/multiprecision/detail/standalone_config.hpp +148 -0
  184. mqt/core/include/mqt-core/boost/multiprecision/detail/static_array.hpp +42 -0
  185. mqt/core/include/mqt-core/boost/multiprecision/detail/string_helpers.hpp +48 -0
  186. mqt/core/include/mqt-core/boost/multiprecision/detail/tables.hpp +80 -0
  187. mqt/core/include/mqt-core/boost/multiprecision/detail/ublas_interop.hpp +75 -0
  188. mqt/core/include/mqt-core/boost/multiprecision/detail/uniform_int_distribution.hpp +212 -0
  189. mqt/core/include/mqt-core/boost/multiprecision/detail/utype_helper.hpp +374 -0
  190. mqt/core/include/mqt-core/boost/multiprecision/eigen.hpp +248 -0
  191. mqt/core/include/mqt-core/boost/multiprecision/float128.hpp +920 -0
  192. mqt/core/include/mqt-core/boost/multiprecision/fwd.hpp +268 -0
  193. mqt/core/include/mqt-core/boost/multiprecision/gmp.hpp +4060 -0
  194. mqt/core/include/mqt-core/boost/multiprecision/integer.hpp +363 -0
  195. mqt/core/include/mqt-core/boost/multiprecision/logged_adaptor.hpp +834 -0
  196. mqt/core/include/mqt-core/boost/multiprecision/miller_rabin.hpp +221 -0
  197. mqt/core/include/mqt-core/boost/multiprecision/mpc.hpp +1721 -0
  198. mqt/core/include/mqt-core/boost/multiprecision/mpfi.hpp +2559 -0
  199. mqt/core/include/mqt-core/boost/multiprecision/mpfr.hpp +3644 -0
  200. mqt/core/include/mqt-core/boost/multiprecision/number.hpp +2500 -0
  201. mqt/core/include/mqt-core/boost/multiprecision/random.hpp +23 -0
  202. mqt/core/include/mqt-core/boost/multiprecision/rational_adaptor.hpp +1289 -0
  203. mqt/core/include/mqt-core/boost/multiprecision/tommath.hpp +1034 -0
  204. mqt/core/include/mqt-core/boost/multiprecision/traits/explicit_conversion.hpp +67 -0
  205. mqt/core/include/mqt-core/boost/multiprecision/traits/extract_exponent_type.hpp +28 -0
  206. mqt/core/include/mqt-core/boost/multiprecision/traits/is_backend.hpp +91 -0
  207. mqt/core/include/mqt-core/boost/multiprecision/traits/is_byte_container.hpp +51 -0
  208. mqt/core/include/mqt-core/boost/multiprecision/traits/is_complex.hpp +22 -0
  209. mqt/core/include/mqt-core/boost/multiprecision/traits/is_convertible_arithmetic.hpp +51 -0
  210. mqt/core/include/mqt-core/boost/multiprecision/traits/is_restricted_conversion.hpp +47 -0
  211. mqt/core/include/mqt-core/boost/multiprecision/traits/is_variable_precision.hpp +25 -0
  212. mqt/core/include/mqt-core/boost/multiprecision/traits/max_digits10.hpp +79 -0
  213. mqt/core/include/mqt-core/boost/multiprecision/traits/std_integer_traits.hpp +90 -0
  214. mqt/core/include/mqt-core/boost/multiprecision/traits/transcendental_reduction_type.hpp +21 -0
  215. mqt/core/include/mqt-core/boost/version.hpp +32 -0
  216. mqt/core/include/mqt-core/circuit_optimizer/CircuitOptimizer.hpp +119 -0
  217. mqt/core/include/mqt-core/circuit_optimizer/mqt_core_circuit_optimizer_export.h +43 -0
  218. mqt/core/include/mqt-core/datastructures/DirectedAcyclicGraph.hpp +117 -0
  219. mqt/core/include/mqt-core/datastructures/DirectedGraph.hpp +158 -0
  220. mqt/core/include/mqt-core/datastructures/DisjointSet.hpp +50 -0
  221. mqt/core/include/mqt-core/datastructures/Layer.hpp +172 -0
  222. mqt/core/include/mqt-core/datastructures/SymmetricMatrix.hpp +57 -0
  223. mqt/core/include/mqt-core/datastructures/UndirectedGraph.hpp +227 -0
  224. mqt/core/include/mqt-core/datastructures/mqt_core_ds_export.h +43 -0
  225. mqt/core/include/mqt-core/dd/Approximation.hpp +45 -0
  226. mqt/core/include/mqt-core/dd/CachedEdge.hpp +174 -0
  227. mqt/core/include/mqt-core/dd/Complex.hpp +165 -0
  228. mqt/core/include/mqt-core/dd/ComplexNumbers.hpp +150 -0
  229. mqt/core/include/mqt-core/dd/ComplexValue.hpp +184 -0
  230. mqt/core/include/mqt-core/dd/ComputeTable.hpp +183 -0
  231. mqt/core/include/mqt-core/dd/DDDefinitions.hpp +139 -0
  232. mqt/core/include/mqt-core/dd/DDpackageConfig.hpp +104 -0
  233. mqt/core/include/mqt-core/dd/DensityNoiseTable.hpp +114 -0
  234. mqt/core/include/mqt-core/dd/Edge.hpp +416 -0
  235. mqt/core/include/mqt-core/dd/Export.hpp +438 -0
  236. mqt/core/include/mqt-core/dd/FunctionalityConstruction.hpp +75 -0
  237. mqt/core/include/mqt-core/dd/GateMatrixDefinitions.hpp +43 -0
  238. mqt/core/include/mqt-core/dd/LinkedListBase.hpp +45 -0
  239. mqt/core/include/mqt-core/dd/MemoryManager.hpp +193 -0
  240. mqt/core/include/mqt-core/dd/Node.hpp +223 -0
  241. mqt/core/include/mqt-core/dd/NoiseFunctionality.hpp +144 -0
  242. mqt/core/include/mqt-core/dd/Operations.hpp +306 -0
  243. mqt/core/include/mqt-core/dd/Package.hpp +2036 -0
  244. mqt/core/include/mqt-core/dd/Package_fwd.hpp +22 -0
  245. mqt/core/include/mqt-core/dd/RealNumber.hpp +255 -0
  246. mqt/core/include/mqt-core/dd/RealNumberUniqueTable.hpp +217 -0
  247. mqt/core/include/mqt-core/dd/Simulation.hpp +98 -0
  248. mqt/core/include/mqt-core/dd/StateGeneration.hpp +143 -0
  249. mqt/core/include/mqt-core/dd/StochasticNoiseOperationTable.hpp +88 -0
  250. mqt/core/include/mqt-core/dd/UnaryComputeTable.hpp +121 -0
  251. mqt/core/include/mqt-core/dd/UniqueTable.hpp +243 -0
  252. mqt/core/include/mqt-core/dd/mqt_core_dd_export.h +43 -0
  253. mqt/core/include/mqt-core/dd/statistics/MemoryManagerStatistics.hpp +84 -0
  254. mqt/core/include/mqt-core/dd/statistics/PackageStatistics.hpp +55 -0
  255. mqt/core/include/mqt-core/dd/statistics/Statistics.hpp +48 -0
  256. mqt/core/include/mqt-core/dd/statistics/TableStatistics.hpp +79 -0
  257. mqt/core/include/mqt-core/dd/statistics/UniqueTableStatistics.hpp +31 -0
  258. mqt/core/include/mqt-core/fomac/FoMaC.hpp +568 -0
  259. mqt/core/include/mqt-core/ir/Definitions.hpp +108 -0
  260. mqt/core/include/mqt-core/ir/Permutation.hpp +213 -0
  261. mqt/core/include/mqt-core/ir/QuantumComputation.hpp +596 -0
  262. mqt/core/include/mqt-core/ir/Register.hpp +125 -0
  263. mqt/core/include/mqt-core/ir/mqt_core_ir_export.h +43 -0
  264. mqt/core/include/mqt-core/ir/operations/AodOperation.hpp +92 -0
  265. mqt/core/include/mqt-core/ir/operations/CompoundOperation.hpp +212 -0
  266. mqt/core/include/mqt-core/ir/operations/Control.hpp +142 -0
  267. mqt/core/include/mqt-core/ir/operations/Expression.hpp +847 -0
  268. mqt/core/include/mqt-core/ir/operations/IfElseOperation.hpp +169 -0
  269. mqt/core/include/mqt-core/ir/operations/NonUnitaryOperation.hpp +118 -0
  270. mqt/core/include/mqt-core/ir/operations/OpType.hpp +120 -0
  271. mqt/core/include/mqt-core/ir/operations/OpType.inc +76 -0
  272. mqt/core/include/mqt-core/ir/operations/Operation.hpp +247 -0
  273. mqt/core/include/mqt-core/ir/operations/StandardOperation.hpp +140 -0
  274. mqt/core/include/mqt-core/ir/operations/SymbolicOperation.hpp +144 -0
  275. mqt/core/include/mqt-core/mqt_na_qdmi/device.h +602 -0
  276. mqt/core/include/mqt-core/mqt_na_qdmi/types.h +78 -0
  277. mqt/core/include/mqt-core/na/NAComputation.hpp +185 -0
  278. mqt/core/include/mqt-core/na/device/Device.hpp +410 -0
  279. mqt/core/include/mqt-core/na/device/DeviceMemberInitializers.hpp +724 -0
  280. mqt/core/include/mqt-core/na/device/Generator.hpp +447 -0
  281. mqt/core/include/mqt-core/na/entities/Atom.hpp +62 -0
  282. mqt/core/include/mqt-core/na/entities/Location.hpp +154 -0
  283. mqt/core/include/mqt-core/na/entities/Zone.hpp +95 -0
  284. mqt/core/include/mqt-core/na/fomac/Device.hpp +169 -0
  285. mqt/core/include/mqt-core/na/mqt_core_na_export.h +43 -0
  286. mqt/core/include/mqt-core/na/operations/GlobalCZOp.hpp +38 -0
  287. mqt/core/include/mqt-core/na/operations/GlobalOp.hpp +58 -0
  288. mqt/core/include/mqt-core/na/operations/GlobalRYOp.hpp +42 -0
  289. mqt/core/include/mqt-core/na/operations/LoadOp.hpp +89 -0
  290. mqt/core/include/mqt-core/na/operations/LocalOp.hpp +56 -0
  291. mqt/core/include/mqt-core/na/operations/LocalRZOp.hpp +42 -0
  292. mqt/core/include/mqt-core/na/operations/LocalUOp.hpp +49 -0
  293. mqt/core/include/mqt-core/na/operations/MoveOp.hpp +66 -0
  294. mqt/core/include/mqt-core/na/operations/Op.hpp +62 -0
  295. mqt/core/include/mqt-core/na/operations/ShuttlingOp.hpp +51 -0
  296. mqt/core/include/mqt-core/na/operations/StoreOp.hpp +87 -0
  297. mqt/core/include/mqt-core/qasm3/Exception.hpp +85 -0
  298. mqt/core/include/mqt-core/qasm3/Gate.hpp +65 -0
  299. mqt/core/include/mqt-core/qasm3/Importer.hpp +192 -0
  300. mqt/core/include/mqt-core/qasm3/InstVisitor.hpp +145 -0
  301. mqt/core/include/mqt-core/qasm3/NestedEnvironment.hpp +41 -0
  302. mqt/core/include/mqt-core/qasm3/Parser.hpp +170 -0
  303. mqt/core/include/mqt-core/qasm3/Scanner.hpp +73 -0
  304. mqt/core/include/mqt-core/qasm3/Statement.hpp +486 -0
  305. mqt/core/include/mqt-core/qasm3/Statement_fwd.hpp +39 -0
  306. mqt/core/include/mqt-core/qasm3/StdGates.hpp +232 -0
  307. mqt/core/include/mqt-core/qasm3/Token.hpp +198 -0
  308. mqt/core/include/mqt-core/qasm3/Types.hpp +238 -0
  309. mqt/core/include/mqt-core/qasm3/Types_fwd.hpp +22 -0
  310. mqt/core/include/mqt-core/qasm3/mqt_core_qasm_export.h +43 -0
  311. mqt/core/include/mqt-core/qasm3/passes/CompilerPass.hpp +22 -0
  312. mqt/core/include/mqt-core/qasm3/passes/ConstEvalPass.hpp +102 -0
  313. mqt/core/include/mqt-core/qasm3/passes/TypeCheckPass.hpp +124 -0
  314. mqt/core/include/mqt-core/qdmi/Driver.hpp +431 -0
  315. mqt/core/include/mqt-core/zx/FunctionalityConstruction.hpp +125 -0
  316. mqt/core/include/mqt-core/zx/Rational.hpp +318 -0
  317. mqt/core/include/mqt-core/zx/Rules.hpp +132 -0
  318. mqt/core/include/mqt-core/zx/Simplify.hpp +182 -0
  319. mqt/core/include/mqt-core/zx/Utils.hpp +212 -0
  320. mqt/core/include/mqt-core/zx/ZXDefinitions.hpp +93 -0
  321. mqt/core/include/mqt-core/zx/ZXDiagram.hpp +480 -0
  322. mqt/core/include/mqt-core/zx/mqt_core_zx_export.h +43 -0
  323. mqt/core/include/nlohmann/adl_serializer.hpp +55 -0
  324. mqt/core/include/nlohmann/byte_container_with_subtype.hpp +103 -0
  325. mqt/core/include/nlohmann/detail/abi_macros.hpp +111 -0
  326. mqt/core/include/nlohmann/detail/conversions/from_json.hpp +577 -0
  327. mqt/core/include/nlohmann/detail/conversions/to_chars.hpp +1118 -0
  328. mqt/core/include/nlohmann/detail/conversions/to_json.hpp +479 -0
  329. mqt/core/include/nlohmann/detail/exceptions.hpp +291 -0
  330. mqt/core/include/nlohmann/detail/hash.hpp +129 -0
  331. mqt/core/include/nlohmann/detail/input/binary_reader.hpp +3068 -0
  332. mqt/core/include/nlohmann/detail/input/input_adapters.hpp +549 -0
  333. mqt/core/include/nlohmann/detail/input/json_sax.hpp +986 -0
  334. mqt/core/include/nlohmann/detail/input/lexer.hpp +1643 -0
  335. mqt/core/include/nlohmann/detail/input/parser.hpp +519 -0
  336. mqt/core/include/nlohmann/detail/input/position_t.hpp +37 -0
  337. mqt/core/include/nlohmann/detail/iterators/internal_iterator.hpp +35 -0
  338. mqt/core/include/nlohmann/detail/iterators/iter_impl.hpp +760 -0
  339. mqt/core/include/nlohmann/detail/iterators/iteration_proxy.hpp +235 -0
  340. mqt/core/include/nlohmann/detail/iterators/iterator_traits.hpp +61 -0
  341. mqt/core/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +130 -0
  342. mqt/core/include/nlohmann/detail/iterators/primitive_iterator.hpp +132 -0
  343. mqt/core/include/nlohmann/detail/json_custom_base_class.hpp +39 -0
  344. mqt/core/include/nlohmann/detail/json_pointer.hpp +988 -0
  345. mqt/core/include/nlohmann/detail/json_ref.hpp +78 -0
  346. mqt/core/include/nlohmann/detail/macro_scope.hpp +595 -0
  347. mqt/core/include/nlohmann/detail/macro_unscope.hpp +46 -0
  348. mqt/core/include/nlohmann/detail/meta/call_std/begin.hpp +17 -0
  349. mqt/core/include/nlohmann/detail/meta/call_std/end.hpp +17 -0
  350. mqt/core/include/nlohmann/detail/meta/cpp_future.hpp +171 -0
  351. mqt/core/include/nlohmann/detail/meta/detected.hpp +70 -0
  352. mqt/core/include/nlohmann/detail/meta/identity_tag.hpp +21 -0
  353. mqt/core/include/nlohmann/detail/meta/is_sax.hpp +159 -0
  354. mqt/core/include/nlohmann/detail/meta/std_fs.hpp +29 -0
  355. mqt/core/include/nlohmann/detail/meta/type_traits.hpp +795 -0
  356. mqt/core/include/nlohmann/detail/meta/void_t.hpp +24 -0
  357. mqt/core/include/nlohmann/detail/output/binary_writer.hpp +1850 -0
  358. mqt/core/include/nlohmann/detail/output/output_adapters.hpp +147 -0
  359. mqt/core/include/nlohmann/detail/output/serializer.hpp +988 -0
  360. mqt/core/include/nlohmann/detail/string_concat.hpp +146 -0
  361. mqt/core/include/nlohmann/detail/string_escape.hpp +72 -0
  362. mqt/core/include/nlohmann/detail/string_utils.hpp +37 -0
  363. mqt/core/include/nlohmann/detail/value_t.hpp +118 -0
  364. mqt/core/include/nlohmann/json.hpp +5306 -0
  365. mqt/core/include/nlohmann/json_fwd.hpp +75 -0
  366. mqt/core/include/nlohmann/ordered_map.hpp +359 -0
  367. mqt/core/include/nlohmann/thirdparty/hedley/hedley.hpp +2045 -0
  368. mqt/core/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +158 -0
  369. mqt/core/include/qdmi/qdmi/client.h +990 -0
  370. mqt/core/include/qdmi/qdmi/constants.h +1139 -0
  371. mqt/core/include/qdmi/qdmi/device.h +602 -0
  372. mqt/core/include/qdmi/qdmi/types.h +78 -0
  373. mqt/core/include/spdlog/async.h +99 -0
  374. mqt/core/include/spdlog/async_logger-inl.h +84 -0
  375. mqt/core/include/spdlog/async_logger.h +74 -0
  376. mqt/core/include/spdlog/cfg/argv.h +40 -0
  377. mqt/core/include/spdlog/cfg/env.h +36 -0
  378. mqt/core/include/spdlog/cfg/helpers-inl.h +107 -0
  379. mqt/core/include/spdlog/cfg/helpers.h +29 -0
  380. mqt/core/include/spdlog/common-inl.h +68 -0
  381. mqt/core/include/spdlog/common.h +406 -0
  382. mqt/core/include/spdlog/details/backtracer-inl.h +63 -0
  383. mqt/core/include/spdlog/details/backtracer.h +45 -0
  384. mqt/core/include/spdlog/details/circular_q.h +115 -0
  385. mqt/core/include/spdlog/details/console_globals.h +28 -0
  386. mqt/core/include/spdlog/details/file_helper-inl.h +153 -0
  387. mqt/core/include/spdlog/details/file_helper.h +61 -0
  388. mqt/core/include/spdlog/details/fmt_helper.h +141 -0
  389. mqt/core/include/spdlog/details/log_msg-inl.h +44 -0
  390. mqt/core/include/spdlog/details/log_msg.h +40 -0
  391. mqt/core/include/spdlog/details/log_msg_buffer-inl.h +54 -0
  392. mqt/core/include/spdlog/details/log_msg_buffer.h +32 -0
  393. mqt/core/include/spdlog/details/mpmc_blocking_q.h +177 -0
  394. mqt/core/include/spdlog/details/null_mutex.h +35 -0
  395. mqt/core/include/spdlog/details/os-inl.h +606 -0
  396. mqt/core/include/spdlog/details/os.h +127 -0
  397. mqt/core/include/spdlog/details/periodic_worker-inl.h +26 -0
  398. mqt/core/include/spdlog/details/periodic_worker.h +58 -0
  399. mqt/core/include/spdlog/details/registry-inl.h +270 -0
  400. mqt/core/include/spdlog/details/registry.h +131 -0
  401. mqt/core/include/spdlog/details/synchronous_factory.h +22 -0
  402. mqt/core/include/spdlog/details/tcp_client-windows.h +135 -0
  403. mqt/core/include/spdlog/details/tcp_client.h +127 -0
  404. mqt/core/include/spdlog/details/thread_pool-inl.h +126 -0
  405. mqt/core/include/spdlog/details/thread_pool.h +117 -0
  406. mqt/core/include/spdlog/details/udp_client-windows.h +98 -0
  407. mqt/core/include/spdlog/details/udp_client.h +81 -0
  408. mqt/core/include/spdlog/details/windows_include.h +11 -0
  409. mqt/core/include/spdlog/fmt/bin_to_hex.h +224 -0
  410. mqt/core/include/spdlog/fmt/bundled/args.h +220 -0
  411. mqt/core/include/spdlog/fmt/bundled/base.h +2989 -0
  412. mqt/core/include/spdlog/fmt/bundled/chrono.h +2330 -0
  413. mqt/core/include/spdlog/fmt/bundled/color.h +637 -0
  414. mqt/core/include/spdlog/fmt/bundled/compile.h +539 -0
  415. mqt/core/include/spdlog/fmt/bundled/core.h +5 -0
  416. mqt/core/include/spdlog/fmt/bundled/fmt.license.rst +27 -0
  417. mqt/core/include/spdlog/fmt/bundled/format-inl.h +1948 -0
  418. mqt/core/include/spdlog/fmt/bundled/format.h +4244 -0
  419. mqt/core/include/spdlog/fmt/bundled/os.h +427 -0
  420. mqt/core/include/spdlog/fmt/bundled/ostream.h +167 -0
  421. mqt/core/include/spdlog/fmt/bundled/printf.h +633 -0
  422. mqt/core/include/spdlog/fmt/bundled/ranges.h +850 -0
  423. mqt/core/include/spdlog/fmt/bundled/std.h +728 -0
  424. mqt/core/include/spdlog/fmt/bundled/xchar.h +369 -0
  425. mqt/core/include/spdlog/fmt/chrono.h +23 -0
  426. mqt/core/include/spdlog/fmt/compile.h +23 -0
  427. mqt/core/include/spdlog/fmt/fmt.h +30 -0
  428. mqt/core/include/spdlog/fmt/ostr.h +23 -0
  429. mqt/core/include/spdlog/fmt/ranges.h +23 -0
  430. mqt/core/include/spdlog/fmt/std.h +24 -0
  431. mqt/core/include/spdlog/fmt/xchar.h +23 -0
  432. mqt/core/include/spdlog/formatter.h +17 -0
  433. mqt/core/include/spdlog/fwd.h +18 -0
  434. mqt/core/include/spdlog/logger-inl.h +198 -0
  435. mqt/core/include/spdlog/logger.h +379 -0
  436. mqt/core/include/spdlog/mdc.h +52 -0
  437. mqt/core/include/spdlog/pattern_formatter-inl.h +1340 -0
  438. mqt/core/include/spdlog/pattern_formatter.h +118 -0
  439. mqt/core/include/spdlog/sinks/android_sink.h +137 -0
  440. mqt/core/include/spdlog/sinks/ansicolor_sink-inl.h +142 -0
  441. mqt/core/include/spdlog/sinks/ansicolor_sink.h +116 -0
  442. mqt/core/include/spdlog/sinks/base_sink-inl.h +59 -0
  443. mqt/core/include/spdlog/sinks/base_sink.h +51 -0
  444. mqt/core/include/spdlog/sinks/basic_file_sink-inl.h +48 -0
  445. mqt/core/include/spdlog/sinks/basic_file_sink.h +66 -0
  446. mqt/core/include/spdlog/sinks/callback_sink.h +56 -0
  447. mqt/core/include/spdlog/sinks/daily_file_sink.h +254 -0
  448. mqt/core/include/spdlog/sinks/dist_sink.h +81 -0
  449. mqt/core/include/spdlog/sinks/dup_filter_sink.h +91 -0
  450. mqt/core/include/spdlog/sinks/hourly_file_sink.h +193 -0
  451. mqt/core/include/spdlog/sinks/kafka_sink.h +119 -0
  452. mqt/core/include/spdlog/sinks/mongo_sink.h +108 -0
  453. mqt/core/include/spdlog/sinks/msvc_sink.h +68 -0
  454. mqt/core/include/spdlog/sinks/null_sink.h +41 -0
  455. mqt/core/include/spdlog/sinks/ostream_sink.h +43 -0
  456. mqt/core/include/spdlog/sinks/qt_sinks.h +304 -0
  457. mqt/core/include/spdlog/sinks/ringbuffer_sink.h +67 -0
  458. mqt/core/include/spdlog/sinks/rotating_file_sink-inl.h +179 -0
  459. mqt/core/include/spdlog/sinks/rotating_file_sink.h +93 -0
  460. mqt/core/include/spdlog/sinks/sink-inl.h +22 -0
  461. mqt/core/include/spdlog/sinks/sink.h +34 -0
  462. mqt/core/include/spdlog/sinks/stdout_color_sinks-inl.h +38 -0
  463. mqt/core/include/spdlog/sinks/stdout_color_sinks.h +49 -0
  464. mqt/core/include/spdlog/sinks/stdout_sinks-inl.h +127 -0
  465. mqt/core/include/spdlog/sinks/stdout_sinks.h +84 -0
  466. mqt/core/include/spdlog/sinks/syslog_sink.h +104 -0
  467. mqt/core/include/spdlog/sinks/systemd_sink.h +121 -0
  468. mqt/core/include/spdlog/sinks/tcp_sink.h +75 -0
  469. mqt/core/include/spdlog/sinks/udp_sink.h +69 -0
  470. mqt/core/include/spdlog/sinks/win_eventlog_sink.h +260 -0
  471. mqt/core/include/spdlog/sinks/wincolor_sink-inl.h +172 -0
  472. mqt/core/include/spdlog/sinks/wincolor_sink.h +82 -0
  473. mqt/core/include/spdlog/spdlog-inl.h +96 -0
  474. mqt/core/include/spdlog/spdlog.h +357 -0
  475. mqt/core/include/spdlog/stopwatch.h +66 -0
  476. mqt/core/include/spdlog/tweakme.h +148 -0
  477. mqt/core/include/spdlog/version.h +11 -0
  478. mqt/core/ir/__init__.pyi +2078 -0
  479. mqt/core/ir/operations.pyi +1011 -0
  480. mqt/core/ir/registers.pyi +91 -0
  481. mqt/core/ir/symbolic.pyi +177 -0
  482. mqt/core/ir.cp313t-win_amd64.pyd +0 -0
  483. mqt/core/lib/mqt-core-algorithms.lib +0 -0
  484. mqt/core/lib/mqt-core-circuit-optimizer.lib +0 -0
  485. mqt/core/lib/mqt-core-dd.lib +0 -0
  486. mqt/core/lib/mqt-core-ds.lib +0 -0
  487. mqt/core/lib/mqt-core-fomac.lib +0 -0
  488. mqt/core/lib/mqt-core-ir.lib +0 -0
  489. mqt/core/lib/mqt-core-na-fomac.lib +0 -0
  490. mqt/core/lib/mqt-core-na.lib +0 -0
  491. mqt/core/lib/mqt-core-qasm.lib +0 -0
  492. mqt/core/lib/mqt-core-qdmi-driver.lib +0 -0
  493. mqt/core/lib/mqt-core-qdmi-na-device-gen.lib +0 -0
  494. mqt/core/lib/mqt-core-qdmi-na-device.lib +0 -0
  495. mqt/core/lib/mqt-core-zx.lib +0 -0
  496. mqt/core/lib/pkgconfig/spdlog.pc +13 -0
  497. mqt/core/lib/spdlog.lib +0 -0
  498. mqt/core/na/__init__.py +12 -0
  499. mqt/core/na/fomac.cp313t-win_amd64.pyd +0 -0
  500. mqt/core/na/fomac.pyi +117 -0
  501. mqt/core/nlohmann_json.natvis +278 -0
  502. mqt/core/plugins/__init__.py +9 -0
  503. mqt/core/plugins/qiskit/__init__.py +19 -0
  504. mqt/core/plugins/qiskit/mqt_to_qiskit.py +420 -0
  505. mqt/core/plugins/qiskit/qiskit_to_mqt.py +562 -0
  506. mqt/core/py.typed +2 -0
  507. mqt/core/share/cmake/mqt-core/AddMQTPythonBinding.cmake +55 -0
  508. mqt/core/share/cmake/mqt-core/Cache.cmake +33 -0
  509. mqt/core/share/cmake/mqt-core/FindGMP.cmake +103 -0
  510. mqt/core/share/cmake/mqt-core/PackageAddTest.cmake +46 -0
  511. mqt/core/share/cmake/mqt-core/PreventInSourceBuilds.cmake +25 -0
  512. mqt/core/share/cmake/mqt-core/StandardProjectSettings.cmake +87 -0
  513. mqt/core/share/cmake/mqt-core/mqt-core-config-version.cmake +85 -0
  514. mqt/core/share/cmake/mqt-core/mqt-core-config.cmake +52 -0
  515. mqt/core/share/cmake/mqt-core/mqt-core-targets-release.cmake +141 -0
  516. mqt/core/share/cmake/mqt-core/mqt-core-targets.cmake +445 -0
  517. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake +15 -0
  518. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake +20 -0
  519. mqt/core/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake +110 -0
  520. mqt/core/share/cmake/qdmi/Cache.cmake +44 -0
  521. mqt/core/share/cmake/qdmi/PrefixHandling.cmake +78 -0
  522. mqt/core/share/cmake/qdmi/prefix_defs.txt +26 -0
  523. mqt/core/share/cmake/qdmi/qdmi-config-version.cmake +85 -0
  524. mqt/core/share/cmake/qdmi/qdmi-config.cmake +42 -0
  525. mqt/core/share/cmake/qdmi/qdmi-targets.cmake +129 -0
  526. mqt/core/share/cmake/spdlog/spdlogConfig.cmake +44 -0
  527. mqt/core/share/cmake/spdlog/spdlogConfigTargets-release.cmake +19 -0
  528. mqt/core/share/cmake/spdlog/spdlogConfigTargets.cmake +121 -0
  529. mqt/core/share/cmake/spdlog/spdlogConfigVersion.cmake +65 -0
  530. mqt/core/share/pkgconfig/nlohmann_json.pc +7 -0
  531. mqt_core-3.3.2.dist-info/DELVEWHEEL +2 -0
  532. mqt_core-3.3.2.dist-info/METADATA +210 -0
  533. mqt_core-3.3.2.dist-info/RECORD +537 -0
  534. mqt_core-3.3.2.dist-info/WHEEL +5 -0
  535. mqt_core-3.3.2.dist-info/entry_points.txt +4 -0
  536. mqt_core-3.3.2.dist-info/licenses/LICENSE.md +22 -0
  537. mqt_core.libs/msvcp140.dll +0 -0
@@ -0,0 +1,3644 @@
1
+ ///////////////////////////////////////////////////////////////////////////////
2
+ // Copyright 2011 John Maddock. Distributed under the Boost
3
+ // Software License, Version 1.0. (See accompanying file
4
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
+
6
+ #ifndef BOOST_MP_MPFR_HPP
7
+ #define BOOST_MP_MPFR_HPP
8
+
9
+ #include <boost/multiprecision/detail/standalone_config.hpp>
10
+ #include <boost/multiprecision/number.hpp>
11
+ #include <boost/multiprecision/debug_adaptor.hpp>
12
+ #include <boost/multiprecision/logged_adaptor.hpp>
13
+ #include <boost/multiprecision/gmp.hpp>
14
+ #include <boost/multiprecision/detail/digits.hpp>
15
+ #include <boost/multiprecision/detail/float128_functions.hpp>
16
+ #include <boost/multiprecision/detail/atomic.hpp>
17
+ #include <boost/multiprecision/traits/max_digits10.hpp>
18
+ #include <boost/multiprecision/detail/hash.hpp>
19
+ #include <boost/multiprecision/detail/no_exceptions_support.hpp>
20
+ #include <boost/multiprecision/detail/assert.hpp>
21
+ #include <boost/multiprecision/detail/fpclassify.hpp>
22
+ #include <mpfr.h>
23
+ #include <cmath>
24
+ #include <cstdint>
25
+ #include <algorithm>
26
+ #include <utility>
27
+ #include <type_traits>
28
+ #include <atomic>
29
+
30
+ #ifdef BOOST_MP_MATH_AVAILABLE
31
+ #include <boost/math/constants/constants.hpp>
32
+ #include <boost/math/special_functions/gamma.hpp>
33
+ #endif
34
+
35
+ #ifndef BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION
36
+ #define BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION 20
37
+ #endif
38
+
39
+ namespace boost {
40
+ namespace multiprecision {
41
+
42
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
43
+ struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public std::integral_constant<int, number_kind_floating_point>
44
+ {};
45
+
46
+ namespace backends {
47
+
48
+ namespace detail {
49
+
50
+ template <bool b>
51
+ struct mpfr_cleanup
52
+ {
53
+ //
54
+ // There are 2 seperate cleanup objects here, one calls
55
+ // mpfr_free_cache on destruction to perform global cleanup
56
+ // the other is declared thread_local and calls
57
+ // mpfr_free_cache2(MPFR_FREE_LOCAL_CACHE) to free thread local data.
58
+ //
59
+ struct initializer
60
+ {
61
+ initializer() {}
62
+ ~initializer() { mpfr_free_cache(); }
63
+ void force_instantiate() const {}
64
+ };
65
+ #if MPFR_VERSION_MAJOR >= 4
66
+ struct thread_initializer
67
+ {
68
+ thread_initializer() {}
69
+ ~thread_initializer() { mpfr_free_cache2(MPFR_FREE_LOCAL_CACHE); }
70
+ void force_instantiate() const {}
71
+ };
72
+ #endif
73
+ static const initializer init;
74
+ static void force_instantiate()
75
+ {
76
+ #if MPFR_VERSION_MAJOR >= 4
77
+ static const BOOST_MP_THREAD_LOCAL thread_initializer thread_init;
78
+ thread_init.force_instantiate();
79
+ #endif
80
+ init.force_instantiate();
81
+ }
82
+ };
83
+
84
+ template <bool b>
85
+ typename mpfr_cleanup<b>::initializer const mpfr_cleanup<b>::init;
86
+
87
+ inline void mpfr_copy_precision(mpfr_t dest, const mpfr_t src)
88
+ {
89
+ mpfr_prec_t p_dest = mpfr_get_prec(dest);
90
+ mpfr_prec_t p_src = mpfr_get_prec(src);
91
+ if (p_dest != p_src)
92
+ mpfr_set_prec(dest, p_src);
93
+ }
94
+ inline void mpfr_copy_precision(mpfr_t dest, const mpfr_t src1, const mpfr_t src2)
95
+ {
96
+ mpfr_prec_t p_dest = mpfr_get_prec(dest);
97
+ mpfr_prec_t p_src1 = mpfr_get_prec(src1);
98
+ mpfr_prec_t p_src2 = mpfr_get_prec(src2);
99
+ if (p_src2 > p_src1)
100
+ p_src1 = p_src2;
101
+ if (p_dest != p_src1)
102
+ mpfr_set_prec(dest, p_src1);
103
+ }
104
+
105
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
106
+ struct mpfr_float_imp;
107
+
108
+ template <unsigned digits10>
109
+ struct mpfr_float_imp<digits10, allocate_dynamic>
110
+ {
111
+ #ifdef BOOST_HAS_LONG_LONG
112
+ using signed_types = std::tuple<long, long long> ;
113
+ using unsigned_types = std::tuple<unsigned long, unsigned long long>;
114
+ #else
115
+ using signed_types = std::tuple<long> ;
116
+ using unsigned_types = std::tuple<unsigned long>;
117
+ #endif
118
+ using float_types = std::tuple<double, long double>;
119
+ using exponent_type = long ;
120
+
121
+ mpfr_float_imp()
122
+ {
123
+ mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision()))));
124
+ mpfr_set_ui(m_data, 0u, GMP_RNDN);
125
+ }
126
+ mpfr_float_imp(unsigned digits2)
127
+ {
128
+ mpfr_init2(m_data, digits2);
129
+ mpfr_set_ui(m_data, 0u, GMP_RNDN);
130
+ }
131
+
132
+ mpfr_float_imp(const mpfr_float_imp& o)
133
+ {
134
+ mpfr_init2(m_data, preserve_source_precision() ? mpfr_get_prec(o.data()) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
135
+ if (o.m_data[0]._mpfr_d)
136
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
137
+ }
138
+ // rvalue copy
139
+ mpfr_float_imp(mpfr_float_imp&& o) noexcept
140
+ {
141
+ mpfr_prec_t binary_default_precision = static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision()));
142
+ if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfr_get_prec(o.data()) == binary_default_precision))
143
+ {
144
+ m_data[0] = o.m_data[0];
145
+ o.m_data[0]._mpfr_d = nullptr;
146
+ }
147
+ else
148
+ {
149
+ // NOTE: C allocation interface must not throw:
150
+ mpfr_init2(m_data, binary_default_precision);
151
+ if (o.m_data[0]._mpfr_d)
152
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
153
+ }
154
+ }
155
+ mpfr_float_imp& operator=(const mpfr_float_imp& o)
156
+ {
157
+ if ((o.m_data[0]._mpfr_d) && (this != &o))
158
+ {
159
+ if (m_data[0]._mpfr_d == nullptr)
160
+ {
161
+ mpfr_init2(m_data, preserve_source_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(o.m_data)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
162
+ }
163
+ else if (preserve_source_precision() && (mpfr_get_prec(o.data()) != mpfr_get_prec(data())))
164
+ {
165
+ mpfr_set_prec(m_data, mpfr_get_prec(o.m_data));
166
+ }
167
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
168
+ }
169
+ return *this;
170
+ }
171
+ // rvalue assign
172
+ mpfr_float_imp& operator=(mpfr_float_imp&& o) noexcept
173
+ {
174
+ if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfr_get_prec(o.data()) == mpfr_get_prec(data())))
175
+ mpfr_swap(m_data, o.m_data);
176
+ else
177
+ *this = static_cast<const mpfr_float_imp&>(o);
178
+ return *this;
179
+ }
180
+ #ifdef BOOST_HAS_LONG_LONG
181
+ #ifdef _MPFR_H_HAVE_INTMAX_T
182
+ mpfr_float_imp& operator=(unsigned long long i)
183
+ {
184
+ if (m_data[0]._mpfr_d == nullptr)
185
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
186
+ mpfr_set_uj(m_data, i, GMP_RNDN);
187
+ return *this;
188
+ }
189
+ mpfr_float_imp& operator=(long long i)
190
+ {
191
+ if (m_data[0]._mpfr_d == nullptr)
192
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
193
+ mpfr_set_sj(m_data, i, GMP_RNDN);
194
+ return *this;
195
+ }
196
+ #else
197
+ mpfr_float_imp& operator=(unsigned long long i)
198
+ {
199
+ if (m_data[0]._mpfr_d == nullptr)
200
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
201
+ unsigned long long mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uLL);
202
+ unsigned shift = 0;
203
+ mpfr_t t;
204
+ mpfr_init2(t, (std::max)(static_cast<mpfr_prec_t>(std::numeric_limits<unsigned long long>::digits), static_cast<mpfr_prec_t>(mpfr_get_prec(m_data))));
205
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
206
+ while (i)
207
+ {
208
+ mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
209
+ if (shift)
210
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
211
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
212
+ shift += std::numeric_limits<unsigned long>::digits;
213
+ i >>= std::numeric_limits<unsigned long>::digits;
214
+ }
215
+ mpfr_clear(t);
216
+ return *this;
217
+ }
218
+ mpfr_float_imp& operator=(long long i)
219
+ {
220
+ if (m_data[0]._mpfr_d == nullptr)
221
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
222
+ bool neg = i < 0;
223
+ *this = boost::multiprecision::detail::unsigned_abs(i);
224
+ if (neg)
225
+ mpfr_neg(m_data, m_data, GMP_RNDN);
226
+ return *this;
227
+ }
228
+ #endif
229
+ #endif
230
+ #ifdef BOOST_HAS_INT128
231
+ mpfr_float_imp& operator=(uint128_type i)
232
+ {
233
+ if (m_data[0]._mpfr_d == nullptr)
234
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
235
+ unsigned long long mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uLL);
236
+ unsigned shift = 0;
237
+ mpfr_t t;
238
+ mpfr_init2(t, (std::max)(static_cast<mpfr_prec_t>(std::numeric_limits<unsigned long long>::digits), static_cast<mpfr_prec_t>(mpfr_get_prec(m_data))));
239
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
240
+ while (i)
241
+ {
242
+ mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
243
+ if (shift)
244
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
245
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
246
+ shift += std::numeric_limits<unsigned long>::digits;
247
+ i >>= std::numeric_limits<unsigned long>::digits;
248
+ }
249
+ mpfr_clear(t);
250
+ return *this;
251
+ }
252
+ mpfr_float_imp& operator=(int128_type i)
253
+ {
254
+ if (m_data[0]._mpfr_d == nullptr)
255
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
256
+ bool neg = i < 0;
257
+ *this = boost::multiprecision::detail::unsigned_abs(i);
258
+ if (neg)
259
+ mpfr_neg(m_data, m_data, GMP_RNDN);
260
+ return *this;
261
+ }
262
+ #endif
263
+ mpfr_float_imp& operator=(unsigned long i)
264
+ {
265
+ if (m_data[0]._mpfr_d == nullptr)
266
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
267
+ mpfr_set_ui(m_data, i, GMP_RNDN);
268
+ return *this;
269
+ }
270
+ mpfr_float_imp& operator=(long i)
271
+ {
272
+ if (m_data[0]._mpfr_d == nullptr)
273
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
274
+ mpfr_set_si(m_data, i, GMP_RNDN);
275
+ return *this;
276
+ }
277
+ mpfr_float_imp& operator=(double d)
278
+ {
279
+ if (m_data[0]._mpfr_d == nullptr)
280
+ mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision()))));
281
+ mpfr_set_d(m_data, d, GMP_RNDN);
282
+ return *this;
283
+ }
284
+ mpfr_float_imp& operator=(long double a)
285
+ {
286
+ if (m_data[0]._mpfr_d == nullptr)
287
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
288
+ mpfr_set_ld(m_data, a, GMP_RNDN);
289
+ return *this;
290
+ }
291
+ #ifdef BOOST_HAS_FLOAT128
292
+ mpfr_float_imp& operator=(float128_type a)
293
+ {
294
+ BOOST_MP_FLOAT128_USING
295
+ if (m_data[0]._mpfr_d == nullptr)
296
+ mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
297
+
298
+ if (a == 0)
299
+ {
300
+ mpfr_set_si(m_data, 0, GMP_RNDN);
301
+ return *this;
302
+ }
303
+
304
+ if (a == 1)
305
+ {
306
+ mpfr_set_si(m_data, 1, GMP_RNDN);
307
+ return *this;
308
+ }
309
+
310
+ if (BOOST_MP_ISINF(a))
311
+ {
312
+ mpfr_set_inf(m_data, a < 0 ? -1 : 1);
313
+ return *this;
314
+ }
315
+ if (BOOST_MP_ISNAN(a))
316
+ {
317
+ mpfr_set_nan(m_data);
318
+ return *this;
319
+ }
320
+
321
+ int e;
322
+ float128_type f, term;
323
+ mpfr_set_ui(m_data, 0u, GMP_RNDN);
324
+
325
+ f = frexp(a, &e);
326
+
327
+ constexpr const int shift = std::numeric_limits<int>::digits - 1;
328
+
329
+ while (f)
330
+ {
331
+ // extract int sized bits from f:
332
+ f = ldexp(f, shift);
333
+ term = floor(f);
334
+ e -= shift;
335
+ mpfr_mul_2exp(m_data, m_data, shift, GMP_RNDN);
336
+ if (term > 0)
337
+ mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), GMP_RNDN);
338
+ else
339
+ mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), GMP_RNDN);
340
+ f -= term;
341
+ }
342
+ if (e > 0)
343
+ mpfr_mul_2exp(m_data, m_data, e, GMP_RNDN);
344
+ else if (e < 0)
345
+ mpfr_div_2exp(m_data, m_data, -e, GMP_RNDN);
346
+ return *this;
347
+ }
348
+ #endif
349
+ mpfr_float_imp& operator=(const char* s)
350
+ {
351
+ if (m_data[0]._mpfr_d == nullptr)
352
+ mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision()))));
353
+ if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
354
+ {
355
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
356
+ }
357
+ return *this;
358
+ }
359
+ void swap(mpfr_float_imp& o) noexcept
360
+ {
361
+ mpfr_swap(m_data, o.m_data);
362
+ }
363
+ std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
364
+ {
365
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
366
+
367
+ bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
368
+ bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
369
+
370
+ std::streamsize org_digits(digits);
371
+
372
+ if (scientific && digits)
373
+ ++digits;
374
+
375
+ std::string result;
376
+ mp_exp_t e;
377
+ if (mpfr_inf_p(m_data))
378
+ {
379
+ if (mpfr_sgn(m_data) < 0)
380
+ result = "-inf";
381
+ else if (f & std::ios_base::showpos)
382
+ result = "+inf";
383
+ else
384
+ result = "inf";
385
+ return result;
386
+ }
387
+ if (mpfr_nan_p(m_data))
388
+ {
389
+ result = "nan";
390
+ return result;
391
+ }
392
+ if (mpfr_zero_p(m_data))
393
+ {
394
+ e = 0;
395
+ if (mpfr_signbit(m_data))
396
+ result = "-0";
397
+ else
398
+ result = "0";
399
+ }
400
+ else if (fixed)
401
+ {
402
+ // We actually need a different number of digits to what one might expect:
403
+ char* ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
404
+ --e;
405
+ mpfr_free_str(ps);
406
+ digits += e + 1;
407
+ if (digits == 0)
408
+ {
409
+ // We need to get *all* the digits and then possibly round up,
410
+ // we end up with either "0" or "1" as the result.
411
+ ps = mpfr_get_str(nullptr, &e, 10, 0, m_data, GMP_RNDN);
412
+ --e;
413
+ unsigned offset = *ps == '-' ? 1 : 0;
414
+ if (ps[offset] > '5')
415
+ {
416
+ ++e;
417
+ ps[offset] = '1';
418
+ ps[offset + 1] = 0;
419
+ }
420
+ else if (ps[offset] == '5')
421
+ {
422
+ unsigned i = offset + 1;
423
+ bool round_up = false;
424
+ while (ps[i] != 0)
425
+ {
426
+ if (ps[i] != '0')
427
+ {
428
+ round_up = true;
429
+ break;
430
+ }
431
+ ++i;
432
+ }
433
+ if (round_up)
434
+ {
435
+ ++e;
436
+ ps[offset] = '1';
437
+ ps[offset + 1] = 0;
438
+ }
439
+ else
440
+ {
441
+ ps[offset] = '0';
442
+ ps[offset + 1] = 0;
443
+ }
444
+ }
445
+ else
446
+ {
447
+ ps[offset] = '0';
448
+ ps[offset + 1] = 0;
449
+ }
450
+ }
451
+ else if (digits > 0)
452
+ {
453
+ mp_exp_t old_e = e;
454
+ ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
455
+ --e; // To match with what our formatter expects.
456
+ if (old_e > e)
457
+ {
458
+ // in some cases, when we ask for more digits of precision, it will
459
+ // change the number of digits to the left of the decimal, if that
460
+ // happens, account for it here.
461
+ // example: cout << fixed << setprecision(3) << mpf_float_50("99.9809")
462
+ mpfr_free_str(ps);
463
+ digits -= old_e - e;
464
+ ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
465
+ --e; // To match with what our formatter expects.
466
+ }
467
+ }
468
+ else
469
+ {
470
+ ps = mpfr_get_str(nullptr, &e, 10, 1, m_data, GMP_RNDN);
471
+ --e;
472
+ unsigned offset = *ps == '-' ? 1 : 0;
473
+ ps[offset] = '0';
474
+ ps[offset + 1] = 0;
475
+ }
476
+ result = ps ? ps : "0";
477
+ if (ps)
478
+ mpfr_free_str(ps);
479
+ }
480
+ else
481
+ {
482
+ char* ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
483
+ --e; // To match with what our formatter expects.
484
+ result = ps ? ps : "0";
485
+ if (ps)
486
+ mpfr_free_str(ps);
487
+ }
488
+ boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
489
+ return result;
490
+ }
491
+ ~mpfr_float_imp() noexcept
492
+ {
493
+ if (m_data[0]._mpfr_d)
494
+ mpfr_clear(m_data);
495
+ detail::mpfr_cleanup<true>::force_instantiate();
496
+ }
497
+ void negate() noexcept
498
+ {
499
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
500
+ mpfr_neg(m_data, m_data, GMP_RNDN);
501
+ }
502
+ template <mpfr_allocation_type AllocationType>
503
+ int compare(const mpfr_float_backend<digits10, AllocationType>& o) const
504
+ {
505
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d && o.m_data[0]._mpfr_d);
506
+ return mpfr_cmp(m_data, o.m_data);
507
+ }
508
+ int compare(long i) const
509
+ {
510
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
511
+ return mpfr_cmp_si(m_data, i);
512
+ }
513
+ int compare(double i) const
514
+ {
515
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
516
+ return mpfr_cmp_d(m_data, i);
517
+ }
518
+ int compare(long double i) const
519
+ {
520
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
521
+ return mpfr_cmp_ld(m_data, i);
522
+ }
523
+ int compare(unsigned long i) const
524
+ {
525
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
526
+ return mpfr_cmp_ui(m_data, i);
527
+ }
528
+ template <class V>
529
+ int compare(V v) const
530
+ {
531
+ mpfr_float_backend<digits10, allocate_dynamic> d(0uL, mpfr_get_prec(m_data));
532
+ d = v;
533
+ return compare(d);
534
+ }
535
+ mpfr_t& data() noexcept
536
+ {
537
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
538
+ return m_data;
539
+ }
540
+ const mpfr_t& data() const noexcept
541
+ {
542
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
543
+ return m_data;
544
+ }
545
+
546
+ protected:
547
+ mpfr_t m_data;
548
+ static boost::multiprecision::detail::precision_type& get_global_default_precision() noexcept
549
+ {
550
+ static boost::multiprecision::detail::precision_type val(BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION);
551
+ return val;
552
+ }
553
+ static unsigned& get_default_precision() noexcept
554
+ {
555
+ static BOOST_MP_THREAD_LOCAL unsigned val(get_global_default_precision());
556
+ return val;
557
+ }
558
+ #ifndef BOOST_MT_NO_ATOMIC_INT
559
+ static std::atomic<variable_precision_options>& get_global_default_options() noexcept
560
+ {
561
+ static std::atomic<variable_precision_options> val{variable_precision_options::preserve_related_precision};
562
+ return val;
563
+ }
564
+ #else
565
+ static variable_precision_options& get_global_default_options() noexcept
566
+ {
567
+ static variable_precision_options val{variable_precision_options::preserve_related_precision};
568
+ return val;
569
+ }
570
+ #endif
571
+ static variable_precision_options& get_default_options()noexcept
572
+ {
573
+ static BOOST_MP_THREAD_LOCAL variable_precision_options val(get_global_default_options());
574
+ return val;
575
+ }
576
+ static bool preserve_source_precision() noexcept
577
+ {
578
+ return get_default_options() >= variable_precision_options::preserve_source_precision;
579
+ }
580
+ };
581
+
582
+ #ifdef BOOST_MSVC
583
+ #pragma warning(push)
584
+ #pragma warning(disable : 4127) // Conditional expression is constant
585
+ #endif
586
+
587
+ template <unsigned digits10>
588
+ struct mpfr_float_imp<digits10, allocate_stack>
589
+ {
590
+ #ifdef BOOST_HAS_LONG_LONG
591
+ using signed_types = std::tuple<long, long long> ;
592
+ using unsigned_types = std::tuple<unsigned long, unsigned long long>;
593
+ #else
594
+ using signed_types = std::tuple<long> ;
595
+ using unsigned_types = std::tuple<unsigned long>;
596
+ #endif
597
+ using float_types = std::tuple<double, long double>;
598
+ using exponent_type = long ;
599
+
600
+ static constexpr const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
601
+ static constexpr const unsigned limb_count = mpfr_custom_get_size(digits2) / sizeof(mp_limb_t);
602
+
603
+ ~mpfr_float_imp() noexcept
604
+ {
605
+ detail::mpfr_cleanup<true>::force_instantiate();
606
+ }
607
+ mpfr_float_imp()
608
+ {
609
+ mpfr_custom_init(m_buffer, digits2);
610
+ mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
611
+ mpfr_set_ui(m_data, 0u, GMP_RNDN);
612
+ }
613
+
614
+ mpfr_float_imp(const mpfr_float_imp& o)
615
+ {
616
+ mpfr_custom_init(m_buffer, digits2);
617
+ mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
618
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
619
+ }
620
+ mpfr_float_imp& operator=(const mpfr_float_imp& o)
621
+ {
622
+ mpfr_set(m_data, o.m_data, GMP_RNDN);
623
+ return *this;
624
+ }
625
+ #ifdef BOOST_HAS_LONG_LONG
626
+ #ifdef _MPFR_H_HAVE_INTMAX_T
627
+ mpfr_float_imp& operator=(unsigned long long i)
628
+ {
629
+ mpfr_set_uj(m_data, i, GMP_RNDN);
630
+ return *this;
631
+ }
632
+ mpfr_float_imp& operator=(long long i)
633
+ {
634
+ mpfr_set_sj(m_data, i, GMP_RNDN);
635
+ return *this;
636
+ }
637
+ #else
638
+ mpfr_float_imp& operator=(unsigned long long i)
639
+ {
640
+ unsigned long long mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uL);
641
+ unsigned shift = 0;
642
+ mpfr_t t;
643
+ mp_limb_t t_limbs[limb_count];
644
+ mpfr_custom_init(t_limbs, digits2);
645
+ mpfr_custom_init_set(t, MPFR_NAN_KIND, 0, digits2, t_limbs);
646
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
647
+ while (i)
648
+ {
649
+ mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
650
+ if (shift)
651
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
652
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
653
+ shift += std::numeric_limits<unsigned long>::digits;
654
+ i >>= std::numeric_limits<unsigned long>::digits;
655
+ }
656
+ return *this;
657
+ }
658
+ mpfr_float_imp& operator=(long long i)
659
+ {
660
+ bool neg = i < 0;
661
+ *this = boost::multiprecision::detail::unsigned_abs(i);
662
+ if (neg)
663
+ mpfr_neg(m_data, m_data, GMP_RNDN);
664
+ return *this;
665
+ }
666
+ #endif
667
+ #endif
668
+ #ifdef BOOST_HAS_INT128
669
+ mpfr_float_imp& operator=(uint128_type i)
670
+ {
671
+ unsigned long long mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uL);
672
+ unsigned shift = 0;
673
+ mpfr_t t;
674
+ mp_limb_t t_limbs[limb_count];
675
+ mpfr_custom_init(t_limbs, digits2);
676
+ mpfr_custom_init_set(t, MPFR_NAN_KIND, 0, digits2, t_limbs);
677
+ mpfr_set_ui(m_data, 0, GMP_RNDN);
678
+ while (i)
679
+ {
680
+ mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
681
+ if (shift)
682
+ mpfr_mul_2exp(t, t, shift, GMP_RNDN);
683
+ mpfr_add(m_data, m_data, t, GMP_RNDN);
684
+ shift += std::numeric_limits<unsigned long>::digits;
685
+ i >>= std::numeric_limits<unsigned long>::digits;
686
+ }
687
+ return *this;
688
+ }
689
+ mpfr_float_imp& operator=(int128_type i)
690
+ {
691
+ bool neg = i < 0;
692
+ *this = boost::multiprecision::detail::unsigned_abs(i);
693
+ if (neg)
694
+ mpfr_neg(m_data, m_data, GMP_RNDN);
695
+ return *this;
696
+ }
697
+ #endif
698
+ mpfr_float_imp& operator=(unsigned long i)
699
+ {
700
+ mpfr_set_ui(m_data, i, GMP_RNDN);
701
+ return *this;
702
+ }
703
+ mpfr_float_imp& operator=(long i)
704
+ {
705
+ mpfr_set_si(m_data, i, GMP_RNDN);
706
+ return *this;
707
+ }
708
+ mpfr_float_imp& operator=(double d)
709
+ {
710
+ mpfr_set_d(m_data, d, GMP_RNDN);
711
+ return *this;
712
+ }
713
+ mpfr_float_imp& operator=(long double a)
714
+ {
715
+ mpfr_set_ld(m_data, a, GMP_RNDN);
716
+ return *this;
717
+ }
718
+ #ifdef BOOST_HAS_FLOAT128
719
+ mpfr_float_imp& operator=(float128_type a)
720
+ {
721
+ BOOST_MP_FLOAT128_USING
722
+ if (a == 0)
723
+ {
724
+ mpfr_set_si(m_data, 0, GMP_RNDN);
725
+ return *this;
726
+ }
727
+
728
+ if (a == 1)
729
+ {
730
+ mpfr_set_si(m_data, 1, GMP_RNDN);
731
+ return *this;
732
+ }
733
+
734
+ if (BOOST_MP_ISINF(a))
735
+ {
736
+ mpfr_set_inf(m_data, a < 0 ? -1 : 1);
737
+ return *this;
738
+ }
739
+ if (BOOST_MP_ISNAN(a))
740
+ {
741
+ mpfr_set_nan(m_data);
742
+ return *this;
743
+ }
744
+
745
+ int e;
746
+ float128_type f, term;
747
+ mpfr_set_ui(m_data, 0u, GMP_RNDN);
748
+
749
+ f = frexp(a, &e);
750
+
751
+ constexpr const int shift = std::numeric_limits<int>::digits - 1;
752
+
753
+ while (f)
754
+ {
755
+ // extract int sized bits from f:
756
+ f = ldexp(f, shift);
757
+ term = floor(f);
758
+ e -= shift;
759
+ mpfr_mul_2exp(m_data, m_data, shift, GMP_RNDN);
760
+ if (term > 0)
761
+ mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), GMP_RNDN);
762
+ else
763
+ mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), GMP_RNDN);
764
+ f -= term;
765
+ }
766
+ if (e > 0)
767
+ mpfr_mul_2exp(m_data, m_data, e, GMP_RNDN);
768
+ else if (e < 0)
769
+ mpfr_div_2exp(m_data, m_data, -e, GMP_RNDN);
770
+ return *this;
771
+ }
772
+ #endif
773
+ mpfr_float_imp& operator=(const char* s)
774
+ {
775
+ if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
776
+ {
777
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
778
+ }
779
+ return *this;
780
+ }
781
+ void swap(mpfr_float_imp& o) noexcept
782
+ {
783
+ // We have to swap by copying:
784
+ mpfr_float_imp t(*this);
785
+ *this = o;
786
+ o = t;
787
+ }
788
+ std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
789
+ {
790
+ BOOST_MP_ASSERT(m_data[0]._mpfr_d);
791
+
792
+ bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
793
+ bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
794
+
795
+ std::streamsize org_digits(digits);
796
+
797
+ if (scientific && digits)
798
+ ++digits;
799
+
800
+ std::string result;
801
+ mp_exp_t e;
802
+ if (mpfr_inf_p(m_data))
803
+ {
804
+ if (mpfr_sgn(m_data) < 0)
805
+ result = "-inf";
806
+ else if (f & std::ios_base::showpos)
807
+ result = "+inf";
808
+ else
809
+ result = "inf";
810
+ return result;
811
+ }
812
+ if (mpfr_nan_p(m_data))
813
+ {
814
+ result = "nan";
815
+ return result;
816
+ }
817
+ if (mpfr_zero_p(m_data))
818
+ {
819
+ e = 0;
820
+ result = "0";
821
+ }
822
+ else
823
+ {
824
+ char* ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
825
+ --e; // To match with what our formatter expects.
826
+ if (fixed && e != -1)
827
+ {
828
+ // Oops we actually need a different number of digits to what we asked for:
829
+ mpfr_free_str(ps);
830
+ digits += e + 1;
831
+ if (digits == 0)
832
+ {
833
+ // We need to get *all* the digits and then possibly round up,
834
+ // we end up with either "0" or "1" as the result.
835
+ ps = mpfr_get_str(nullptr, &e, 10, 0, m_data, GMP_RNDN);
836
+ --e;
837
+ unsigned offset = *ps == '-' ? 1 : 0;
838
+ if (ps[offset] > '5')
839
+ {
840
+ ++e;
841
+ ps[offset] = '1';
842
+ ps[offset + 1] = 0;
843
+ }
844
+ else if (ps[offset] == '5')
845
+ {
846
+ unsigned i = offset + 1;
847
+ bool round_up = false;
848
+ while (ps[i] != 0)
849
+ {
850
+ if (ps[i] != '0')
851
+ {
852
+ round_up = true;
853
+ break;
854
+ }
855
+ }
856
+ if (round_up)
857
+ {
858
+ ++e;
859
+ ps[offset] = '1';
860
+ ps[offset + 1] = 0;
861
+ }
862
+ else
863
+ {
864
+ ps[offset] = '0';
865
+ ps[offset + 1] = 0;
866
+ }
867
+ }
868
+ else
869
+ {
870
+ ps[offset] = '0';
871
+ ps[offset + 1] = 0;
872
+ }
873
+ }
874
+ else if (digits > 0)
875
+ {
876
+ ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
877
+ --e; // To match with what our formatter expects.
878
+ }
879
+ else
880
+ {
881
+ ps = mpfr_get_str(nullptr, &e, 10, 1, m_data, GMP_RNDN);
882
+ --e;
883
+ unsigned offset = *ps == '-' ? 1 : 0;
884
+ ps[offset] = '0';
885
+ ps[offset + 1] = 0;
886
+ }
887
+ }
888
+ result = ps ? ps : "0";
889
+ if (ps)
890
+ mpfr_free_str(ps);
891
+ }
892
+ boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
893
+ return result;
894
+ }
895
+ void negate() noexcept
896
+ {
897
+ mpfr_neg(m_data, m_data, GMP_RNDN);
898
+ }
899
+ template <mpfr_allocation_type AllocationType>
900
+ int compare(const mpfr_float_backend<digits10, AllocationType>& o) const
901
+ {
902
+ return mpfr_cmp(m_data, o.m_data);
903
+ }
904
+ int compare(long i) const
905
+ {
906
+ return mpfr_cmp_si(m_data, i);
907
+ }
908
+ int compare(unsigned long i) const
909
+ {
910
+ return mpfr_cmp_ui(m_data, i);
911
+ }
912
+ int compare(double i) const
913
+ {
914
+ return mpfr_cmp_d(m_data, i);
915
+ }
916
+ int compare(long double i) const
917
+ {
918
+ return mpfr_cmp_ld(m_data, i);
919
+ }
920
+ template <class V>
921
+ int compare(V v) const
922
+ {
923
+ mpfr_float_backend<digits10, allocate_stack> d;
924
+ d = v;
925
+ return compare(d);
926
+ }
927
+ mpfr_t& data() noexcept
928
+ {
929
+ return m_data;
930
+ }
931
+ const mpfr_t& data() const noexcept
932
+ {
933
+ return m_data;
934
+ }
935
+
936
+ protected:
937
+ mpfr_t m_data;
938
+ mp_limb_t m_buffer[limb_count];
939
+ };
940
+
941
+ #ifdef BOOST_MSVC
942
+ #pragma warning(pop)
943
+ #endif
944
+
945
+ } // namespace detail
946
+
947
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
948
+ struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationType>
949
+ {
950
+ mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {}
951
+ mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {}
952
+ // rvalue copy
953
+ mpfr_float_backend(mpfr_float_backend&& o) noexcept : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o))
954
+ {}
955
+ template <unsigned D, mpfr_allocation_type AT>
956
+ mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
957
+ : detail::mpfr_float_imp<digits10, AllocationType>()
958
+ {
959
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
960
+ }
961
+ template <unsigned D, mpfr_allocation_type AT>
962
+ explicit mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename std::enable_if<!(D <= digits10)>::type* = nullptr)
963
+ : detail::mpfr_float_imp<digits10, AllocationType>()
964
+ {
965
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
966
+ }
967
+ template <unsigned D>
968
+ mpfr_float_backend(const gmp_float<D>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
969
+ : detail::mpfr_float_imp<digits10, AllocationType>()
970
+ {
971
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
972
+ }
973
+ template <unsigned D>
974
+ mpfr_float_backend(const gmp_float<D>& val, typename std::enable_if<!(D <= digits10)>::type* = nullptr)
975
+ : detail::mpfr_float_imp<digits10, AllocationType>()
976
+ {
977
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
978
+ }
979
+ mpfr_float_backend(const gmp_int& val)
980
+ : detail::mpfr_float_imp<digits10, AllocationType>()
981
+ {
982
+ mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
983
+ }
984
+ mpfr_float_backend(const gmp_rational& val)
985
+ : detail::mpfr_float_imp<digits10, AllocationType>()
986
+ {
987
+ mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
988
+ }
989
+ mpfr_float_backend(const mpfr_t val)
990
+ : detail::mpfr_float_imp<digits10, AllocationType>()
991
+ {
992
+ mpfr_set(this->m_data, val, GMP_RNDN);
993
+ }
994
+ mpfr_float_backend(const mpf_t val)
995
+ : detail::mpfr_float_imp<digits10, AllocationType>()
996
+ {
997
+ mpfr_set_f(this->m_data, val, GMP_RNDN);
998
+ }
999
+ mpfr_float_backend(const mpz_t val)
1000
+ : detail::mpfr_float_imp<digits10, AllocationType>()
1001
+ {
1002
+ mpfr_set_z(this->m_data, val, GMP_RNDN);
1003
+ }
1004
+ mpfr_float_backend(const mpq_t val)
1005
+ : detail::mpfr_float_imp<digits10, AllocationType>()
1006
+ {
1007
+ mpfr_set_q(this->m_data, val, GMP_RNDN);
1008
+ }
1009
+ // Construction with precision: we ignore the precision here.
1010
+ template <class V>
1011
+ mpfr_float_backend(const V& o, unsigned)
1012
+ {
1013
+ *this = o;
1014
+ }
1015
+ mpfr_float_backend& operator=(const mpfr_float_backend& o)
1016
+ {
1017
+ *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType> const&>(o);
1018
+ return *this;
1019
+ }
1020
+ // rvalue assign
1021
+ mpfr_float_backend& operator=(mpfr_float_backend&& o) noexcept
1022
+ {
1023
+ *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o);
1024
+ return *this;
1025
+ }
1026
+ template <class V>
1027
+ typename std::enable_if<std::is_assignable<detail::mpfr_float_imp<digits10, AllocationType>, V>::value, mpfr_float_backend&>::type operator=(const V& v)
1028
+ {
1029
+ *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = v;
1030
+ return *this;
1031
+ }
1032
+ mpfr_float_backend& operator=(const mpfr_t val)
1033
+ {
1034
+ if (this->m_data[0]._mpfr_d == nullptr)
1035
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1036
+ mpfr_set(this->m_data, val, GMP_RNDN);
1037
+ return *this;
1038
+ }
1039
+ mpfr_float_backend& operator=(const mpf_t val)
1040
+ {
1041
+ if (this->m_data[0]._mpfr_d == nullptr)
1042
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1043
+ mpfr_set_f(this->m_data, val, GMP_RNDN);
1044
+ return *this;
1045
+ }
1046
+ mpfr_float_backend& operator=(const mpz_t val)
1047
+ {
1048
+ if (this->m_data[0]._mpfr_d == nullptr)
1049
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1050
+ mpfr_set_z(this->m_data, val, GMP_RNDN);
1051
+ return *this;
1052
+ }
1053
+ mpfr_float_backend& operator=(const mpq_t val)
1054
+ {
1055
+ if (this->m_data[0]._mpfr_d == nullptr)
1056
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1057
+ mpfr_set_q(this->m_data, val, GMP_RNDN);
1058
+ return *this;
1059
+ }
1060
+ // We don't change our precision here, this is a fixed precision type:
1061
+ template <unsigned D, mpfr_allocation_type AT>
1062
+ mpfr_float_backend& operator=(const mpfr_float_backend<D, AT>& val)
1063
+ {
1064
+ if (this->m_data[0]._mpfr_d == nullptr)
1065
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1066
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
1067
+ return *this;
1068
+ }
1069
+ template <unsigned D>
1070
+ mpfr_float_backend& operator=(const gmp_float<D>& val)
1071
+ {
1072
+ if (this->m_data[0]._mpfr_d == nullptr)
1073
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1074
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
1075
+ return *this;
1076
+ }
1077
+ mpfr_float_backend& operator=(const gmp_int& val)
1078
+ {
1079
+ if (this->m_data[0]._mpfr_d == nullptr)
1080
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1081
+ mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
1082
+ return *this;
1083
+ }
1084
+ mpfr_float_backend& operator=(const gmp_rational& val)
1085
+ {
1086
+ if (this->m_data[0]._mpfr_d == nullptr)
1087
+ mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
1088
+ mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
1089
+ return *this;
1090
+ }
1091
+ };
1092
+
1093
+ template <>
1094
+ struct mpfr_float_backend<0, allocate_dynamic> : public detail::mpfr_float_imp<0, allocate_dynamic>
1095
+ {
1096
+ mpfr_float_backend() : detail::mpfr_float_imp<0, allocate_dynamic>() {}
1097
+ mpfr_float_backend(const mpfr_t val)
1098
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(mpfr_get_prec(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
1099
+ {
1100
+ mpfr_set(this->m_data, val, GMP_RNDN);
1101
+ }
1102
+ mpfr_float_backend(const mpf_t val)
1103
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(mpf_get_prec(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
1104
+ {
1105
+ mpfr_set_f(this->m_data, val, GMP_RNDN);
1106
+ }
1107
+ mpfr_float_backend(const mpz_t val)
1108
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
1109
+ {
1110
+ mpfr_set_z(this->m_data, val, GMP_RNDN);
1111
+ }
1112
+ mpfr_float_backend(const mpq_t val)
1113
+ : detail::mpfr_float_imp<0, allocate_dynamic>()
1114
+ {
1115
+ mpfr_set_q(this->m_data, val, GMP_RNDN);
1116
+ }
1117
+ mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0, allocate_dynamic>(o) {}
1118
+ // rvalue copy
1119
+ mpfr_float_backend(mpfr_float_backend&& o) noexcept : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<detail::mpfr_float_imp<0, allocate_dynamic>&&>(o))
1120
+ {}
1121
+ template <class V>
1122
+ mpfr_float_backend(const V& o, unsigned digits10)
1123
+ : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<unsigned>(multiprecision::detail::digits10_2_2(digits10)))
1124
+ {
1125
+ *this = o;
1126
+ }
1127
+ #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
1128
+ mpfr_float_backend(const std::string_view& o, unsigned digits10)
1129
+ : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<unsigned>(multiprecision::detail::digits10_2_2(digits10)))
1130
+ {
1131
+ std::string s(o);
1132
+ *this = s.c_str();
1133
+ }
1134
+ #endif
1135
+ template <unsigned D>
1136
+ mpfr_float_backend(const gmp_float<D>& val, unsigned digits10)
1137
+ : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<unsigned>(multiprecision::detail::digits10_2_2(digits10)))
1138
+ {
1139
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
1140
+ }
1141
+ template <unsigned D>
1142
+ mpfr_float_backend(const mpfr_float_backend<D>& val, unsigned digits10)
1143
+ : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<unsigned>(multiprecision::detail::digits10_2_2(digits10)))
1144
+ {
1145
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
1146
+ }
1147
+ template <unsigned D>
1148
+ mpfr_float_backend(const mpfr_float_backend<D>& val)
1149
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_related_precision() ? static_cast<unsigned>(mpfr_get_prec(val.data())) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
1150
+ {
1151
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
1152
+ }
1153
+ template <unsigned D>
1154
+ mpfr_float_backend(const gmp_float<D>& val)
1155
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(mpf_get_prec(val.data())) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
1156
+ {
1157
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
1158
+ }
1159
+ mpfr_float_backend(const gmp_int& val)
1160
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(used_gmp_int_bits(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(thread_default_precision())))
1161
+ {
1162
+ mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
1163
+ }
1164
+ mpfr_float_backend(const gmp_rational& val)
1165
+ : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(used_gmp_rational_bits(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(thread_default_precision())))
1166
+ {
1167
+ mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
1168
+ }
1169
+
1170
+ mpfr_float_backend& operator=(const mpfr_float_backend& o) = default;
1171
+ // rvalue assign
1172
+ mpfr_float_backend& operator=(mpfr_float_backend&& o) noexcept = default;
1173
+
1174
+ template <class V>
1175
+ typename std::enable_if<std::is_assignable<detail::mpfr_float_imp<0, allocate_dynamic>, V>::value, mpfr_float_backend&>::type operator=(const V& v)
1176
+ {
1177
+ constexpr unsigned d10 = std::is_floating_point<V>::value ?
1178
+ std::numeric_limits<V>::digits10 :
1179
+ std::numeric_limits<V>::digits10 ? 1 + std::numeric_limits<V>::digits10 :
1180
+ 1 + boost::multiprecision::detail::digits2_2_10(std::numeric_limits<V>::digits);
1181
+
1182
+ if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
1183
+ {
1184
+ BOOST_IF_CONSTEXPR(std::is_floating_point<V>::value)
1185
+ {
1186
+ if (std::numeric_limits<V>::digits > mpfr_get_prec(this->data()))
1187
+ mpfr_set_prec(this->data(), std::numeric_limits<V>::digits);
1188
+ }
1189
+ else
1190
+ {
1191
+ if(precision() < d10)
1192
+ this->precision(d10);
1193
+ }
1194
+ }
1195
+
1196
+ *static_cast<detail::mpfr_float_imp<0, allocate_dynamic>*>(this) = v;
1197
+ return *this;
1198
+ }
1199
+ mpfr_float_backend& operator=(const mpfr_t val)
1200
+ {
1201
+ if (this->m_data[0]._mpfr_d == nullptr)
1202
+ mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(val)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
1203
+ else if(preserve_all_precision())
1204
+ mpfr_set_prec(this->m_data, mpfr_get_prec(val));
1205
+ mpfr_set(this->m_data, val, GMP_RNDN);
1206
+ return *this;
1207
+ }
1208
+ mpfr_float_backend& operator=(const mpf_t val)
1209
+ {
1210
+ if (this->m_data[0]._mpfr_d == nullptr)
1211
+ mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpf_get_prec(val)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
1212
+ else if(preserve_all_precision())
1213
+ mpfr_set_prec(this->m_data, static_cast<mpfr_prec_t>(mpf_get_prec(val)));
1214
+ mpfr_set_f(this->m_data, val, GMP_RNDN);
1215
+ return *this;
1216
+ }
1217
+ mpfr_float_backend& operator=(const mpz_t val)
1218
+ {
1219
+ if (this->m_data[0]._mpfr_d == nullptr)
1220
+ mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(get_default_precision())));
1221
+ mpfr_set_z(this->m_data, val, GMP_RNDN);
1222
+ return *this;
1223
+ }
1224
+ mpfr_float_backend& operator=(const mpq_t val)
1225
+ {
1226
+ if (this->m_data[0]._mpfr_d == nullptr)
1227
+ mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(get_default_precision())));
1228
+ mpfr_set_q(this->m_data, val, GMP_RNDN);
1229
+ return *this;
1230
+ }
1231
+ template <unsigned D>
1232
+ mpfr_float_backend& operator=(const mpfr_float_backend<D>& val)
1233
+ {
1234
+ if (this->m_data[0]._mpfr_d == nullptr)
1235
+ mpfr_init2(this->m_data, preserve_related_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(val.data())) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
1236
+ else if (preserve_related_precision())
1237
+ mpfr_set_prec(this->m_data, mpfr_get_prec(val.data()));
1238
+ mpfr_set(this->m_data, val.data(), GMP_RNDN);
1239
+ return *this;
1240
+ }
1241
+ template <unsigned D>
1242
+ mpfr_float_backend& operator=(const gmp_float<D>& val)
1243
+ {
1244
+ if (this->m_data[0]._mpfr_d == nullptr)
1245
+ mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpf_get_prec(val.data())) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
1246
+ else if (preserve_all_precision())
1247
+ mpfr_set_prec(this->m_data, static_cast<mpfr_prec_t>(mpf_get_prec(val.data())));
1248
+ mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
1249
+ return *this;
1250
+ }
1251
+ mpfr_float_backend& operator=(const gmp_int& val)
1252
+ {
1253
+ if (this->m_data[0]._mpfr_d == nullptr)
1254
+ {
1255
+ unsigned requested_precision = this->thread_default_precision();
1256
+ if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
1257
+ {
1258
+ unsigned d2 = static_cast<unsigned>(used_gmp_int_bits(val));
1259
+ unsigned d10 = static_cast<unsigned>(1ULL + multiprecision::detail::digits2_2_10(d2));
1260
+ if (d10 > requested_precision)
1261
+ requested_precision = d10;
1262
+ }
1263
+ mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(requested_precision)));
1264
+ }
1265
+ else if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
1266
+ {
1267
+ unsigned requested_precision = this->thread_default_precision();
1268
+ unsigned d2 = static_cast<unsigned>(used_gmp_int_bits(val));
1269
+ unsigned d10 = static_cast<unsigned>(1ULL + multiprecision::detail::digits2_2_10(d2));
1270
+ if (d10 > requested_precision)
1271
+ this->precision(d10);
1272
+ }
1273
+ mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
1274
+ return *this;
1275
+ }
1276
+ mpfr_float_backend& operator=(const gmp_rational& val)
1277
+ {
1278
+ if (this->m_data[0]._mpfr_d == nullptr)
1279
+ {
1280
+ unsigned requested_precision = this->get_default_precision();
1281
+ if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
1282
+ {
1283
+ unsigned d10 = static_cast<unsigned>(1u + multiprecision::detail::digits2_2_10(used_gmp_rational_bits(val)));
1284
+ if (d10 > requested_precision)
1285
+ requested_precision = d10;
1286
+ }
1287
+ mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(requested_precision)));
1288
+ }
1289
+ else if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
1290
+ {
1291
+ unsigned requested_precision = this->get_default_precision();
1292
+ unsigned d10 = static_cast<unsigned>(1u + multiprecision::detail::digits2_2_10(used_gmp_rational_bits(val)));
1293
+ if (d10 > requested_precision)
1294
+ this->precision(d10);
1295
+ }
1296
+ mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
1297
+ return *this;
1298
+ }
1299
+ static unsigned default_precision() noexcept
1300
+ {
1301
+ return get_global_default_precision();
1302
+ }
1303
+ static void default_precision(unsigned v) noexcept
1304
+ {
1305
+ get_global_default_precision() = v;
1306
+ }
1307
+ static unsigned thread_default_precision() noexcept
1308
+ {
1309
+ return get_default_precision();
1310
+ }
1311
+ static void thread_default_precision(unsigned v) noexcept
1312
+ {
1313
+ get_default_precision() = v;
1314
+ }
1315
+ unsigned precision() const noexcept
1316
+ {
1317
+ return static_cast<unsigned>(multiprecision::detail::digits2_2_10(static_cast<unsigned long>(mpfr_get_prec(this->m_data))));
1318
+ }
1319
+ void precision(unsigned digits10) noexcept
1320
+ {
1321
+ mpfr_prec_round(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2((digits10))), GMP_RNDN);
1322
+ }
1323
+ //
1324
+ // Variable precision options:
1325
+ //
1326
+ static variable_precision_options default_variable_precision_options()noexcept
1327
+ {
1328
+ return get_global_default_options();
1329
+ }
1330
+ static variable_precision_options thread_default_variable_precision_options()noexcept
1331
+ {
1332
+ return get_default_options();
1333
+ }
1334
+ static void default_variable_precision_options(variable_precision_options opts)
1335
+ {
1336
+ get_global_default_options() = opts;
1337
+ }
1338
+ static void thread_default_variable_precision_options(variable_precision_options opts)
1339
+ {
1340
+ get_default_options() = opts;
1341
+ }
1342
+ static bool preserve_source_precision()
1343
+ {
1344
+ return get_default_options() >= variable_precision_options::preserve_source_precision;
1345
+ }
1346
+ static bool preserve_related_precision()
1347
+ {
1348
+ return get_default_options() >= variable_precision_options::preserve_related_precision;
1349
+ }
1350
+ static bool preserve_all_precision()
1351
+ {
1352
+ return get_default_options() >= variable_precision_options::preserve_all_precision;
1353
+ }
1354
+ };
1355
+
1356
+ template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
1357
+ inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
1358
+ {
1359
+ return a.compare(b) == 0;
1360
+ }
1361
+ template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
1362
+ inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
1363
+ {
1364
+ return a.compare(b) < 0;
1365
+ }
1366
+ template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
1367
+ inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
1368
+ {
1369
+ return a.compare(b) > 0;
1370
+ }
1371
+
1372
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1373
+ inline bool eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b)noexcept
1374
+ {
1375
+ return mpfr_equal_p(a.data(), b.data());
1376
+ }
1377
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1378
+ inline bool eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b) noexcept
1379
+ {
1380
+ return mpfr_less_p(a.data(), b.data());
1381
+ }
1382
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1383
+ inline bool eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b) noexcept
1384
+ {
1385
+ return mpfr_greater_p(a.data(), b.data());
1386
+ }
1387
+
1388
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1389
+ inline void eval_add(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
1390
+ {
1391
+ mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
1392
+ }
1393
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1394
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
1395
+ {
1396
+ mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
1397
+ }
1398
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1399
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
1400
+ {
1401
+ if ((void*)&o == (void*)&result)
1402
+ mpfr_sqr(result.data(), o.data(), GMP_RNDN);
1403
+ else
1404
+ mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
1405
+ }
1406
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1407
+ inline void eval_divide(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
1408
+ {
1409
+ mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
1410
+ }
1411
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1412
+ inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1413
+ {
1414
+ mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
1415
+ }
1416
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1417
+ inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1418
+ {
1419
+ mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
1420
+ }
1421
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1422
+ inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1423
+ {
1424
+ mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
1425
+ }
1426
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1427
+ inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
1428
+ {
1429
+ mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
1430
+ }
1431
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1432
+ inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, long i)
1433
+ {
1434
+ if (i > 0)
1435
+ mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
1436
+ else
1437
+ mpfr_sub_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1438
+ }
1439
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1440
+ inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, long i)
1441
+ {
1442
+ if (i > 0)
1443
+ mpfr_sub_ui(result.data(), result.data(), static_cast<typename std::make_unsigned<long>::type>(i), GMP_RNDN);
1444
+ else
1445
+ mpfr_add_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1446
+ }
1447
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1448
+ inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, long i)
1449
+ {
1450
+ mpfr_mul_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1451
+ if (i < 0)
1452
+ mpfr_neg(result.data(), result.data(), GMP_RNDN);
1453
+ }
1454
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1455
+ inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, long i)
1456
+ {
1457
+ mpfr_div_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
1458
+ if (i < 0)
1459
+ mpfr_neg(result.data(), result.data(), GMP_RNDN);
1460
+ }
1461
+ //
1462
+ // Specialised 3 arg versions of the basic operators:
1463
+ //
1464
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
1465
+ inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
1466
+ {
1467
+ mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
1468
+ }
1469
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1470
+ inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1471
+ {
1472
+ mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
1473
+ }
1474
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1475
+ inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1476
+ {
1477
+ if (y < 0)
1478
+ mpfr_sub_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1479
+ else
1480
+ mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
1481
+ }
1482
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1483
+ inline void eval_add(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1484
+ {
1485
+ mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
1486
+ }
1487
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1488
+ inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1489
+ {
1490
+ if (x < 0)
1491
+ {
1492
+ mpfr_ui_sub(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
1493
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
1494
+ }
1495
+ else
1496
+ mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
1497
+ }
1498
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
1499
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
1500
+ {
1501
+ mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
1502
+ }
1503
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1504
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1505
+ {
1506
+ mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
1507
+ }
1508
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1509
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1510
+ {
1511
+ if (y < 0)
1512
+ mpfr_add_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1513
+ else
1514
+ mpfr_sub_ui(a.data(), x.data(), static_cast<typename std::make_unsigned<long>::type>(y), GMP_RNDN);
1515
+ }
1516
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1517
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1518
+ {
1519
+ mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
1520
+ }
1521
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1522
+ inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1523
+ {
1524
+ if (x < 0)
1525
+ {
1526
+ mpfr_add_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
1527
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
1528
+ }
1529
+ else
1530
+ mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
1531
+ }
1532
+
1533
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
1534
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
1535
+ {
1536
+ if ((void*)&x == (void*)&y)
1537
+ mpfr_sqr(a.data(), x.data(), GMP_RNDN);
1538
+ else
1539
+ mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
1540
+ }
1541
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1542
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1543
+ {
1544
+ mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
1545
+ }
1546
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1547
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1548
+ {
1549
+ if (y < 0)
1550
+ {
1551
+ mpfr_mul_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1552
+ a.negate();
1553
+ }
1554
+ else
1555
+ mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
1556
+ }
1557
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1558
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1559
+ {
1560
+ mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
1561
+ }
1562
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1563
+ inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1564
+ {
1565
+ if (x < 0)
1566
+ {
1567
+ mpfr_mul_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
1568
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
1569
+ }
1570
+ else
1571
+ mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
1572
+ }
1573
+
1574
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3, mpfr_allocation_type A3>
1575
+ inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& y)
1576
+ {
1577
+ mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
1578
+ }
1579
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1580
+ inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
1581
+ {
1582
+ mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
1583
+ }
1584
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1585
+ inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
1586
+ {
1587
+ if (y < 0)
1588
+ {
1589
+ mpfr_div_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
1590
+ a.negate();
1591
+ }
1592
+ else
1593
+ mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
1594
+ }
1595
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1596
+ inline void eval_divide(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
1597
+ {
1598
+ mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
1599
+ }
1600
+ template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
1601
+ inline void eval_divide(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
1602
+ {
1603
+ if (x < 0)
1604
+ {
1605
+ mpfr_ui_div(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
1606
+ mpfr_neg(a.data(), a.data(), GMP_RNDN);
1607
+ }
1608
+ else
1609
+ mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
1610
+ }
1611
+
1612
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1613
+ inline bool eval_is_zero(const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1614
+ {
1615
+ return 0 != mpfr_zero_p(val.data());
1616
+ }
1617
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1618
+ inline int eval_get_sign(const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1619
+ {
1620
+ return mpfr_sgn(val.data());
1621
+ }
1622
+
1623
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1624
+ inline void eval_convert_to(unsigned long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1625
+ {
1626
+ if (mpfr_nan_p(val.data()))
1627
+ {
1628
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1629
+ }
1630
+ *result = mpfr_get_ui(val.data(), GMP_RNDZ);
1631
+ }
1632
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1633
+ inline void eval_convert_to(long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1634
+ {
1635
+ if (mpfr_nan_p(val.data()))
1636
+ {
1637
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1638
+ }
1639
+ *result = mpfr_get_si(val.data(), GMP_RNDZ);
1640
+ }
1641
+ #ifdef _MPFR_H_HAVE_INTMAX_T
1642
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1643
+ inline void eval_convert_to(unsigned long long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1644
+ {
1645
+ if (mpfr_nan_p(val.data()))
1646
+ {
1647
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1648
+ }
1649
+ *result = mpfr_get_uj(val.data(), GMP_RNDZ);
1650
+ }
1651
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1652
+ inline void eval_convert_to(long long* result, const mpfr_float_backend<digits10, AllocationType>& val)
1653
+ {
1654
+ if (mpfr_nan_p(val.data()))
1655
+ {
1656
+ BOOST_MP_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
1657
+ }
1658
+ *result = mpfr_get_sj(val.data(), GMP_RNDZ);
1659
+ }
1660
+ #endif
1661
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1662
+ inline void eval_convert_to(float* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1663
+ {
1664
+ *result = mpfr_get_flt(val.data(), GMP_RNDN);
1665
+ }
1666
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1667
+ inline void eval_convert_to(double* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1668
+ {
1669
+ *result = mpfr_get_d(val.data(), GMP_RNDN);
1670
+ }
1671
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1672
+ inline void eval_convert_to(long double* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1673
+ {
1674
+ *result = mpfr_get_ld(val.data(), GMP_RNDN);
1675
+ }
1676
+
1677
+ #ifdef BOOST_HAS_INT128
1678
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1679
+ inline void eval_convert_to(int128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1680
+ {
1681
+ gmp_int i;
1682
+ mpfr_get_z(i.data(), val.data(), GMP_RNDN);
1683
+ eval_convert_to(result, i);
1684
+ }
1685
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1686
+ inline void eval_convert_to(uint128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1687
+ {
1688
+ gmp_int i;
1689
+ mpfr_get_z(i.data(), val.data(), GMP_RNDN);
1690
+ eval_convert_to(result, i);
1691
+ }
1692
+ #endif
1693
+ #if defined(BOOST_HAS_FLOAT128)
1694
+ template <unsigned digits10, mpfr_allocation_type AllocationType>
1695
+ inline void eval_convert_to(float128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
1696
+ {
1697
+ *result = float128_procs::strtoflt128(val.str(0, std::ios_base::scientific).c_str(), nullptr);
1698
+ }
1699
+ #endif
1700
+
1701
+ //
1702
+ // Native non-member operations:
1703
+ //
1704
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1705
+ inline void eval_sqrt(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1706
+ {
1707
+ mpfr_sqrt(result.data(), val.data(), GMP_RNDN);
1708
+ }
1709
+
1710
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1711
+ inline void eval_abs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1712
+ {
1713
+ mpfr_abs(result.data(), val.data(), GMP_RNDN);
1714
+ }
1715
+
1716
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1717
+ inline void eval_fabs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1718
+ {
1719
+ mpfr_abs(result.data(), val.data(), GMP_RNDN);
1720
+ }
1721
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1722
+ inline void eval_ceil(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1723
+ {
1724
+ mpfr_ceil(result.data(), val.data());
1725
+ }
1726
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1727
+ inline void eval_floor(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1728
+ {
1729
+ mpfr_floor(result.data(), val.data());
1730
+ }
1731
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1732
+ inline void eval_trunc(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
1733
+ {
1734
+ mpfr_trunc(result.data(), val.data());
1735
+ }
1736
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1737
+ inline void eval_ldexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long e)
1738
+ {
1739
+ using local_uint_type = typename boost::multiprecision::detail::make_unsigned<long>::type;
1740
+
1741
+ if (e > 0)
1742
+ mpfr_mul_2exp(result.data(), val.data(), static_cast<local_uint_type>(e), GMP_RNDN);
1743
+ else if (e < 0)
1744
+ mpfr_div_2exp(result.data(), val.data(), static_cast<local_uint_type>(-e), GMP_RNDN);
1745
+ else
1746
+ result = val;
1747
+ }
1748
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1749
+ inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, int* e)
1750
+ {
1751
+ if (mpfr_zero_p(val.data()))
1752
+ {
1753
+ *e = 0;
1754
+ result = val;
1755
+ return;
1756
+ }
1757
+ mp_exp_t v = mpfr_get_exp(val.data());
1758
+ *e = static_cast<int>(v);
1759
+ if (v)
1760
+ eval_ldexp(result, val, -v);
1761
+ else
1762
+ result = val;
1763
+ }
1764
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1765
+ inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long* e)
1766
+ {
1767
+ if (mpfr_zero_p(val.data()))
1768
+ {
1769
+ *e = 0;
1770
+ result = val;
1771
+ return;
1772
+ }
1773
+ mp_exp_t v = mpfr_get_exp(val.data());
1774
+ *e = v;
1775
+ if(v)
1776
+ eval_ldexp(result, val, -v);
1777
+ else
1778
+ result = val;
1779
+ }
1780
+
1781
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1782
+ inline int eval_fpclassify(const mpfr_float_backend<Digits10, AllocateType>& val) noexcept
1783
+ {
1784
+ return mpfr_inf_p(val.data()) ? FP_INFINITE : mpfr_nan_p(val.data()) ? FP_NAN : mpfr_zero_p(val.data()) ? FP_ZERO : FP_NORMAL;
1785
+ }
1786
+
1787
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1788
+ inline void eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& e)
1789
+ {
1790
+ if (mpfr_zero_p(b.data()) && mpfr_integer_p(e.data()) && (mpfr_signbit(e.data()) == 0) && mpfr_fits_ulong_p(e.data(), GMP_RNDN) && (mpfr_get_ui(e.data(), GMP_RNDN) & 1))
1791
+ {
1792
+ mpfr_set(result.data(), b.data(), GMP_RNDN);
1793
+ }
1794
+ else
1795
+ mpfr_pow(result.data(), b.data(), e.data(), GMP_RNDN);
1796
+ }
1797
+
1798
+ #ifdef BOOST_MSVC
1799
+ //
1800
+ // The enable_if usage below doesn't work with msvc - but only when
1801
+ // certain other enable_if usages are defined first. It's a capricious
1802
+ // and rather annoying compiler bug in other words....
1803
+ //
1804
+ #define BOOST_MP_ENABLE_IF_WORKAROUND (Digits10 || !Digits10)&&
1805
+ #else
1806
+ #define BOOST_MP_ENABLE_IF_WORKAROUND
1807
+ #endif
1808
+
1809
+ template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
1810
+ inline typename std::enable_if<boost::multiprecision::detail::is_signed<Integer>::value && boost::multiprecision::detail::is_integral<Integer>::value && (BOOST_MP_ENABLE_IF_WORKAROUND(sizeof(Integer) <= sizeof(long)))>::type
1811
+ eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
1812
+ {
1813
+ mpfr_pow_si(result.data(), b.data(), e, GMP_RNDN);
1814
+ }
1815
+
1816
+ template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
1817
+ inline typename std::enable_if<boost::multiprecision::detail::is_unsigned<Integer>::value && (BOOST_MP_ENABLE_IF_WORKAROUND(sizeof(Integer) <= sizeof(long)))>::type
1818
+ eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
1819
+ {
1820
+ mpfr_pow_ui(result.data(), b.data(), e, GMP_RNDN);
1821
+ }
1822
+
1823
+ #undef BOOST_MP_ENABLE_IF_WORKAROUND
1824
+
1825
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1826
+ inline void eval_exp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1827
+ {
1828
+ mpfr_exp(result.data(), arg.data(), GMP_RNDN);
1829
+ }
1830
+
1831
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1832
+ inline void eval_exp2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1833
+ {
1834
+ mpfr_exp2(result.data(), arg.data(), GMP_RNDN);
1835
+ }
1836
+
1837
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1838
+ inline void eval_log(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1839
+ {
1840
+ mpfr_log(result.data(), arg.data(), GMP_RNDN);
1841
+ }
1842
+
1843
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1844
+ inline void eval_log10(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1845
+ {
1846
+ mpfr_log10(result.data(), arg.data(), GMP_RNDN);
1847
+ }
1848
+
1849
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1850
+ inline void eval_sin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1851
+ {
1852
+ mpfr_sin(result.data(), arg.data(), GMP_RNDN);
1853
+ }
1854
+
1855
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1856
+ inline void eval_cos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1857
+ {
1858
+ mpfr_cos(result.data(), arg.data(), GMP_RNDN);
1859
+ }
1860
+
1861
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1862
+ inline void eval_tan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1863
+ {
1864
+ mpfr_tan(result.data(), arg.data(), GMP_RNDN);
1865
+ }
1866
+
1867
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1868
+ inline void eval_asin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1869
+ {
1870
+ mpfr_asin(result.data(), arg.data(), GMP_RNDN);
1871
+ }
1872
+
1873
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1874
+ inline void eval_acos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1875
+ {
1876
+ mpfr_acos(result.data(), arg.data(), GMP_RNDN);
1877
+ }
1878
+
1879
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1880
+ inline void eval_atan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1881
+ {
1882
+ mpfr_atan(result.data(), arg.data(), GMP_RNDN);
1883
+ }
1884
+
1885
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1886
+ inline void eval_atan2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg1, const mpfr_float_backend<Digits10, AllocateType>& arg2)
1887
+ {
1888
+ mpfr_atan2(result.data(), arg1.data(), arg2.data(), GMP_RNDN);
1889
+ }
1890
+
1891
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1892
+ inline void eval_sinh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1893
+ {
1894
+ mpfr_sinh(result.data(), arg.data(), GMP_RNDN);
1895
+ }
1896
+
1897
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1898
+ inline void eval_cosh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1899
+ {
1900
+ mpfr_cosh(result.data(), arg.data(), GMP_RNDN);
1901
+ }
1902
+
1903
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1904
+ inline void eval_tanh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1905
+ {
1906
+ mpfr_tanh(result.data(), arg.data(), GMP_RNDN);
1907
+ }
1908
+
1909
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1910
+ inline void eval_log2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
1911
+ {
1912
+ mpfr_log2(result.data(), arg.data(), GMP_RNDN);
1913
+ }
1914
+
1915
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1916
+ inline void eval_modf(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg, mpfr_float_backend<Digits10, AllocateType>* pipart)
1917
+ {
1918
+ if (pipart == nullptr)
1919
+ {
1920
+ mpfr_float_backend<Digits10, AllocateType> ipart;
1921
+ mpfr_modf(ipart.data(), result.data(), arg.data(), GMP_RNDN);
1922
+ }
1923
+ else
1924
+ {
1925
+ mpfr_modf(pipart->data(), result.data(), arg.data(), GMP_RNDN);
1926
+ }
1927
+ }
1928
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1929
+ inline void eval_remainder(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1930
+ {
1931
+ mpfr_remainder(result.data(), a.data(), b.data(), GMP_RNDN);
1932
+ }
1933
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1934
+ inline void eval_remquo(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, int* pi)
1935
+ {
1936
+ long l;
1937
+ mpfr_remquo(result.data(), &l, a.data(), b.data(), GMP_RNDN);
1938
+ if (pi)
1939
+ *pi = static_cast<int>(l);
1940
+ }
1941
+
1942
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1943
+ inline void eval_fmod(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1944
+ {
1945
+ mpfr_fmod(result.data(), a.data(), b.data(), GMP_RNDN);
1946
+ }
1947
+
1948
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1949
+ inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1950
+ {
1951
+ mpfr_fma(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
1952
+ }
1953
+
1954
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1955
+ inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
1956
+ {
1957
+ mpfr_fma(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
1958
+ }
1959
+
1960
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1961
+ inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
1962
+ {
1963
+ mpfr_fms(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
1964
+ result.negate();
1965
+ }
1966
+
1967
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1968
+ inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
1969
+ {
1970
+ mpfr_fms(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
1971
+ }
1972
+
1973
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1974
+ inline int eval_signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const mpfr_float_backend<Digits10, AllocateType>& arg)
1975
+ {
1976
+ return (arg.data()[0]._mpfr_sign < 0) ? 1 : 0;
1977
+ }
1978
+
1979
+ template <unsigned Digits10, mpfr_allocation_type AllocateType>
1980
+ inline std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
1981
+ {
1982
+ std::size_t result = 0;
1983
+ std::size_t len = val.data()[0]._mpfr_prec / mp_bits_per_limb;
1984
+ if (val.data()[0]._mpfr_prec % mp_bits_per_limb)
1985
+ ++len;
1986
+ for (std::size_t i = 0; i < len; ++i)
1987
+ boost::multiprecision::detail::hash_combine(result, val.data()[0]._mpfr_d[i]);
1988
+ boost::multiprecision::detail::hash_combine(result, val.data()[0]._mpfr_exp, val.data()[0]._mpfr_sign);
1989
+ return result;
1990
+ }
1991
+
1992
+ } // namespace backends
1993
+
1994
+ namespace detail {
1995
+ template <>
1996
+ struct is_variable_precision<backends::mpfr_float_backend<0> > : public std::integral_constant<bool, true>
1997
+ {};
1998
+ } // namespace detail
1999
+
2000
+ template <>
2001
+ struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
2002
+ {};
2003
+
2004
+ template <unsigned D, boost::multiprecision::mpfr_allocation_type A1, boost::multiprecision::mpfr_allocation_type A2>
2005
+ struct is_equivalent_number_type<backends::mpfr_float_backend<D, A1>, backends::mpfr_float_backend<D, A2> > : public std::integral_constant<bool, true> {};
2006
+
2007
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2008
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& b)
2009
+ {
2010
+ return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(-a) : a;
2011
+ }
2012
+
2013
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2014
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& b)
2015
+ {
2016
+ return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>(-a) : a;
2017
+ }
2018
+
2019
+ } // namespace multiprecision
2020
+
2021
+ namespace math {
2022
+
2023
+ using boost::multiprecision::copysign;
2024
+ using boost::multiprecision::signbit;
2025
+
2026
+ namespace tools {
2027
+
2028
+ #ifndef BOOST_MP_MATH_AVAILABLE
2029
+
2030
+ template <typename T>
2031
+ inline int digits();
2032
+
2033
+ template <typename T>
2034
+ inline T max_value();
2035
+
2036
+ template <typename T>
2037
+ inline T min_value();
2038
+
2039
+ #endif
2040
+
2041
+ inline void set_output_precision(const boost::multiprecision::mpfr_float& val, std::ostream& os)
2042
+ {
2043
+ os << std::setprecision(static_cast<int>(val.precision()));
2044
+ }
2045
+
2046
+ template <>
2047
+ inline int digits<boost::multiprecision::mpfr_float>()
2048
+ #ifdef BOOST_MATH_NOEXCEPT
2049
+ noexcept
2050
+ #endif
2051
+ {
2052
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::thread_default_precision()));
2053
+ }
2054
+ template <>
2055
+ inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
2056
+ #ifdef BOOST_MATH_NOEXCEPT
2057
+ noexcept
2058
+ #endif
2059
+ {
2060
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::thread_default_precision()));
2061
+ }
2062
+
2063
+ template <>
2064
+ inline boost::multiprecision::mpfr_float
2065
+ max_value<boost::multiprecision::mpfr_float>()
2066
+ {
2067
+ boost::multiprecision::mpfr_float result(0.5);
2068
+ mpfr_mul_2exp(result.backend().data(), result.backend().data(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(mpfr_get_emax()), GMP_RNDN);
2069
+ BOOST_MP_ASSERT(mpfr_number_p(result.backend().data()));
2070
+ return result;
2071
+ }
2072
+
2073
+ template <>
2074
+ inline boost::multiprecision::mpfr_float
2075
+ min_value<boost::multiprecision::mpfr_float>()
2076
+ {
2077
+ boost::multiprecision::mpfr_float result(0.5);
2078
+ mpfr_div_2exp(result.backend().data(), result.backend().data(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(-mpfr_get_emin()), GMP_RNDN);
2079
+ BOOST_MP_ASSERT(mpfr_number_p(result.backend().data()));
2080
+ return result;
2081
+ }
2082
+
2083
+ template <>
2084
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
2085
+ max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
2086
+ {
2087
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
2088
+ mpfr_mul_2exp(result.backend().data(), result.backend().data(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(mpfr_get_emax()), GMP_RNDN);
2089
+ BOOST_MP_ASSERT(mpfr_number_p(result.backend().data()));
2090
+ return result;
2091
+ }
2092
+
2093
+ template <>
2094
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
2095
+ min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
2096
+ {
2097
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
2098
+ mpfr_div_2exp(result.backend().data(), result.backend().data(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(-mpfr_get_emin()), GMP_RNDN);
2099
+ BOOST_MP_ASSERT(mpfr_number_p(result.backend().data()));
2100
+ return result;
2101
+ }
2102
+ //
2103
+ // Over again with debug_adaptor:
2104
+ //
2105
+ template <>
2106
+ inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2107
+ #ifdef BOOST_MATH_NOEXCEPT
2108
+ noexcept
2109
+ #endif
2110
+ {
2111
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::thread_default_precision()));
2112
+ }
2113
+ template <>
2114
+ inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2115
+ #ifdef BOOST_MATH_NOEXCEPT
2116
+ noexcept
2117
+ #endif
2118
+ {
2119
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::thread_default_precision()));
2120
+ }
2121
+
2122
+ template <>
2123
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
2124
+ max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2125
+ {
2126
+ return max_value<boost::multiprecision::mpfr_float>().backend();
2127
+ }
2128
+
2129
+ template <>
2130
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
2131
+ min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2132
+ {
2133
+ return min_value<boost::multiprecision::mpfr_float>().backend();
2134
+ }
2135
+
2136
+ template <>
2137
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
2138
+ max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2139
+ {
2140
+ return max_value<boost::multiprecision::mpfr_float>().backend();
2141
+ }
2142
+
2143
+ template <>
2144
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
2145
+ min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2146
+ {
2147
+ return min_value<boost::multiprecision::mpfr_float>().backend();
2148
+ }
2149
+
2150
+ //
2151
+ // Over again with logged_adaptor:
2152
+ //
2153
+ template <>
2154
+ inline int digits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2155
+ #ifdef BOOST_MATH_NOEXCEPT
2156
+ noexcept
2157
+ #endif
2158
+ {
2159
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision()));
2160
+ }
2161
+ template <>
2162
+ inline int digits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2163
+ #ifdef BOOST_MATH_NOEXCEPT
2164
+ noexcept
2165
+ #endif
2166
+ {
2167
+ return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision()));
2168
+ }
2169
+
2170
+ template <>
2171
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >
2172
+ max_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2173
+ {
2174
+ return max_value<boost::multiprecision::mpfr_float>().backend();
2175
+ }
2176
+
2177
+ template <>
2178
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >
2179
+ min_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
2180
+ {
2181
+ return min_value<boost::multiprecision::mpfr_float>().backend();
2182
+ }
2183
+
2184
+ template <>
2185
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
2186
+ max_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2187
+ {
2188
+ return max_value<boost::multiprecision::mpfr_float>().backend();
2189
+ }
2190
+
2191
+ template <>
2192
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
2193
+ min_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
2194
+ {
2195
+ return min_value<boost::multiprecision::mpfr_float>().backend();
2196
+ }
2197
+
2198
+ } // namespace tools
2199
+
2200
+ namespace constants { namespace detail {
2201
+
2202
+ template <class T>
2203
+ struct constant_pi;
2204
+ template <class T>
2205
+ struct constant_ln_two;
2206
+ template <class T>
2207
+ struct constant_euler;
2208
+ template <class T>
2209
+ struct constant_catalan;
2210
+
2211
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2212
+ struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
2213
+ {
2214
+ using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
2215
+ template <int N>
2216
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2217
+ {
2218
+ // Rely on C++11 thread safe initialization:
2219
+ static result_type result{get(std::integral_constant<int, 0>())};
2220
+ return result;
2221
+ }
2222
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2223
+ {
2224
+ result_type result;
2225
+ mpfr_const_pi(result.backend().data(), GMP_RNDN);
2226
+ return result;
2227
+ }
2228
+ };
2229
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2230
+ struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
2231
+ {
2232
+ using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
2233
+ template <int N>
2234
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2235
+ {
2236
+ // Rely on C++11 thread safe initialization:
2237
+ static result_type result{get(std::integral_constant<int, 0>())};
2238
+ return result;
2239
+ }
2240
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2241
+ {
2242
+ result_type result;
2243
+ mpfr_const_log2(result.backend().data(), GMP_RNDN);
2244
+ return result;
2245
+ }
2246
+ };
2247
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2248
+ struct constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
2249
+ {
2250
+ using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
2251
+ template <int N>
2252
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2253
+ {
2254
+ // Rely on C++11 thread safe initialization:
2255
+ static result_type result{get(std::integral_constant<int, 0>())};
2256
+ return result;
2257
+ }
2258
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2259
+ {
2260
+ result_type result;
2261
+ mpfr_const_euler(result.backend().data(), GMP_RNDN);
2262
+ return result;
2263
+ }
2264
+ };
2265
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2266
+ struct constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
2267
+ {
2268
+ using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
2269
+ template <int N>
2270
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2271
+ {
2272
+ // Rely on C++11 thread safe initialization:
2273
+ static result_type result{get(std::integral_constant<int, 0>())};
2274
+ return result;
2275
+ }
2276
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2277
+ {
2278
+ result_type result;
2279
+ mpfr_const_catalan(result.backend().data(), GMP_RNDN);
2280
+ return result;
2281
+ }
2282
+ };
2283
+ //
2284
+ // Over again with debug_adaptor:
2285
+ //
2286
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2287
+ struct constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2288
+ {
2289
+ using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2290
+ template <int N>
2291
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2292
+ {
2293
+ // Rely on C++11 thread safe initialization:
2294
+ static result_type result{get(std::integral_constant<int, 0>())};
2295
+ return result;
2296
+ }
2297
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2298
+ {
2299
+ result_type result;
2300
+ mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
2301
+ result.backend().update_view();
2302
+ return result;
2303
+ }
2304
+ };
2305
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2306
+ struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2307
+ {
2308
+ using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2309
+ template <int N>
2310
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2311
+ {
2312
+ // Rely on C++11 thread safe initialization:
2313
+ static result_type result{get(std::integral_constant<int, 0>())};
2314
+ return result;
2315
+ }
2316
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2317
+ {
2318
+ result_type result;
2319
+ mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
2320
+ result.backend().update_view();
2321
+ return result;
2322
+ }
2323
+ };
2324
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2325
+ struct constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2326
+ {
2327
+ using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2328
+ template <int N>
2329
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2330
+ {
2331
+ // Rely on C++11 thread safe initialization:
2332
+ static result_type result{get(std::integral_constant<int, 0>())};
2333
+ return result;
2334
+ }
2335
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2336
+ {
2337
+ result_type result;
2338
+ mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
2339
+ result.backend().update_view();
2340
+ return result;
2341
+ }
2342
+ };
2343
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2344
+ struct constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2345
+ {
2346
+ using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2347
+ template <int N>
2348
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2349
+ {
2350
+ // Rely on C++11 thread safe initialization:
2351
+ static result_type result{get(std::integral_constant<int, 0>())};
2352
+ return result;
2353
+ }
2354
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2355
+ {
2356
+ result_type result;
2357
+ mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
2358
+ result.backend().update_view();
2359
+ return result;
2360
+ }
2361
+ };
2362
+
2363
+ //
2364
+ // Over again with logged_adaptor:
2365
+ //
2366
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2367
+ struct constant_pi<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2368
+ {
2369
+ using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2370
+ template <int N>
2371
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2372
+ {
2373
+ // C++11 thread safe static initialization:
2374
+ static result_type result{get(std::integral_constant<int, 0>())};
2375
+ return result;
2376
+ }
2377
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2378
+ {
2379
+ result_type result;
2380
+ mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
2381
+ return result;
2382
+ }
2383
+ };
2384
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2385
+ struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2386
+ {
2387
+ using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2388
+ template <int N>
2389
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2390
+ {
2391
+ // C++11 thread safe static initialization:
2392
+ static result_type result{get(std::integral_constant<int, 0>())};
2393
+ return result;
2394
+ }
2395
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2396
+ {
2397
+ result_type result;
2398
+ mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
2399
+ return result;
2400
+ }
2401
+ };
2402
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2403
+ struct constant_euler<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2404
+ {
2405
+ using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2406
+ template <int N>
2407
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2408
+ {
2409
+ // C++11 thread safe static initialization:
2410
+ static result_type result{get(std::integral_constant<int, 0>())};
2411
+ return result;
2412
+ }
2413
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2414
+ {
2415
+ result_type result;
2416
+ mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
2417
+ return result;
2418
+ }
2419
+ };
2420
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2421
+ struct constant_catalan<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
2422
+ {
2423
+ using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
2424
+ template <int N>
2425
+ static inline const result_type& get(const std::integral_constant<int, N>&)
2426
+ {
2427
+ // C++11 thread safe static initialization:
2428
+ static result_type result{get(std::integral_constant<int, 0>())};
2429
+ return result;
2430
+ }
2431
+ static inline const result_type get(const std::integral_constant<int, 0>&)
2432
+ {
2433
+ result_type result;
2434
+ mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
2435
+ return result;
2436
+ }
2437
+ };
2438
+
2439
+ }} // namespace constants::detail
2440
+
2441
+ } // namespace math
2442
+
2443
+ namespace multiprecision {
2444
+ //
2445
+ // Overloaded special functions which call native mpfr routines:
2446
+ //
2447
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2448
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2449
+ {
2450
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2451
+
2452
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2453
+ mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2454
+ return result;
2455
+ }
2456
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2457
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2458
+ {
2459
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2460
+
2461
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2462
+ mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2463
+ return result;
2464
+ }
2465
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2466
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2467
+ {
2468
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2469
+
2470
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2471
+ mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2472
+ return result;
2473
+ }
2474
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2475
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2476
+ {
2477
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2478
+
2479
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2480
+ mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
2481
+ return result;
2482
+ }
2483
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2484
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2485
+ {
2486
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2487
+
2488
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2489
+ mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
2490
+ return result;
2491
+ }
2492
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2493
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2494
+ {
2495
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2496
+
2497
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2498
+ mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
2499
+ return result;
2500
+ }
2501
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2502
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2503
+ {
2504
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2505
+
2506
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2507
+ mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
2508
+ return result;
2509
+ }
2510
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2511
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2512
+ {
2513
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2514
+
2515
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2516
+ mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
2517
+ return result;
2518
+ }
2519
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2520
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2521
+ {
2522
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2523
+
2524
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2525
+ mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
2526
+ return result;
2527
+ }
2528
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2529
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2530
+ {
2531
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2532
+
2533
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2534
+ mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
2535
+ return result;
2536
+ }
2537
+
2538
+ //
2539
+ // Over again with debug_adaptor:
2540
+ //
2541
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2542
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2543
+ {
2544
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2545
+
2546
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2547
+ mpfr_asinh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2548
+ result.backend().update_view();
2549
+ return result;
2550
+ }
2551
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2552
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2553
+ {
2554
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2555
+
2556
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2557
+ mpfr_acosh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2558
+ result.backend().update_view();
2559
+ return result;
2560
+ }
2561
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2562
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2563
+ {
2564
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2565
+
2566
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2567
+ mpfr_atanh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2568
+ result.backend().update_view();
2569
+ return result;
2570
+ }
2571
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2572
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2573
+ {
2574
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2575
+
2576
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2577
+ mpfr_cbrt(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2578
+ result.backend().update_view();
2579
+ return result;
2580
+ }
2581
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2582
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2583
+ {
2584
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2585
+
2586
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2587
+ mpfr_erf(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2588
+ result.backend().update_view();
2589
+ return result;
2590
+ }
2591
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2592
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2593
+ {
2594
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2595
+
2596
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2597
+ mpfr_erfc(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2598
+ result.backend().update_view();
2599
+ return result;
2600
+ }
2601
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2602
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2603
+ {
2604
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2605
+
2606
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2607
+ mpfr_expm1(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2608
+ result.backend().update_view();
2609
+ return result;
2610
+ }
2611
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2612
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2613
+ {
2614
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2615
+
2616
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2617
+ mpfr_lngamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2618
+ result.backend().update_view();
2619
+ return result;
2620
+ }
2621
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2622
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2623
+ {
2624
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2625
+
2626
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2627
+ mpfr_gamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2628
+ result.backend().update_view();
2629
+ return result;
2630
+ }
2631
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2632
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2633
+ {
2634
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2635
+
2636
+ boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2637
+ mpfr_log1p(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2638
+ result.backend().update_view();
2639
+ return result;
2640
+ }
2641
+
2642
+ //
2643
+ // Over again with logged_adaptor:
2644
+ //
2645
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2646
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2647
+ {
2648
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2649
+
2650
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2651
+ mpfr_asinh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2652
+ return result;
2653
+ }
2654
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2655
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2656
+ {
2657
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2658
+
2659
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2660
+ mpfr_acosh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2661
+ return result;
2662
+ }
2663
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2664
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2665
+ {
2666
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2667
+
2668
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2669
+ mpfr_atanh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2670
+ return result;
2671
+ }
2672
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2673
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2674
+ {
2675
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2676
+
2677
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2678
+ mpfr_cbrt(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2679
+ return result;
2680
+ }
2681
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2682
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2683
+ {
2684
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2685
+
2686
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2687
+ mpfr_erf(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2688
+ return result;
2689
+ }
2690
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2691
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2692
+ {
2693
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2694
+
2695
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2696
+ mpfr_erfc(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2697
+ return result;
2698
+ }
2699
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2700
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2701
+ {
2702
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2703
+
2704
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2705
+ mpfr_expm1(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2706
+ return result;
2707
+ }
2708
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2709
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2710
+ {
2711
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2712
+
2713
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2714
+ mpfr_lngamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2715
+ return result;
2716
+ }
2717
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2718
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2719
+ {
2720
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2721
+
2722
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2723
+ mpfr_gamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2724
+ return result;
2725
+ }
2726
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2727
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
2728
+ {
2729
+ boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
2730
+
2731
+ boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
2732
+ mpfr_log1p(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
2733
+ return result;
2734
+ }
2735
+
2736
+ } // namespace multiprecision
2737
+
2738
+ namespace math {
2739
+ //
2740
+ // Overloaded special functions which call native mpfr routines:
2741
+ //
2742
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2743
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
2744
+ {
2745
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2746
+
2747
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2748
+ mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2749
+ if (mpfr_inf_p(result.backend().data()))
2750
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("asinh<%1%>(%1%)", nullptr, Policy());
2751
+ if (mpfr_nan_p(result.backend().data()))
2752
+ return policies::raise_evaluation_error("asinh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
2753
+ return result;
2754
+ }
2755
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2756
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2757
+ {
2758
+ return asinh(arg, policies::policy<>());
2759
+ }
2760
+
2761
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2762
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
2763
+ {
2764
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2765
+
2766
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2767
+ mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2768
+ if (mpfr_inf_p(result.backend().data()))
2769
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("acosh<%1%>(%1%)", nullptr, Policy());
2770
+ if (mpfr_nan_p(result.backend().data()))
2771
+ return policies::raise_evaluation_error("acosh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
2772
+ return result;
2773
+ }
2774
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2775
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2776
+ {
2777
+ return acosh(arg, policies::policy<>());
2778
+ }
2779
+
2780
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2781
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& )
2782
+ {
2783
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2784
+
2785
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2786
+ mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
2787
+ if (mpfr_inf_p(result.backend().data()))
2788
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("atanh<%1%>(%1%)", nullptr, Policy());
2789
+ if (mpfr_nan_p(result.backend().data()))
2790
+ return policies::raise_evaluation_error("atanh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
2791
+ return result;
2792
+ }
2793
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2794
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2795
+ {
2796
+ return atanh(arg, policies::policy<>());
2797
+ }
2798
+
2799
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2800
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
2801
+ {
2802
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2803
+
2804
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2805
+ if (mpfr_nan_p(arg.backend().data()))
2806
+ return policies::raise_domain_error("cbrt<%1%>(%1%)", "Input is a NaN", result, Policy());
2807
+ mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
2808
+ if (mpfr_inf_p(result.backend().data()))
2809
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("cbrt<%1%>(%1%)", nullptr, Policy());
2810
+ if (mpfr_nan_p(result.backend().data()))
2811
+ return policies::raise_evaluation_error("cbrt<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
2812
+ return result;
2813
+ }
2814
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2815
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2816
+ {
2817
+ return cbrt(arg, policies::policy<>());
2818
+ }
2819
+
2820
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2821
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2822
+ {
2823
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2824
+
2825
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2826
+ if (mpfr_nan_p(arg.backend().data()))
2827
+ return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
2828
+ mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
2829
+ if (mpfr_inf_p(result.backend().data()))
2830
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("erf<%1%>(%1%)", nullptr, pol);
2831
+ if (mpfr_nan_p(result.backend().data()))
2832
+ return policies::raise_evaluation_error("erf<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2833
+ return result;
2834
+ }
2835
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2836
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2837
+ {
2838
+ return erf(arg, policies::policy<>());
2839
+ }
2840
+
2841
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2842
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2843
+ {
2844
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2845
+
2846
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2847
+ if (mpfr_nan_p(arg.backend().data()))
2848
+ return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
2849
+ mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
2850
+ if (mpfr_inf_p(result.backend().data()))
2851
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("erfc<%1%>(%1%)", nullptr, pol);
2852
+ if (mpfr_nan_p(result.backend().data()))
2853
+ return policies::raise_evaluation_error("erfc<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2854
+ return result;
2855
+ }
2856
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2857
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2858
+ {
2859
+ return erfc(arg, policies::policy<>());
2860
+ }
2861
+
2862
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2863
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2864
+ {
2865
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2866
+
2867
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2868
+ if (mpfr_nan_p(arg.backend().data()))
2869
+ return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
2870
+ mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
2871
+ if (mpfr_inf_p(result.backend().data()))
2872
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("expm1<%1%>(%1%)", nullptr, pol);
2873
+ if (mpfr_nan_p(result.backend().data()))
2874
+ return policies::raise_evaluation_error("expm1<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2875
+ return result;
2876
+ }
2877
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2878
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2879
+ {
2880
+ return expm1(arg, policies::policy<>());
2881
+ }
2882
+
2883
+ #ifdef BOOST_MP_MATH_AVAILABLE
2884
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2885
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> arg, int* sign, const Policy& pol)
2886
+ {
2887
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2888
+ (void)precision_guard; // warning suppression
2889
+
2890
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2891
+ if (arg > 0)
2892
+ {
2893
+ mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
2894
+ if (sign)
2895
+ *sign = 1;
2896
+ }
2897
+ else
2898
+ {
2899
+ if (floor(arg) == arg)
2900
+ return policies::raise_pole_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >(
2901
+ "lgamma<%1%>", "Evaluation of lgamma at a negative integer %1%.", arg, pol);
2902
+
2903
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> t = detail::sinpx(arg);
2904
+ arg = -arg;
2905
+ if (t < 0)
2906
+ {
2907
+ t = -t;
2908
+ }
2909
+ result = boost::multiprecision::log(boost::math::constants::pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >()) - lgamma(arg, 0, pol) - boost::multiprecision::log(t);
2910
+ if (sign)
2911
+ {
2912
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> phase = 1 - arg;
2913
+ phase = floor(phase) / 2;
2914
+ if (floor(phase) == phase)
2915
+ *sign = -1;
2916
+ else
2917
+ *sign = 1;
2918
+ }
2919
+ }
2920
+ if (mpfr_inf_p(result.backend().data()))
2921
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("lgamma<%1%>(%1%)", nullptr, pol);
2922
+ if (mpfr_nan_p(result.backend().data()))
2923
+ return policies::raise_evaluation_error("lgamma<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2924
+ return result;
2925
+ }
2926
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2927
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, int* sign)
2928
+ {
2929
+ return lgamma(arg, sign, policies::policy<>());
2930
+ }
2931
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2932
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2933
+ {
2934
+ return lgamma(arg, 0, pol);
2935
+ }
2936
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2937
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2938
+ {
2939
+ return lgamma(arg, 0, policies::policy<>());
2940
+ }
2941
+ #endif // BOOST_MP_MATH_AVAILABLE
2942
+
2943
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2944
+ inline typename std::enable_if<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2945
+ {
2946
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2947
+
2948
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2949
+ mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
2950
+ if (mpfr_inf_p(result.backend().data()))
2951
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("tgamma<%1%>(%1%)", nullptr, pol);
2952
+ if (mpfr_nan_p(result.backend().data()))
2953
+ return policies::raise_evaluation_error("tgamma<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2954
+ return result;
2955
+ }
2956
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2957
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2958
+ {
2959
+ return tgamma(arg, policies::policy<>());
2960
+ }
2961
+
2962
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2963
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2964
+ {
2965
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2966
+
2967
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2968
+ mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
2969
+ if (mpfr_inf_p(result.backend().data()))
2970
+ return (arg == -1 ? -1 : 1) * policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("log1p<%1%>(%1%)", nullptr, pol);
2971
+ if (mpfr_nan_p(result.backend().data()))
2972
+ return policies::raise_evaluation_error("log1p<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
2973
+ return result;
2974
+ }
2975
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2976
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2977
+ {
2978
+ return log1p(arg, policies::policy<>());
2979
+ }
2980
+
2981
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
2982
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
2983
+ {
2984
+ boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
2985
+
2986
+ boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
2987
+ mpfr_rec_sqrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
2988
+ if (mpfr_inf_p(result.backend().data()))
2989
+ return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("rsqrt<%1%>(%1%)", nullptr, pol);
2990
+ if (mpfr_nan_p(result.backend().data()))
2991
+ return policies::raise_evaluation_error("rsqrt<%1%>(%1%)", "Negative argument, result is a NaN", result, pol);
2992
+ return result;
2993
+ }
2994
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
2995
+ inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
2996
+ {
2997
+ return rsqrt(arg, policies::policy<>());
2998
+ }
2999
+
3000
+ //
3001
+ // Over again with debug_adaptor:
3002
+ //
3003
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3004
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3005
+ {
3006
+ return asinh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3007
+ }
3008
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3009
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3010
+ {
3011
+ return asinh(arg, policies::policy<>());
3012
+ }
3013
+
3014
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3015
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3016
+ {
3017
+ return acosh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3018
+ }
3019
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3020
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3021
+ {
3022
+ return acosh(arg, policies::policy<>());
3023
+ }
3024
+
3025
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3026
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3027
+ {
3028
+ return atanh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3029
+ }
3030
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3031
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3032
+ {
3033
+ return atanh(arg, policies::policy<>());
3034
+ }
3035
+
3036
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3037
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3038
+ {
3039
+ return cbrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3040
+ }
3041
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3042
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3043
+ {
3044
+ return cbrt(arg, policies::policy<>());
3045
+ }
3046
+
3047
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3048
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3049
+ {
3050
+ return erf(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3051
+ }
3052
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3053
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3054
+ {
3055
+ return erf(arg, policies::policy<>());
3056
+ }
3057
+
3058
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3059
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3060
+ {
3061
+ return erfc(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3062
+ }
3063
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3064
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3065
+ {
3066
+ return erfc(arg, policies::policy<>());
3067
+ }
3068
+
3069
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3070
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3071
+ {
3072
+ return expm1(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3073
+ }
3074
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3075
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> exm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3076
+ {
3077
+ return expm1(arg, policies::policy<>());
3078
+ }
3079
+
3080
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3081
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> arg, int* sign, const Policy& pol)
3082
+ {
3083
+ return lgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), sign, pol).backend();
3084
+ }
3085
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3086
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, int* sign)
3087
+ {
3088
+ return lgamma(arg, sign, policies::policy<>());
3089
+ }
3090
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3091
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3092
+ {
3093
+ return lgamma(arg, 0, pol);
3094
+ }
3095
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3096
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3097
+ {
3098
+ return lgamma(arg, 0, policies::policy<>());
3099
+ }
3100
+
3101
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3102
+ inline typename std::enable_if<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3103
+ {
3104
+ return tgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3105
+ }
3106
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3107
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3108
+ {
3109
+ return tgamma(arg, policies::policy<>());
3110
+ }
3111
+
3112
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3113
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3114
+ {
3115
+ return log1p(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3116
+ }
3117
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3118
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3119
+ {
3120
+ return log1p(arg, policies::policy<>());
3121
+ }
3122
+
3123
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3124
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3125
+ {
3126
+ return rsqrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3127
+ }
3128
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3129
+ inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3130
+ {
3131
+ return rsqrt(arg, policies::policy<>());
3132
+ }
3133
+
3134
+ //
3135
+ // Over again with logged_adaptor:
3136
+ //
3137
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3138
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3139
+ {
3140
+ return asinh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3141
+ }
3142
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3143
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3144
+ {
3145
+ return asinh(arg, policies::policy<>());
3146
+ }
3147
+
3148
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3149
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3150
+ {
3151
+ return acosh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3152
+ }
3153
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3154
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3155
+ {
3156
+ return acosh(arg, policies::policy<>());
3157
+ }
3158
+
3159
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3160
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3161
+ {
3162
+ return atanh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3163
+ }
3164
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3165
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3166
+ {
3167
+ return atanh(arg, policies::policy<>());
3168
+ }
3169
+
3170
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3171
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3172
+ {
3173
+ return cbrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3174
+ }
3175
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3176
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3177
+ {
3178
+ return cbrt(arg, policies::policy<>());
3179
+ }
3180
+
3181
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3182
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3183
+ {
3184
+ return erf(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3185
+ }
3186
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3187
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3188
+ {
3189
+ return erf(arg, policies::policy<>());
3190
+ }
3191
+
3192
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3193
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3194
+ {
3195
+ return erfc(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3196
+ }
3197
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3198
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3199
+ {
3200
+ return erfc(arg, policies::policy<>());
3201
+ }
3202
+
3203
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3204
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3205
+ {
3206
+ return expm1(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3207
+ }
3208
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3209
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> exm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3210
+ {
3211
+ return expm1(arg, policies::policy<>());
3212
+ }
3213
+
3214
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3215
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> arg, int* sign, const Policy& pol)
3216
+ {
3217
+ return lgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), sign, pol).backend();
3218
+ }
3219
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3220
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, int* sign)
3221
+ {
3222
+ return lgamma(arg, sign, policies::policy<>());
3223
+ }
3224
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3225
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3226
+ {
3227
+ return lgamma(arg, 0, pol);
3228
+ }
3229
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3230
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3231
+ {
3232
+ return lgamma(arg, 0, policies::policy<>());
3233
+ }
3234
+
3235
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3236
+ inline typename std::enable_if<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3237
+ {
3238
+ return tgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3239
+ }
3240
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3241
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3242
+ {
3243
+ return tgamma(arg, policies::policy<>());
3244
+ }
3245
+
3246
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3247
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3248
+ {
3249
+ return log1p(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3250
+ }
3251
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3252
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3253
+ {
3254
+ return log1p(arg, policies::policy<>());
3255
+ }
3256
+
3257
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
3258
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
3259
+ {
3260
+ return rsqrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
3261
+ }
3262
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3263
+ inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
3264
+ {
3265
+ return rsqrt(arg, policies::policy<>());
3266
+ }
3267
+
3268
+ } // namespace math
3269
+
3270
+ } // namespace boost
3271
+
3272
+ namespace Eigen
3273
+ {
3274
+
3275
+ template <class B1, class B2>
3276
+ struct NumTraitsImp;
3277
+
3278
+ template <boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3279
+ struct NumTraitsImp<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>, boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>
3280
+ {
3281
+ using self_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>;
3282
+ using Real = typename boost::multiprecision::scalar_result_from_possible_complex<self_type>::type;
3283
+ using NonInteger = self_type; // Not correct but we can't do much better??
3284
+ using Literal = double;
3285
+ using Nested = self_type;
3286
+ enum
3287
+ {
3288
+ IsComplex = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_complex,
3289
+ IsInteger = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer,
3290
+ ReadCost = 1,
3291
+ AddCost = 4,
3292
+ MulCost = 8,
3293
+ IsSigned = std::numeric_limits<self_type>::is_specialized ? std::numeric_limits<self_type>::is_signed : true,
3294
+ RequireInitialization = 1,
3295
+ };
3296
+ static Real epsilon()
3297
+ {
3298
+ #ifdef BOOST_MP_MATH_AVAILABLE
3299
+ return boost::math::tools::epsilon< boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
3300
+ #else
3301
+ self_type result{1};
3302
+ mpfr_div_2exp(result.backend().data(), result.backend().data(), std::numeric_limits<self_type>::digits - 1, GMP_RNDN);
3303
+ return result;
3304
+ #endif
3305
+ }
3306
+ static Real dummy_precision()
3307
+ {
3308
+ return 1000 * epsilon();
3309
+ }
3310
+ static Real highest()
3311
+ {
3312
+ #ifdef BOOST_MP_MATH_AVAILABLE
3313
+ return boost::math::tools::max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
3314
+ #else
3315
+ self_type value(0.5);
3316
+ mpfr_mul_2exp(value.backend().data(), value.backend().data(), mpfr_get_emax(), GMP_RNDN);
3317
+ return value;
3318
+ #endif
3319
+ }
3320
+ static Real lowest()
3321
+ {
3322
+ #ifdef BOOST_MP_MATH_AVAILABLE
3323
+ return boost::math::tools::min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
3324
+ #else
3325
+ return -(highest)();
3326
+ #endif
3327
+ }
3328
+ static int digits10()
3329
+ {
3330
+ return Real::thread_default_precision();
3331
+ }
3332
+ static int digits()
3333
+ {
3334
+ return boost::math::tools::digits<Real>();
3335
+ }
3336
+ static int min_exponent()
3337
+ {
3338
+ return static_cast<int>(mpfr_get_emin());
3339
+ }
3340
+ static int max_exponent()
3341
+ {
3342
+ return static_cast<int>(mpfr_get_emax());
3343
+ }
3344
+ static Real infinity()
3345
+ {
3346
+ return std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<50, AllocateType>, ExpressionTemplates>>::infinity();
3347
+ }
3348
+ static Real quiet_NaN()
3349
+ {
3350
+ return std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<50, AllocateType>, ExpressionTemplates>>::quiet_NaN();
3351
+ }
3352
+ };
3353
+
3354
+ }
3355
+
3356
+ namespace std {
3357
+
3358
+ //
3359
+ // numeric_limits [partial] specializations for the types declared in this header:
3360
+ //
3361
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3362
+ class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
3363
+ {
3364
+ using number_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
3365
+
3366
+ static number_type get_min()
3367
+ {
3368
+ number_type result{0.5};
3369
+ mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
3370
+ return result;
3371
+ }
3372
+ static number_type get_max()
3373
+ {
3374
+ number_type result{0.5};
3375
+ mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
3376
+ return result;
3377
+ }
3378
+ static number_type get_eps()
3379
+ {
3380
+ number_type result{1};
3381
+ mpfr_div_2exp(result.backend().data(), result.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
3382
+ return result;
3383
+ }
3384
+
3385
+ public:
3386
+ static constexpr bool is_specialized = true;
3387
+ static number_type(min)()
3388
+ {
3389
+ static number_type value{get_min()};
3390
+ return value;
3391
+ }
3392
+ static number_type(max)()
3393
+ {
3394
+ static number_type value{get_max()};
3395
+ return value;
3396
+ }
3397
+ static constexpr number_type lowest()
3398
+ {
3399
+ return -(max)();
3400
+ }
3401
+ static constexpr int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
3402
+ static constexpr int digits10 = Digits10;
3403
+ // Is this really correct???
3404
+ static constexpr int max_digits10 = static_cast<int>(boost::multiprecision::detail::calc_max_digits10<static_cast<unsigned>(digits)>::value);
3405
+ static constexpr bool is_signed = true;
3406
+ static constexpr bool is_integer = false;
3407
+ static constexpr bool is_exact = false;
3408
+ static constexpr int radix = 2;
3409
+ static number_type epsilon()
3410
+ {
3411
+ static number_type value{get_eps()};
3412
+ return value;
3413
+ }
3414
+ // What value should this be????
3415
+ static number_type round_error()
3416
+ {
3417
+ // returns epsilon/2
3418
+ return 0.5;
3419
+ }
3420
+ static constexpr long min_exponent = MPFR_EMIN_DEFAULT;
3421
+ static constexpr long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
3422
+ static constexpr long max_exponent = MPFR_EMAX_DEFAULT;
3423
+ static constexpr long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
3424
+ static constexpr bool has_infinity = true;
3425
+ static constexpr bool has_quiet_NaN = true;
3426
+ static constexpr bool has_signaling_NaN = false;
3427
+ #ifdef _MSC_VER
3428
+ #pragma warning(push)
3429
+ #pragma warning(disable : 4996)
3430
+ #endif
3431
+ static constexpr float_denorm_style has_denorm = denorm_absent;
3432
+ #ifdef _MSC_VER
3433
+ #pragma warning(pop)
3434
+ #endif
3435
+ static constexpr bool has_denorm_loss = false;
3436
+ static number_type infinity()
3437
+ {
3438
+ number_type value;
3439
+ mpfr_set_inf(value.backend().data(), 1);
3440
+ return value;
3441
+ }
3442
+ static number_type quiet_NaN()
3443
+ {
3444
+ number_type value;
3445
+ mpfr_set_nan(value.backend().data());
3446
+ return value;
3447
+ }
3448
+ static constexpr number_type signaling_NaN()
3449
+ {
3450
+ return number_type(0);
3451
+ }
3452
+ static constexpr number_type denorm_min() { return (min)(); }
3453
+ static constexpr bool is_iec559 = false;
3454
+ static constexpr bool is_bounded = true;
3455
+ static constexpr bool is_modulo = false;
3456
+ static constexpr bool traps = true;
3457
+ static constexpr bool tinyness_before = false;
3458
+ static constexpr float_round_style round_style = round_to_nearest;
3459
+ };
3460
+
3461
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3462
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits;
3463
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3464
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits10;
3465
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3466
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_digits10;
3467
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3468
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_signed;
3469
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3470
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_integer;
3471
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3472
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_exact;
3473
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3474
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::radix;
3475
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3476
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent;
3477
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3478
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent10;
3479
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3480
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent;
3481
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3482
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent10;
3483
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3484
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_infinity;
3485
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3486
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_quiet_NaN;
3487
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3488
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_signaling_NaN;
3489
+ #ifdef _MSC_VER
3490
+ #pragma warning(push)
3491
+ #pragma warning(disable : 4996)
3492
+ #endif
3493
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3494
+ constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm;
3495
+ #ifdef _MSC_VER
3496
+ #pragma warning(pop)
3497
+ #endif
3498
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3499
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm_loss;
3500
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3501
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_iec559;
3502
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3503
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_bounded;
3504
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3505
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_modulo;
3506
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3507
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::traps;
3508
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3509
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::tinyness_before;
3510
+ template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
3511
+ constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::round_style;
3512
+
3513
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3514
+ class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >
3515
+ {
3516
+ using number_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates>;
3517
+
3518
+ public:
3519
+ static constexpr bool is_specialized = false;
3520
+ static number_type(min)()
3521
+ {
3522
+ number_type value(0.5);
3523
+ mpfr_div_2exp(value.backend().data(), value.backend().data(), -mpfr_get_emin(), GMP_RNDN);
3524
+ return value;
3525
+ }
3526
+ static number_type(max)()
3527
+ {
3528
+ number_type value(0.5);
3529
+ mpfr_mul_2exp(value.backend().data(), value.backend().data(), mpfr_get_emax(), GMP_RNDN);
3530
+ return value;
3531
+ }
3532
+ static number_type lowest()
3533
+ {
3534
+ return -(max)();
3535
+ }
3536
+ static constexpr int digits = INT_MAX;
3537
+ static constexpr int digits10 = INT_MAX;
3538
+ static constexpr int max_digits10 = INT_MAX;
3539
+ static constexpr bool is_signed = true;
3540
+ static constexpr bool is_integer = false;
3541
+ static constexpr bool is_exact = false;
3542
+ static constexpr int radix = 2;
3543
+ static number_type epsilon()
3544
+ {
3545
+ number_type value(1);
3546
+ mpfr_div_2exp(value.backend().data(), value.backend().data(), boost::multiprecision::detail::digits10_2_2(number_type::thread_default_precision()) - 1, GMP_RNDN);
3547
+ return value;
3548
+ }
3549
+ static number_type round_error()
3550
+ {
3551
+ return 0.5;
3552
+ }
3553
+ static constexpr long min_exponent = MPFR_EMIN_DEFAULT;
3554
+ static constexpr long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
3555
+ static constexpr long max_exponent = MPFR_EMAX_DEFAULT;
3556
+ static constexpr long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
3557
+ static constexpr bool has_infinity = true;
3558
+ static constexpr bool has_quiet_NaN = true;
3559
+ static constexpr bool has_signaling_NaN = false;
3560
+ #ifdef _MSC_VER
3561
+ #pragma warning(push)
3562
+ #pragma warning(disable : 4996)
3563
+ #endif
3564
+ static constexpr float_denorm_style has_denorm = denorm_absent;
3565
+ #ifdef _MSC_VER
3566
+ #pragma warning(pop)
3567
+ #endif
3568
+ static constexpr bool has_denorm_loss = false;
3569
+ static number_type infinity()
3570
+ {
3571
+ number_type value;
3572
+ mpfr_set_inf(value.backend().data(), 1);
3573
+ return value;
3574
+ }
3575
+ static number_type quiet_NaN()
3576
+ {
3577
+ number_type value;
3578
+ mpfr_set_nan(value.backend().data());
3579
+ return value;
3580
+ }
3581
+ static number_type signaling_NaN() { return number_type(0); }
3582
+ static number_type denorm_min() { return (min)(); }
3583
+ static constexpr bool is_iec559 = false;
3584
+ static constexpr bool is_bounded = true;
3585
+ static constexpr bool is_modulo = false;
3586
+ static constexpr bool traps = false;
3587
+ static constexpr bool tinyness_before = false;
3588
+ static constexpr float_round_style round_style = round_toward_zero;
3589
+ };
3590
+
3591
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3592
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits;
3593
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3594
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits10;
3595
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3596
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_digits10;
3597
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3598
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_signed;
3599
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3600
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_integer;
3601
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3602
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_exact;
3603
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3604
+ constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::radix;
3605
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3606
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent;
3607
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3608
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent10;
3609
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3610
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent;
3611
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3612
+ constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent10;
3613
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3614
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_infinity;
3615
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3616
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_quiet_NaN;
3617
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3618
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_signaling_NaN;
3619
+ #ifdef _MSC_VER
3620
+ #pragma warning(push)
3621
+ #pragma warning(disable : 4996)
3622
+ #endif
3623
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3624
+ constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm;
3625
+ #ifdef _MSC_VER
3626
+ #pragma warning(pop)
3627
+ #endif
3628
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3629
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm_loss;
3630
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3631
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_iec559;
3632
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3633
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_bounded;
3634
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3635
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_modulo;
3636
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3637
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::traps;
3638
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3639
+ constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::tinyness_before;
3640
+ template <boost::multiprecision::expression_template_option ExpressionTemplates>
3641
+ constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::round_style;
3642
+
3643
+ } // namespace std
3644
+ #endif