mqt-core 3.3.2__cp314-cp314t-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.
- mqt/core/__init__.py +89 -0
- mqt/core/__main__.py +55 -0
- mqt/core/_commands.py +52 -0
- mqt/core/_compat/__init__.py +11 -0
- mqt/core/_compat/typing.py +29 -0
- mqt/core/_version.py +34 -0
- mqt/core/_version.pyi +12 -0
- mqt/core/bin/mqt-core-algorithms.dll +0 -0
- mqt/core/bin/mqt-core-circuit-optimizer.dll +0 -0
- mqt/core/bin/mqt-core-dd.dll +0 -0
- mqt/core/bin/mqt-core-ds.dll +0 -0
- mqt/core/bin/mqt-core-fomac.dll +0 -0
- mqt/core/bin/mqt-core-ir.dll +0 -0
- mqt/core/bin/mqt-core-na-fomac.dll +0 -0
- mqt/core/bin/mqt-core-na.dll +0 -0
- mqt/core/bin/mqt-core-qasm.dll +0 -0
- mqt/core/bin/mqt-core-qdmi-driver.dll +0 -0
- mqt/core/bin/mqt-core-qdmi-na-device.dll +0 -0
- mqt/core/bin/mqt-core-zx.dll +0 -0
- mqt/core/dd.cp314t-win_amd64.pyd +0 -0
- mqt/core/dd.pyi +1016 -0
- mqt/core/dd_evaluation.py +368 -0
- mqt/core/fomac.cp314t-win_amd64.pyd +0 -0
- mqt/core/fomac.pyi +125 -0
- mqt/core/include/mqt-core/algorithms/BernsteinVazirani.hpp +39 -0
- mqt/core/include/mqt-core/algorithms/GHZState.hpp +18 -0
- mqt/core/include/mqt-core/algorithms/Grover.hpp +33 -0
- mqt/core/include/mqt-core/algorithms/QFT.hpp +21 -0
- mqt/core/include/mqt-core/algorithms/QPE.hpp +30 -0
- mqt/core/include/mqt-core/algorithms/RandomCliffordCircuit.hpp +22 -0
- mqt/core/include/mqt-core/algorithms/StatePreparation.hpp +43 -0
- mqt/core/include/mqt-core/algorithms/WState.hpp +18 -0
- mqt/core/include/mqt-core/algorithms/mqt_core_algorithms_export.h +43 -0
- mqt/core/include/mqt-core/boost/config/abi/borland_prefix.hpp +27 -0
- mqt/core/include/mqt-core/boost/config/abi/borland_suffix.hpp +12 -0
- mqt/core/include/mqt-core/boost/config/abi/msvc_prefix.hpp +22 -0
- mqt/core/include/mqt-core/boost/config/abi/msvc_suffix.hpp +8 -0
- mqt/core/include/mqt-core/boost/config/abi_prefix.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/abi_suffix.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx03.hpp +211 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx11.hpp +212 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx14.hpp +47 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx17.hpp +65 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx20.hpp +59 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx23.hpp +41 -0
- mqt/core/include/mqt-core/boost/config/assert_cxx98.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/auto_link.hpp +525 -0
- mqt/core/include/mqt-core/boost/config/compiler/borland.hpp +342 -0
- mqt/core/include/mqt-core/boost/config/compiler/clang.hpp +370 -0
- mqt/core/include/mqt-core/boost/config/compiler/clang_version.hpp +89 -0
- mqt/core/include/mqt-core/boost/config/compiler/codegear.hpp +389 -0
- mqt/core/include/mqt-core/boost/config/compiler/comeau.hpp +59 -0
- mqt/core/include/mqt-core/boost/config/compiler/common_edg.hpp +185 -0
- mqt/core/include/mqt-core/boost/config/compiler/compaq_cxx.hpp +19 -0
- mqt/core/include/mqt-core/boost/config/compiler/cray.hpp +446 -0
- mqt/core/include/mqt-core/boost/config/compiler/diab.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/compiler/digitalmars.hpp +146 -0
- mqt/core/include/mqt-core/boost/config/compiler/gcc.hpp +386 -0
- mqt/core/include/mqt-core/boost/config/compiler/gcc_xml.hpp +115 -0
- mqt/core/include/mqt-core/boost/config/compiler/greenhills.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/compiler/hp_acc.hpp +153 -0
- mqt/core/include/mqt-core/boost/config/compiler/intel.hpp +577 -0
- mqt/core/include/mqt-core/boost/config/compiler/kai.hpp +33 -0
- mqt/core/include/mqt-core/boost/config/compiler/metrowerks.hpp +201 -0
- mqt/core/include/mqt-core/boost/config/compiler/mpw.hpp +143 -0
- mqt/core/include/mqt-core/boost/config/compiler/nvcc.hpp +64 -0
- mqt/core/include/mqt-core/boost/config/compiler/pathscale.hpp +141 -0
- mqt/core/include/mqt-core/boost/config/compiler/pgi.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/compiler/sgi_mipspro.hpp +29 -0
- mqt/core/include/mqt-core/boost/config/compiler/sunpro_cc.hpp +225 -0
- mqt/core/include/mqt-core/boost/config/compiler/vacpp.hpp +189 -0
- mqt/core/include/mqt-core/boost/config/compiler/visualc.hpp +398 -0
- mqt/core/include/mqt-core/boost/config/compiler/xlcpp.hpp +303 -0
- mqt/core/include/mqt-core/boost/config/compiler/xlcpp_zos.hpp +174 -0
- mqt/core/include/mqt-core/boost/config/detail/cxx_composite.hpp +218 -0
- mqt/core/include/mqt-core/boost/config/detail/posix_features.hpp +95 -0
- mqt/core/include/mqt-core/boost/config/detail/select_compiler_config.hpp +157 -0
- mqt/core/include/mqt-core/boost/config/detail/select_platform_config.hpp +147 -0
- mqt/core/include/mqt-core/boost/config/detail/select_stdlib_config.hpp +121 -0
- mqt/core/include/mqt-core/boost/config/detail/suffix.hpp +1334 -0
- mqt/core/include/mqt-core/boost/config/header_deprecated.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/helper_macros.hpp +37 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/cmath.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/complex.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/functional.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/memory.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/no_tr1/utility.hpp +28 -0
- mqt/core/include/mqt-core/boost/config/platform/aix.hpp +33 -0
- mqt/core/include/mqt-core/boost/config/platform/amigaos.hpp +15 -0
- mqt/core/include/mqt-core/boost/config/platform/beos.hpp +26 -0
- mqt/core/include/mqt-core/boost/config/platform/bsd.hpp +83 -0
- mqt/core/include/mqt-core/boost/config/platform/cloudabi.hpp +18 -0
- mqt/core/include/mqt-core/boost/config/platform/cray.hpp +18 -0
- mqt/core/include/mqt-core/boost/config/platform/cygwin.hpp +71 -0
- mqt/core/include/mqt-core/boost/config/platform/haiku.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/hpux.hpp +87 -0
- mqt/core/include/mqt-core/boost/config/platform/irix.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/linux.hpp +106 -0
- mqt/core/include/mqt-core/boost/config/platform/macos.hpp +87 -0
- mqt/core/include/mqt-core/boost/config/platform/qnxnto.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/solaris.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/platform/symbian.hpp +97 -0
- mqt/core/include/mqt-core/boost/config/platform/vms.hpp +25 -0
- mqt/core/include/mqt-core/boost/config/platform/vxworks.hpp +422 -0
- mqt/core/include/mqt-core/boost/config/platform/wasm.hpp +23 -0
- mqt/core/include/mqt-core/boost/config/platform/win32.hpp +90 -0
- mqt/core/include/mqt-core/boost/config/platform/zos.hpp +32 -0
- mqt/core/include/mqt-core/boost/config/pragma_message.hpp +31 -0
- mqt/core/include/mqt-core/boost/config/requires_threads.hpp +92 -0
- mqt/core/include/mqt-core/boost/config/stdlib/dinkumware.hpp +324 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libcomo.hpp +93 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libcpp.hpp +180 -0
- mqt/core/include/mqt-core/boost/config/stdlib/libstdcpp3.hpp +482 -0
- mqt/core/include/mqt-core/boost/config/stdlib/modena.hpp +79 -0
- mqt/core/include/mqt-core/boost/config/stdlib/msl.hpp +98 -0
- mqt/core/include/mqt-core/boost/config/stdlib/roguewave.hpp +208 -0
- mqt/core/include/mqt-core/boost/config/stdlib/sgi.hpp +168 -0
- mqt/core/include/mqt-core/boost/config/stdlib/stlport.hpp +258 -0
- mqt/core/include/mqt-core/boost/config/stdlib/vacpp.hpp +74 -0
- mqt/core/include/mqt-core/boost/config/stdlib/xlcpp_zos.hpp +61 -0
- mqt/core/include/mqt-core/boost/config/user.hpp +133 -0
- mqt/core/include/mqt-core/boost/config/warning_disable.hpp +47 -0
- mqt/core/include/mqt-core/boost/config/workaround.hpp +305 -0
- mqt/core/include/mqt-core/boost/config.hpp +67 -0
- mqt/core/include/mqt-core/boost/cstdint.hpp +556 -0
- mqt/core/include/mqt-core/boost/cxx11_char_types.hpp +70 -0
- mqt/core/include/mqt-core/boost/detail/workaround.hpp +10 -0
- mqt/core/include/mqt-core/boost/limits.hpp +146 -0
- mqt/core/include/mqt-core/boost/multiprecision/complex128.hpp +24 -0
- mqt/core/include/mqt-core/boost/multiprecision/complex_adaptor.hpp +1046 -0
- mqt/core/include/mqt-core/boost/multiprecision/concepts/mp_number_archetypes.hpp +257 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/io.hpp +698 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float/transcendental.hpp +157 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_bin_float.hpp +2297 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_complex.hpp +12 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_dec_float.hpp +3690 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add.hpp +368 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/add_unsigned.hpp +387 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/bitwise.hpp +889 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/checked.hpp +178 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/comparison.hpp +374 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/cpp_int_config.hpp +161 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/divide.hpp +703 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/import_export.hpp +248 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/intel_intrinsics.hpp +138 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/limits.hpp +282 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/literals.hpp +295 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/misc.hpp +1457 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/multiply.hpp +848 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/serialize.hpp +211 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int/value_pack.hpp +42 -0
- mqt/core/include/mqt-core/boost/multiprecision/cpp_int.hpp +2360 -0
- mqt/core/include/mqt-core/boost/multiprecision/debug_adaptor.hpp +760 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/assert.hpp +29 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/atomic.hpp +62 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/bitscan.hpp +317 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/check_cpp11_config.hpp +64 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/constexpr.hpp +88 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/default_ops.hpp +4052 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/digits.hpp +49 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/dynamic_array.hpp +44 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/empty_value.hpp +87 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/endian.hpp +35 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/et_ops.hpp +1831 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/float128_functions.hpp +95 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/float_string_cvt.hpp +333 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/fpclassify.hpp +101 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/constants.hpp +288 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/pow.hpp +905 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trig.hpp +1058 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/functions/trunc.hpp +82 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/generic_interconvert.hpp +687 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/hash.hpp +56 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/integer_ops.hpp +474 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/itos.hpp +39 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/min_max.hpp +106 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/no_et_ops.hpp +661 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/no_exceptions_support.hpp +55 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/number_base.hpp +1656 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/number_compare.hpp +848 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/precision.hpp +313 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/rebind.hpp +19 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/standalone_config.hpp +148 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/static_array.hpp +42 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/string_helpers.hpp +48 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/tables.hpp +80 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/ublas_interop.hpp +75 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/uniform_int_distribution.hpp +212 -0
- mqt/core/include/mqt-core/boost/multiprecision/detail/utype_helper.hpp +374 -0
- mqt/core/include/mqt-core/boost/multiprecision/eigen.hpp +248 -0
- mqt/core/include/mqt-core/boost/multiprecision/float128.hpp +920 -0
- mqt/core/include/mqt-core/boost/multiprecision/fwd.hpp +268 -0
- mqt/core/include/mqt-core/boost/multiprecision/gmp.hpp +4060 -0
- mqt/core/include/mqt-core/boost/multiprecision/integer.hpp +363 -0
- mqt/core/include/mqt-core/boost/multiprecision/logged_adaptor.hpp +834 -0
- mqt/core/include/mqt-core/boost/multiprecision/miller_rabin.hpp +221 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpc.hpp +1721 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpfi.hpp +2559 -0
- mqt/core/include/mqt-core/boost/multiprecision/mpfr.hpp +3644 -0
- mqt/core/include/mqt-core/boost/multiprecision/number.hpp +2500 -0
- mqt/core/include/mqt-core/boost/multiprecision/random.hpp +23 -0
- mqt/core/include/mqt-core/boost/multiprecision/rational_adaptor.hpp +1289 -0
- mqt/core/include/mqt-core/boost/multiprecision/tommath.hpp +1034 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/explicit_conversion.hpp +67 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/extract_exponent_type.hpp +28 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_backend.hpp +91 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_byte_container.hpp +51 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_complex.hpp +22 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_convertible_arithmetic.hpp +51 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_restricted_conversion.hpp +47 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/is_variable_precision.hpp +25 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/max_digits10.hpp +79 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/std_integer_traits.hpp +90 -0
- mqt/core/include/mqt-core/boost/multiprecision/traits/transcendental_reduction_type.hpp +21 -0
- mqt/core/include/mqt-core/boost/version.hpp +32 -0
- mqt/core/include/mqt-core/circuit_optimizer/CircuitOptimizer.hpp +119 -0
- mqt/core/include/mqt-core/circuit_optimizer/mqt_core_circuit_optimizer_export.h +43 -0
- mqt/core/include/mqt-core/datastructures/DirectedAcyclicGraph.hpp +117 -0
- mqt/core/include/mqt-core/datastructures/DirectedGraph.hpp +158 -0
- mqt/core/include/mqt-core/datastructures/DisjointSet.hpp +50 -0
- mqt/core/include/mqt-core/datastructures/Layer.hpp +172 -0
- mqt/core/include/mqt-core/datastructures/SymmetricMatrix.hpp +57 -0
- mqt/core/include/mqt-core/datastructures/UndirectedGraph.hpp +227 -0
- mqt/core/include/mqt-core/datastructures/mqt_core_ds_export.h +43 -0
- mqt/core/include/mqt-core/dd/Approximation.hpp +45 -0
- mqt/core/include/mqt-core/dd/CachedEdge.hpp +174 -0
- mqt/core/include/mqt-core/dd/Complex.hpp +165 -0
- mqt/core/include/mqt-core/dd/ComplexNumbers.hpp +150 -0
- mqt/core/include/mqt-core/dd/ComplexValue.hpp +184 -0
- mqt/core/include/mqt-core/dd/ComputeTable.hpp +183 -0
- mqt/core/include/mqt-core/dd/DDDefinitions.hpp +139 -0
- mqt/core/include/mqt-core/dd/DDpackageConfig.hpp +104 -0
- mqt/core/include/mqt-core/dd/DensityNoiseTable.hpp +114 -0
- mqt/core/include/mqt-core/dd/Edge.hpp +416 -0
- mqt/core/include/mqt-core/dd/Export.hpp +438 -0
- mqt/core/include/mqt-core/dd/FunctionalityConstruction.hpp +75 -0
- mqt/core/include/mqt-core/dd/GateMatrixDefinitions.hpp +43 -0
- mqt/core/include/mqt-core/dd/LinkedListBase.hpp +45 -0
- mqt/core/include/mqt-core/dd/MemoryManager.hpp +193 -0
- mqt/core/include/mqt-core/dd/Node.hpp +223 -0
- mqt/core/include/mqt-core/dd/NoiseFunctionality.hpp +144 -0
- mqt/core/include/mqt-core/dd/Operations.hpp +306 -0
- mqt/core/include/mqt-core/dd/Package.hpp +2036 -0
- mqt/core/include/mqt-core/dd/Package_fwd.hpp +22 -0
- mqt/core/include/mqt-core/dd/RealNumber.hpp +255 -0
- mqt/core/include/mqt-core/dd/RealNumberUniqueTable.hpp +217 -0
- mqt/core/include/mqt-core/dd/Simulation.hpp +98 -0
- mqt/core/include/mqt-core/dd/StateGeneration.hpp +143 -0
- mqt/core/include/mqt-core/dd/StochasticNoiseOperationTable.hpp +88 -0
- mqt/core/include/mqt-core/dd/UnaryComputeTable.hpp +121 -0
- mqt/core/include/mqt-core/dd/UniqueTable.hpp +243 -0
- mqt/core/include/mqt-core/dd/mqt_core_dd_export.h +43 -0
- mqt/core/include/mqt-core/dd/statistics/MemoryManagerStatistics.hpp +84 -0
- mqt/core/include/mqt-core/dd/statistics/PackageStatistics.hpp +55 -0
- mqt/core/include/mqt-core/dd/statistics/Statistics.hpp +48 -0
- mqt/core/include/mqt-core/dd/statistics/TableStatistics.hpp +79 -0
- mqt/core/include/mqt-core/dd/statistics/UniqueTableStatistics.hpp +31 -0
- mqt/core/include/mqt-core/fomac/FoMaC.hpp +568 -0
- mqt/core/include/mqt-core/ir/Definitions.hpp +108 -0
- mqt/core/include/mqt-core/ir/Permutation.hpp +213 -0
- mqt/core/include/mqt-core/ir/QuantumComputation.hpp +596 -0
- mqt/core/include/mqt-core/ir/Register.hpp +125 -0
- mqt/core/include/mqt-core/ir/mqt_core_ir_export.h +43 -0
- mqt/core/include/mqt-core/ir/operations/AodOperation.hpp +92 -0
- mqt/core/include/mqt-core/ir/operations/CompoundOperation.hpp +212 -0
- mqt/core/include/mqt-core/ir/operations/Control.hpp +142 -0
- mqt/core/include/mqt-core/ir/operations/Expression.hpp +847 -0
- mqt/core/include/mqt-core/ir/operations/IfElseOperation.hpp +169 -0
- mqt/core/include/mqt-core/ir/operations/NonUnitaryOperation.hpp +118 -0
- mqt/core/include/mqt-core/ir/operations/OpType.hpp +120 -0
- mqt/core/include/mqt-core/ir/operations/OpType.inc +76 -0
- mqt/core/include/mqt-core/ir/operations/Operation.hpp +247 -0
- mqt/core/include/mqt-core/ir/operations/StandardOperation.hpp +140 -0
- mqt/core/include/mqt-core/ir/operations/SymbolicOperation.hpp +144 -0
- mqt/core/include/mqt-core/mqt_na_qdmi/device.h +602 -0
- mqt/core/include/mqt-core/mqt_na_qdmi/types.h +78 -0
- mqt/core/include/mqt-core/na/NAComputation.hpp +185 -0
- mqt/core/include/mqt-core/na/device/Device.hpp +410 -0
- mqt/core/include/mqt-core/na/device/DeviceMemberInitializers.hpp +724 -0
- mqt/core/include/mqt-core/na/device/Generator.hpp +447 -0
- mqt/core/include/mqt-core/na/entities/Atom.hpp +62 -0
- mqt/core/include/mqt-core/na/entities/Location.hpp +154 -0
- mqt/core/include/mqt-core/na/entities/Zone.hpp +95 -0
- mqt/core/include/mqt-core/na/fomac/Device.hpp +169 -0
- mqt/core/include/mqt-core/na/mqt_core_na_export.h +43 -0
- mqt/core/include/mqt-core/na/operations/GlobalCZOp.hpp +38 -0
- mqt/core/include/mqt-core/na/operations/GlobalOp.hpp +58 -0
- mqt/core/include/mqt-core/na/operations/GlobalRYOp.hpp +42 -0
- mqt/core/include/mqt-core/na/operations/LoadOp.hpp +89 -0
- mqt/core/include/mqt-core/na/operations/LocalOp.hpp +56 -0
- mqt/core/include/mqt-core/na/operations/LocalRZOp.hpp +42 -0
- mqt/core/include/mqt-core/na/operations/LocalUOp.hpp +49 -0
- mqt/core/include/mqt-core/na/operations/MoveOp.hpp +66 -0
- mqt/core/include/mqt-core/na/operations/Op.hpp +62 -0
- mqt/core/include/mqt-core/na/operations/ShuttlingOp.hpp +51 -0
- mqt/core/include/mqt-core/na/operations/StoreOp.hpp +87 -0
- mqt/core/include/mqt-core/qasm3/Exception.hpp +85 -0
- mqt/core/include/mqt-core/qasm3/Gate.hpp +65 -0
- mqt/core/include/mqt-core/qasm3/Importer.hpp +192 -0
- mqt/core/include/mqt-core/qasm3/InstVisitor.hpp +145 -0
- mqt/core/include/mqt-core/qasm3/NestedEnvironment.hpp +41 -0
- mqt/core/include/mqt-core/qasm3/Parser.hpp +170 -0
- mqt/core/include/mqt-core/qasm3/Scanner.hpp +73 -0
- mqt/core/include/mqt-core/qasm3/Statement.hpp +486 -0
- mqt/core/include/mqt-core/qasm3/Statement_fwd.hpp +39 -0
- mqt/core/include/mqt-core/qasm3/StdGates.hpp +232 -0
- mqt/core/include/mqt-core/qasm3/Token.hpp +198 -0
- mqt/core/include/mqt-core/qasm3/Types.hpp +238 -0
- mqt/core/include/mqt-core/qasm3/Types_fwd.hpp +22 -0
- mqt/core/include/mqt-core/qasm3/mqt_core_qasm_export.h +43 -0
- mqt/core/include/mqt-core/qasm3/passes/CompilerPass.hpp +22 -0
- mqt/core/include/mqt-core/qasm3/passes/ConstEvalPass.hpp +102 -0
- mqt/core/include/mqt-core/qasm3/passes/TypeCheckPass.hpp +124 -0
- mqt/core/include/mqt-core/qdmi/Driver.hpp +431 -0
- mqt/core/include/mqt-core/zx/FunctionalityConstruction.hpp +125 -0
- mqt/core/include/mqt-core/zx/Rational.hpp +318 -0
- mqt/core/include/mqt-core/zx/Rules.hpp +132 -0
- mqt/core/include/mqt-core/zx/Simplify.hpp +182 -0
- mqt/core/include/mqt-core/zx/Utils.hpp +212 -0
- mqt/core/include/mqt-core/zx/ZXDefinitions.hpp +93 -0
- mqt/core/include/mqt-core/zx/ZXDiagram.hpp +480 -0
- mqt/core/include/mqt-core/zx/mqt_core_zx_export.h +43 -0
- mqt/core/include/nlohmann/adl_serializer.hpp +55 -0
- mqt/core/include/nlohmann/byte_container_with_subtype.hpp +103 -0
- mqt/core/include/nlohmann/detail/abi_macros.hpp +111 -0
- mqt/core/include/nlohmann/detail/conversions/from_json.hpp +577 -0
- mqt/core/include/nlohmann/detail/conversions/to_chars.hpp +1118 -0
- mqt/core/include/nlohmann/detail/conversions/to_json.hpp +479 -0
- mqt/core/include/nlohmann/detail/exceptions.hpp +291 -0
- mqt/core/include/nlohmann/detail/hash.hpp +129 -0
- mqt/core/include/nlohmann/detail/input/binary_reader.hpp +3068 -0
- mqt/core/include/nlohmann/detail/input/input_adapters.hpp +549 -0
- mqt/core/include/nlohmann/detail/input/json_sax.hpp +986 -0
- mqt/core/include/nlohmann/detail/input/lexer.hpp +1643 -0
- mqt/core/include/nlohmann/detail/input/parser.hpp +519 -0
- mqt/core/include/nlohmann/detail/input/position_t.hpp +37 -0
- mqt/core/include/nlohmann/detail/iterators/internal_iterator.hpp +35 -0
- mqt/core/include/nlohmann/detail/iterators/iter_impl.hpp +760 -0
- mqt/core/include/nlohmann/detail/iterators/iteration_proxy.hpp +235 -0
- mqt/core/include/nlohmann/detail/iterators/iterator_traits.hpp +61 -0
- mqt/core/include/nlohmann/detail/iterators/json_reverse_iterator.hpp +130 -0
- mqt/core/include/nlohmann/detail/iterators/primitive_iterator.hpp +132 -0
- mqt/core/include/nlohmann/detail/json_custom_base_class.hpp +39 -0
- mqt/core/include/nlohmann/detail/json_pointer.hpp +988 -0
- mqt/core/include/nlohmann/detail/json_ref.hpp +78 -0
- mqt/core/include/nlohmann/detail/macro_scope.hpp +595 -0
- mqt/core/include/nlohmann/detail/macro_unscope.hpp +46 -0
- mqt/core/include/nlohmann/detail/meta/call_std/begin.hpp +17 -0
- mqt/core/include/nlohmann/detail/meta/call_std/end.hpp +17 -0
- mqt/core/include/nlohmann/detail/meta/cpp_future.hpp +171 -0
- mqt/core/include/nlohmann/detail/meta/detected.hpp +70 -0
- mqt/core/include/nlohmann/detail/meta/identity_tag.hpp +21 -0
- mqt/core/include/nlohmann/detail/meta/is_sax.hpp +159 -0
- mqt/core/include/nlohmann/detail/meta/std_fs.hpp +29 -0
- mqt/core/include/nlohmann/detail/meta/type_traits.hpp +795 -0
- mqt/core/include/nlohmann/detail/meta/void_t.hpp +24 -0
- mqt/core/include/nlohmann/detail/output/binary_writer.hpp +1850 -0
- mqt/core/include/nlohmann/detail/output/output_adapters.hpp +147 -0
- mqt/core/include/nlohmann/detail/output/serializer.hpp +988 -0
- mqt/core/include/nlohmann/detail/string_concat.hpp +146 -0
- mqt/core/include/nlohmann/detail/string_escape.hpp +72 -0
- mqt/core/include/nlohmann/detail/string_utils.hpp +37 -0
- mqt/core/include/nlohmann/detail/value_t.hpp +118 -0
- mqt/core/include/nlohmann/json.hpp +5306 -0
- mqt/core/include/nlohmann/json_fwd.hpp +75 -0
- mqt/core/include/nlohmann/ordered_map.hpp +359 -0
- mqt/core/include/nlohmann/thirdparty/hedley/hedley.hpp +2045 -0
- mqt/core/include/nlohmann/thirdparty/hedley/hedley_undef.hpp +158 -0
- mqt/core/include/qdmi/qdmi/client.h +990 -0
- mqt/core/include/qdmi/qdmi/constants.h +1139 -0
- mqt/core/include/qdmi/qdmi/device.h +602 -0
- mqt/core/include/qdmi/qdmi/types.h +78 -0
- mqt/core/include/spdlog/async.h +99 -0
- mqt/core/include/spdlog/async_logger-inl.h +84 -0
- mqt/core/include/spdlog/async_logger.h +74 -0
- mqt/core/include/spdlog/cfg/argv.h +40 -0
- mqt/core/include/spdlog/cfg/env.h +36 -0
- mqt/core/include/spdlog/cfg/helpers-inl.h +107 -0
- mqt/core/include/spdlog/cfg/helpers.h +29 -0
- mqt/core/include/spdlog/common-inl.h +68 -0
- mqt/core/include/spdlog/common.h +406 -0
- mqt/core/include/spdlog/details/backtracer-inl.h +63 -0
- mqt/core/include/spdlog/details/backtracer.h +45 -0
- mqt/core/include/spdlog/details/circular_q.h +115 -0
- mqt/core/include/spdlog/details/console_globals.h +28 -0
- mqt/core/include/spdlog/details/file_helper-inl.h +153 -0
- mqt/core/include/spdlog/details/file_helper.h +61 -0
- mqt/core/include/spdlog/details/fmt_helper.h +141 -0
- mqt/core/include/spdlog/details/log_msg-inl.h +44 -0
- mqt/core/include/spdlog/details/log_msg.h +40 -0
- mqt/core/include/spdlog/details/log_msg_buffer-inl.h +54 -0
- mqt/core/include/spdlog/details/log_msg_buffer.h +32 -0
- mqt/core/include/spdlog/details/mpmc_blocking_q.h +177 -0
- mqt/core/include/spdlog/details/null_mutex.h +35 -0
- mqt/core/include/spdlog/details/os-inl.h +606 -0
- mqt/core/include/spdlog/details/os.h +127 -0
- mqt/core/include/spdlog/details/periodic_worker-inl.h +26 -0
- mqt/core/include/spdlog/details/periodic_worker.h +58 -0
- mqt/core/include/spdlog/details/registry-inl.h +270 -0
- mqt/core/include/spdlog/details/registry.h +131 -0
- mqt/core/include/spdlog/details/synchronous_factory.h +22 -0
- mqt/core/include/spdlog/details/tcp_client-windows.h +135 -0
- mqt/core/include/spdlog/details/tcp_client.h +127 -0
- mqt/core/include/spdlog/details/thread_pool-inl.h +126 -0
- mqt/core/include/spdlog/details/thread_pool.h +117 -0
- mqt/core/include/spdlog/details/udp_client-windows.h +98 -0
- mqt/core/include/spdlog/details/udp_client.h +81 -0
- mqt/core/include/spdlog/details/windows_include.h +11 -0
- mqt/core/include/spdlog/fmt/bin_to_hex.h +224 -0
- mqt/core/include/spdlog/fmt/bundled/args.h +220 -0
- mqt/core/include/spdlog/fmt/bundled/base.h +2989 -0
- mqt/core/include/spdlog/fmt/bundled/chrono.h +2330 -0
- mqt/core/include/spdlog/fmt/bundled/color.h +637 -0
- mqt/core/include/spdlog/fmt/bundled/compile.h +539 -0
- mqt/core/include/spdlog/fmt/bundled/core.h +5 -0
- mqt/core/include/spdlog/fmt/bundled/fmt.license.rst +27 -0
- mqt/core/include/spdlog/fmt/bundled/format-inl.h +1948 -0
- mqt/core/include/spdlog/fmt/bundled/format.h +4244 -0
- mqt/core/include/spdlog/fmt/bundled/os.h +427 -0
- mqt/core/include/spdlog/fmt/bundled/ostream.h +167 -0
- mqt/core/include/spdlog/fmt/bundled/printf.h +633 -0
- mqt/core/include/spdlog/fmt/bundled/ranges.h +850 -0
- mqt/core/include/spdlog/fmt/bundled/std.h +728 -0
- mqt/core/include/spdlog/fmt/bundled/xchar.h +369 -0
- mqt/core/include/spdlog/fmt/chrono.h +23 -0
- mqt/core/include/spdlog/fmt/compile.h +23 -0
- mqt/core/include/spdlog/fmt/fmt.h +30 -0
- mqt/core/include/spdlog/fmt/ostr.h +23 -0
- mqt/core/include/spdlog/fmt/ranges.h +23 -0
- mqt/core/include/spdlog/fmt/std.h +24 -0
- mqt/core/include/spdlog/fmt/xchar.h +23 -0
- mqt/core/include/spdlog/formatter.h +17 -0
- mqt/core/include/spdlog/fwd.h +18 -0
- mqt/core/include/spdlog/logger-inl.h +198 -0
- mqt/core/include/spdlog/logger.h +379 -0
- mqt/core/include/spdlog/mdc.h +52 -0
- mqt/core/include/spdlog/pattern_formatter-inl.h +1340 -0
- mqt/core/include/spdlog/pattern_formatter.h +118 -0
- mqt/core/include/spdlog/sinks/android_sink.h +137 -0
- mqt/core/include/spdlog/sinks/ansicolor_sink-inl.h +142 -0
- mqt/core/include/spdlog/sinks/ansicolor_sink.h +116 -0
- mqt/core/include/spdlog/sinks/base_sink-inl.h +59 -0
- mqt/core/include/spdlog/sinks/base_sink.h +51 -0
- mqt/core/include/spdlog/sinks/basic_file_sink-inl.h +48 -0
- mqt/core/include/spdlog/sinks/basic_file_sink.h +66 -0
- mqt/core/include/spdlog/sinks/callback_sink.h +56 -0
- mqt/core/include/spdlog/sinks/daily_file_sink.h +254 -0
- mqt/core/include/spdlog/sinks/dist_sink.h +81 -0
- mqt/core/include/spdlog/sinks/dup_filter_sink.h +91 -0
- mqt/core/include/spdlog/sinks/hourly_file_sink.h +193 -0
- mqt/core/include/spdlog/sinks/kafka_sink.h +119 -0
- mqt/core/include/spdlog/sinks/mongo_sink.h +108 -0
- mqt/core/include/spdlog/sinks/msvc_sink.h +68 -0
- mqt/core/include/spdlog/sinks/null_sink.h +41 -0
- mqt/core/include/spdlog/sinks/ostream_sink.h +43 -0
- mqt/core/include/spdlog/sinks/qt_sinks.h +304 -0
- mqt/core/include/spdlog/sinks/ringbuffer_sink.h +67 -0
- mqt/core/include/spdlog/sinks/rotating_file_sink-inl.h +179 -0
- mqt/core/include/spdlog/sinks/rotating_file_sink.h +93 -0
- mqt/core/include/spdlog/sinks/sink-inl.h +22 -0
- mqt/core/include/spdlog/sinks/sink.h +34 -0
- mqt/core/include/spdlog/sinks/stdout_color_sinks-inl.h +38 -0
- mqt/core/include/spdlog/sinks/stdout_color_sinks.h +49 -0
- mqt/core/include/spdlog/sinks/stdout_sinks-inl.h +127 -0
- mqt/core/include/spdlog/sinks/stdout_sinks.h +84 -0
- mqt/core/include/spdlog/sinks/syslog_sink.h +104 -0
- mqt/core/include/spdlog/sinks/systemd_sink.h +121 -0
- mqt/core/include/spdlog/sinks/tcp_sink.h +75 -0
- mqt/core/include/spdlog/sinks/udp_sink.h +69 -0
- mqt/core/include/spdlog/sinks/win_eventlog_sink.h +260 -0
- mqt/core/include/spdlog/sinks/wincolor_sink-inl.h +172 -0
- mqt/core/include/spdlog/sinks/wincolor_sink.h +82 -0
- mqt/core/include/spdlog/spdlog-inl.h +96 -0
- mqt/core/include/spdlog/spdlog.h +357 -0
- mqt/core/include/spdlog/stopwatch.h +66 -0
- mqt/core/include/spdlog/tweakme.h +148 -0
- mqt/core/include/spdlog/version.h +11 -0
- mqt/core/ir/__init__.pyi +2078 -0
- mqt/core/ir/operations.pyi +1011 -0
- mqt/core/ir/registers.pyi +91 -0
- mqt/core/ir/symbolic.pyi +177 -0
- mqt/core/ir.cp314t-win_amd64.pyd +0 -0
- mqt/core/lib/mqt-core-algorithms.lib +0 -0
- mqt/core/lib/mqt-core-circuit-optimizer.lib +0 -0
- mqt/core/lib/mqt-core-dd.lib +0 -0
- mqt/core/lib/mqt-core-ds.lib +0 -0
- mqt/core/lib/mqt-core-fomac.lib +0 -0
- mqt/core/lib/mqt-core-ir.lib +0 -0
- mqt/core/lib/mqt-core-na-fomac.lib +0 -0
- mqt/core/lib/mqt-core-na.lib +0 -0
- mqt/core/lib/mqt-core-qasm.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-driver.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-na-device-gen.lib +0 -0
- mqt/core/lib/mqt-core-qdmi-na-device.lib +0 -0
- mqt/core/lib/mqt-core-zx.lib +0 -0
- mqt/core/lib/pkgconfig/spdlog.pc +13 -0
- mqt/core/lib/spdlog.lib +0 -0
- mqt/core/na/__init__.py +12 -0
- mqt/core/na/fomac.cp314t-win_amd64.pyd +0 -0
- mqt/core/na/fomac.pyi +117 -0
- mqt/core/nlohmann_json.natvis +278 -0
- mqt/core/plugins/__init__.py +9 -0
- mqt/core/plugins/qiskit/__init__.py +19 -0
- mqt/core/plugins/qiskit/mqt_to_qiskit.py +420 -0
- mqt/core/plugins/qiskit/qiskit_to_mqt.py +562 -0
- mqt/core/py.typed +2 -0
- mqt/core/share/cmake/mqt-core/AddMQTPythonBinding.cmake +55 -0
- mqt/core/share/cmake/mqt-core/Cache.cmake +33 -0
- mqt/core/share/cmake/mqt-core/FindGMP.cmake +103 -0
- mqt/core/share/cmake/mqt-core/PackageAddTest.cmake +46 -0
- mqt/core/share/cmake/mqt-core/PreventInSourceBuilds.cmake +25 -0
- mqt/core/share/cmake/mqt-core/StandardProjectSettings.cmake +87 -0
- mqt/core/share/cmake/mqt-core/mqt-core-config-version.cmake +85 -0
- mqt/core/share/cmake/mqt-core/mqt-core-config.cmake +52 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets-release.cmake +141 -0
- mqt/core/share/cmake/mqt-core/mqt-core-targets.cmake +445 -0
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake +15 -0
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake +20 -0
- mqt/core/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake +110 -0
- mqt/core/share/cmake/qdmi/Cache.cmake +44 -0
- mqt/core/share/cmake/qdmi/PrefixHandling.cmake +78 -0
- mqt/core/share/cmake/qdmi/prefix_defs.txt +26 -0
- mqt/core/share/cmake/qdmi/qdmi-config-version.cmake +85 -0
- mqt/core/share/cmake/qdmi/qdmi-config.cmake +42 -0
- mqt/core/share/cmake/qdmi/qdmi-targets.cmake +129 -0
- mqt/core/share/cmake/spdlog/spdlogConfig.cmake +44 -0
- mqt/core/share/cmake/spdlog/spdlogConfigTargets-release.cmake +19 -0
- mqt/core/share/cmake/spdlog/spdlogConfigTargets.cmake +121 -0
- mqt/core/share/cmake/spdlog/spdlogConfigVersion.cmake +65 -0
- mqt/core/share/pkgconfig/nlohmann_json.pc +7 -0
- mqt_core-3.3.2.dist-info/DELVEWHEEL +2 -0
- mqt_core-3.3.2.dist-info/METADATA +210 -0
- mqt_core-3.3.2.dist-info/RECORD +537 -0
- mqt_core-3.3.2.dist-info/WHEEL +5 -0
- mqt_core-3.3.2.dist-info/entry_points.txt +4 -0
- mqt_core-3.3.2.dist-info/licenses/LICENSE.md +22 -0
- mqt_core.libs/msvcp140.dll +0 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright 2013 John Maddock. Distributed under the Boost
|
|
3
|
+
// Software License, Version 1.0. (See accompanying file
|
|
4
|
+
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
|
5
|
+
|
|
6
|
+
#ifndef BOOST_MP_CPP_BIN_FLOAT_IO_HPP
|
|
7
|
+
#define BOOST_MP_CPP_BIN_FLOAT_IO_HPP
|
|
8
|
+
|
|
9
|
+
#include <boost/multiprecision/detail/no_exceptions_support.hpp>
|
|
10
|
+
#include <boost/multiprecision/detail/assert.hpp>
|
|
11
|
+
|
|
12
|
+
namespace boost { namespace multiprecision {
|
|
13
|
+
namespace cpp_bf_io_detail {
|
|
14
|
+
|
|
15
|
+
//
|
|
16
|
+
// Multiplies a by b and shifts the result so it fits inside max_bits bits,
|
|
17
|
+
// returns by how much the result was shifted.
|
|
18
|
+
//
|
|
19
|
+
template <class I>
|
|
20
|
+
inline I restricted_multiply(cpp_int& result, const cpp_int& a, const cpp_int& b, I max_bits, std::int64_t& error)
|
|
21
|
+
{
|
|
22
|
+
using local_integral_type = I;
|
|
23
|
+
|
|
24
|
+
result = a * b;
|
|
25
|
+
local_integral_type gb = static_cast<local_integral_type>(msb(result));
|
|
26
|
+
local_integral_type rshift = 0;
|
|
27
|
+
if (gb > max_bits)
|
|
28
|
+
{
|
|
29
|
+
rshift = gb - max_bits;
|
|
30
|
+
local_integral_type lb = static_cast<local_integral_type>(lsb(result));
|
|
31
|
+
int roundup = 0;
|
|
32
|
+
// The error rate increases by the error of both a and b,
|
|
33
|
+
// this may be overly pessimistic in many case as we're assuming
|
|
34
|
+
// that a and b have the same level of uncertainty...
|
|
35
|
+
if (lb < rshift)
|
|
36
|
+
error = error ? error * 2 : 1;
|
|
37
|
+
if (rshift)
|
|
38
|
+
{
|
|
39
|
+
BOOST_MP_ASSERT(rshift < INT_MAX);
|
|
40
|
+
if (bit_test(result, static_cast<unsigned>(rshift - 1)))
|
|
41
|
+
{
|
|
42
|
+
if (lb == rshift - 1)
|
|
43
|
+
roundup = 1;
|
|
44
|
+
else
|
|
45
|
+
roundup = 2;
|
|
46
|
+
}
|
|
47
|
+
result >>= rshift;
|
|
48
|
+
}
|
|
49
|
+
if ((roundup == 2) || ((roundup == 1) && (result.backend().limbs()[0] & 1)))
|
|
50
|
+
++result;
|
|
51
|
+
}
|
|
52
|
+
return rshift;
|
|
53
|
+
}
|
|
54
|
+
//
|
|
55
|
+
// Computes a^e shifted to the right so it fits in max_bits, returns how far
|
|
56
|
+
// to the right we are shifted.
|
|
57
|
+
//
|
|
58
|
+
template <class I>
|
|
59
|
+
inline I restricted_pow(cpp_int& result, const cpp_int& a, I e, I max_bits, std::int64_t& error)
|
|
60
|
+
{
|
|
61
|
+
BOOST_MP_ASSERT(&result != &a);
|
|
62
|
+
I exp = 0;
|
|
63
|
+
if (e == 1)
|
|
64
|
+
{
|
|
65
|
+
result = a;
|
|
66
|
+
return exp;
|
|
67
|
+
}
|
|
68
|
+
else if (e == 2)
|
|
69
|
+
{
|
|
70
|
+
return restricted_multiply(result, a, a, max_bits, error);
|
|
71
|
+
}
|
|
72
|
+
else if (e == 3)
|
|
73
|
+
{
|
|
74
|
+
exp = restricted_multiply(result, a, a, max_bits, error);
|
|
75
|
+
exp += restricted_multiply(result, result, a, max_bits, error);
|
|
76
|
+
return exp;
|
|
77
|
+
}
|
|
78
|
+
I p = e / 2;
|
|
79
|
+
exp = restricted_pow(result, a, p, max_bits, error);
|
|
80
|
+
exp *= 2;
|
|
81
|
+
exp += restricted_multiply(result, result, result, max_bits, error);
|
|
82
|
+
if (e & 1)
|
|
83
|
+
exp += restricted_multiply(result, result, a, max_bits, error);
|
|
84
|
+
return exp;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
inline int get_round_mode(const cpp_int& what, std::int64_t location, std::int64_t error)
|
|
88
|
+
{
|
|
89
|
+
//
|
|
90
|
+
// Can we round what at /location/, if the error in what is /error/ in
|
|
91
|
+
// units of 0.5ulp. Return:
|
|
92
|
+
//
|
|
93
|
+
// -1: Can't round.
|
|
94
|
+
// 0: leave as is.
|
|
95
|
+
// 1: tie.
|
|
96
|
+
// 2: round up.
|
|
97
|
+
//
|
|
98
|
+
BOOST_MP_ASSERT(location >= 0);
|
|
99
|
+
BOOST_MP_ASSERT(location < INT_MAX);
|
|
100
|
+
std::int64_t error_radius = error & 1 ? (1 + error) / 2 : error / 2;
|
|
101
|
+
if (error_radius && (static_cast<int>(msb(error_radius)) >= location))
|
|
102
|
+
return -1;
|
|
103
|
+
if (bit_test(what, static_cast<unsigned>(location)))
|
|
104
|
+
{
|
|
105
|
+
if (static_cast<int>(lsb(what)) == location)
|
|
106
|
+
return error ? -1 : 1; // Either a tie or can't round depending on whether we have any error
|
|
107
|
+
if (!error)
|
|
108
|
+
return 2; // no error, round up.
|
|
109
|
+
cpp_int t = what - error_radius;
|
|
110
|
+
if (static_cast<int>(lsb(t)) >= location)
|
|
111
|
+
return -1;
|
|
112
|
+
return 2;
|
|
113
|
+
}
|
|
114
|
+
else if (error)
|
|
115
|
+
{
|
|
116
|
+
cpp_int t = what + error_radius;
|
|
117
|
+
return bit_test(t, static_cast<unsigned>(location)) ? -1 : 0;
|
|
118
|
+
}
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
inline int get_round_mode(cpp_int& r, cpp_int& d, std::int64_t error, const cpp_int& q)
|
|
123
|
+
{
|
|
124
|
+
//
|
|
125
|
+
// Lets suppose we have an inexact division by d+delta, where the true
|
|
126
|
+
// value for the divisor is d, and with |delta| <= error/2, then
|
|
127
|
+
// we have calculated q and r such that:
|
|
128
|
+
//
|
|
129
|
+
// n r
|
|
130
|
+
// --- = q + -----------
|
|
131
|
+
// d + error d + error
|
|
132
|
+
//
|
|
133
|
+
// Rearranging for n / d we get:
|
|
134
|
+
//
|
|
135
|
+
// n delta*q + r
|
|
136
|
+
// --- = q + -------------
|
|
137
|
+
// d d
|
|
138
|
+
//
|
|
139
|
+
// So rounding depends on whether 2r + error * q > d.
|
|
140
|
+
//
|
|
141
|
+
// We return:
|
|
142
|
+
// 0 = down down.
|
|
143
|
+
// 1 = tie.
|
|
144
|
+
// 2 = round up.
|
|
145
|
+
// -1 = couldn't decide.
|
|
146
|
+
//
|
|
147
|
+
r <<= 1;
|
|
148
|
+
int c = r.compare(d);
|
|
149
|
+
if (c == 0)
|
|
150
|
+
return error ? -1 : 1;
|
|
151
|
+
if (c > 0)
|
|
152
|
+
{
|
|
153
|
+
if (error)
|
|
154
|
+
{
|
|
155
|
+
r -= error * q;
|
|
156
|
+
return r.compare(d) > 0 ? 2 : -1;
|
|
157
|
+
}
|
|
158
|
+
return 2;
|
|
159
|
+
}
|
|
160
|
+
if (error)
|
|
161
|
+
{
|
|
162
|
+
r += error * q;
|
|
163
|
+
return r.compare(d) < 0 ? 0 : -1;
|
|
164
|
+
}
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
} // namespace cpp_bf_io_detail
|
|
169
|
+
|
|
170
|
+
namespace backends {
|
|
171
|
+
|
|
172
|
+
template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
|
|
173
|
+
cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>& cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::operator=(const char* s)
|
|
174
|
+
{
|
|
175
|
+
cpp_int n;
|
|
176
|
+
std::intmax_t decimal_exp = 0;
|
|
177
|
+
std::intmax_t digits_seen = 0;
|
|
178
|
+
constexpr std::intmax_t max_digits_seen = 4 + (cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count * 301L) / 1000;
|
|
179
|
+
bool ss = false;
|
|
180
|
+
//
|
|
181
|
+
// Extract the sign:
|
|
182
|
+
//
|
|
183
|
+
if (*s == '-')
|
|
184
|
+
{
|
|
185
|
+
ss = true;
|
|
186
|
+
++s;
|
|
187
|
+
}
|
|
188
|
+
else if (*s == '+')
|
|
189
|
+
++s;
|
|
190
|
+
//
|
|
191
|
+
// Special cases first:
|
|
192
|
+
//
|
|
193
|
+
if ((std::strcmp(s, "nan") == 0) || (std::strcmp(s, "NaN") == 0) || (std::strcmp(s, "NAN") == 0))
|
|
194
|
+
{
|
|
195
|
+
return *this = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::quiet_NaN().backend();
|
|
196
|
+
}
|
|
197
|
+
if ((std::strcmp(s, "inf") == 0) || (std::strcmp(s, "Inf") == 0) || (std::strcmp(s, "INF") == 0) || (std::strcmp(s, "infinity") == 0) || (std::strcmp(s, "Infinity") == 0) || (std::strcmp(s, "INFINITY") == 0))
|
|
198
|
+
{
|
|
199
|
+
*this = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::infinity().backend();
|
|
200
|
+
if (ss)
|
|
201
|
+
negate();
|
|
202
|
+
return *this;
|
|
203
|
+
}
|
|
204
|
+
//
|
|
205
|
+
// Digits before the point:
|
|
206
|
+
//
|
|
207
|
+
while (*s && (*s >= '0') && (*s <= '9'))
|
|
208
|
+
{
|
|
209
|
+
n *= 10u;
|
|
210
|
+
n += *s - '0';
|
|
211
|
+
if (digits_seen || (*s != '0'))
|
|
212
|
+
++digits_seen;
|
|
213
|
+
++s;
|
|
214
|
+
}
|
|
215
|
+
// The decimal point (we really should localise this!!)
|
|
216
|
+
if (*s && (*s == '.'))
|
|
217
|
+
++s;
|
|
218
|
+
//
|
|
219
|
+
// Digits after the point:
|
|
220
|
+
//
|
|
221
|
+
while (*s && (*s >= '0') && (*s <= '9'))
|
|
222
|
+
{
|
|
223
|
+
n *= 10u;
|
|
224
|
+
n += *s - '0';
|
|
225
|
+
--decimal_exp;
|
|
226
|
+
if (digits_seen || (*s != '0'))
|
|
227
|
+
++digits_seen;
|
|
228
|
+
++s;
|
|
229
|
+
if (digits_seen > max_digits_seen)
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
//
|
|
233
|
+
// Digits we're skipping:
|
|
234
|
+
//
|
|
235
|
+
while (*s && (*s >= '0') && (*s <= '9'))
|
|
236
|
+
++s;
|
|
237
|
+
//
|
|
238
|
+
// See if there's an exponent:
|
|
239
|
+
//
|
|
240
|
+
if (*s && ((*s == 'e') || (*s == 'E')))
|
|
241
|
+
{
|
|
242
|
+
++s;
|
|
243
|
+
std::intmax_t e = 0;
|
|
244
|
+
bool es = false;
|
|
245
|
+
if (*s && (*s == '-'))
|
|
246
|
+
{
|
|
247
|
+
es = true;
|
|
248
|
+
++s;
|
|
249
|
+
}
|
|
250
|
+
else if (*s && (*s == '+'))
|
|
251
|
+
++s;
|
|
252
|
+
while (*s && (*s >= '0') && (*s <= '9'))
|
|
253
|
+
{
|
|
254
|
+
e *= 10u;
|
|
255
|
+
e += *s - '0';
|
|
256
|
+
++s;
|
|
257
|
+
}
|
|
258
|
+
if (es)
|
|
259
|
+
e = -e;
|
|
260
|
+
decimal_exp += e;
|
|
261
|
+
}
|
|
262
|
+
if (*s)
|
|
263
|
+
{
|
|
264
|
+
//
|
|
265
|
+
// Oops unexpected input at the end of the number:
|
|
266
|
+
//
|
|
267
|
+
BOOST_MP_THROW_EXCEPTION(std::runtime_error("Unable to parse string as a valid floating point number."));
|
|
268
|
+
}
|
|
269
|
+
if (n == 0)
|
|
270
|
+
{
|
|
271
|
+
// Result is necessarily zero:
|
|
272
|
+
*this = static_cast<limb_type>(0u);
|
|
273
|
+
return *this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
constexpr std::size_t limb_bits = sizeof(limb_type) * CHAR_BIT;
|
|
277
|
+
//
|
|
278
|
+
// Set our working precision - this is heuristic based, we want
|
|
279
|
+
// a value as small as possible > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count to avoid large computations
|
|
280
|
+
// and excessive memory usage, but we also want to avoid having to
|
|
281
|
+
// up the computation and start again at a higher precision.
|
|
282
|
+
// So we round cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count up to the nearest whole number of limbs, and add
|
|
283
|
+
// one limb for good measure. This works very well for small exponents,
|
|
284
|
+
// but for larger exponents we may may need to restart, we could add some
|
|
285
|
+
// extra precision right from the start for larger exponents, but this
|
|
286
|
+
// seems to be slightly slower in the *average* case:
|
|
287
|
+
//
|
|
288
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
289
|
+
std::intmax_t max_bits = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + 32;
|
|
290
|
+
#else
|
|
291
|
+
std::intmax_t max_bits = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + ((cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count % limb_bits) ? (limb_bits - cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count % limb_bits) : 0) + limb_bits;
|
|
292
|
+
#endif
|
|
293
|
+
std::int64_t error = 0;
|
|
294
|
+
std::intmax_t calc_exp = 0;
|
|
295
|
+
std::intmax_t final_exponent = 0;
|
|
296
|
+
|
|
297
|
+
if (decimal_exp >= 0)
|
|
298
|
+
{
|
|
299
|
+
// Nice and simple, the result is an integer...
|
|
300
|
+
do
|
|
301
|
+
{
|
|
302
|
+
cpp_int t;
|
|
303
|
+
if (decimal_exp)
|
|
304
|
+
{
|
|
305
|
+
calc_exp = boost::multiprecision::cpp_bf_io_detail::restricted_pow(t, cpp_int(5), decimal_exp, max_bits, error);
|
|
306
|
+
calc_exp += boost::multiprecision::cpp_bf_io_detail::restricted_multiply(t, t, n, max_bits, error);
|
|
307
|
+
}
|
|
308
|
+
else
|
|
309
|
+
t = n;
|
|
310
|
+
final_exponent = (std::int64_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 + decimal_exp + calc_exp;
|
|
311
|
+
std::ptrdiff_t rshift = static_cast<std::ptrdiff_t>(static_cast<std::ptrdiff_t>(msb(t)) - static_cast<std::ptrdiff_t>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count) + 1);
|
|
312
|
+
if (rshift > 0)
|
|
313
|
+
{
|
|
314
|
+
final_exponent += rshift;
|
|
315
|
+
int roundup = boost::multiprecision::cpp_bf_io_detail::get_round_mode(t, rshift - 1, error);
|
|
316
|
+
t >>= rshift;
|
|
317
|
+
if ((roundup == 2) || ((roundup == 1) && t.backend().limbs()[0] & 1))
|
|
318
|
+
++t;
|
|
319
|
+
else if (roundup < 0)
|
|
320
|
+
{
|
|
321
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
322
|
+
max_bits += 32;
|
|
323
|
+
#else
|
|
324
|
+
max_bits *= 2;
|
|
325
|
+
#endif
|
|
326
|
+
error = 0;
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
else
|
|
331
|
+
{
|
|
332
|
+
BOOST_MP_ASSERT(!error);
|
|
333
|
+
}
|
|
334
|
+
if (final_exponent > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
|
|
335
|
+
{
|
|
336
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
|
|
337
|
+
final_exponent -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
|
|
338
|
+
}
|
|
339
|
+
else if (final_exponent < cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent)
|
|
340
|
+
{
|
|
341
|
+
// Underflow:
|
|
342
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
|
|
343
|
+
final_exponent -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
|
|
344
|
+
}
|
|
345
|
+
else
|
|
346
|
+
{
|
|
347
|
+
exponent() = static_cast<Exponent>(final_exponent);
|
|
348
|
+
final_exponent = 0;
|
|
349
|
+
}
|
|
350
|
+
copy_and_round(*this, t.backend());
|
|
351
|
+
break;
|
|
352
|
+
} while (true);
|
|
353
|
+
|
|
354
|
+
if (ss != sign())
|
|
355
|
+
negate();
|
|
356
|
+
}
|
|
357
|
+
else
|
|
358
|
+
{
|
|
359
|
+
// Result is the ratio of two integers: we need to organise the
|
|
360
|
+
// division so as to produce at least an N-bit result which we can
|
|
361
|
+
// round according to the remainder.
|
|
362
|
+
//cpp_int d = pow(cpp_int(5), -decimal_exp);
|
|
363
|
+
do
|
|
364
|
+
{
|
|
365
|
+
cpp_int d;
|
|
366
|
+
calc_exp = boost::multiprecision::cpp_bf_io_detail::restricted_pow(d, cpp_int(5), -decimal_exp, max_bits, error);
|
|
367
|
+
const std::ptrdiff_t shift = static_cast<std::ptrdiff_t>(static_cast<std::ptrdiff_t>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count) - static_cast<std::ptrdiff_t>(msb(n)) + static_cast<std::ptrdiff_t>(msb(d)));
|
|
368
|
+
final_exponent = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1 + decimal_exp - calc_exp;
|
|
369
|
+
if (shift > 0)
|
|
370
|
+
{
|
|
371
|
+
n <<= shift;
|
|
372
|
+
final_exponent -= static_cast<Exponent>(shift);
|
|
373
|
+
}
|
|
374
|
+
cpp_int q, r;
|
|
375
|
+
divide_qr(n, d, q, r);
|
|
376
|
+
std::ptrdiff_t gb = static_cast<std::ptrdiff_t>(msb(q));
|
|
377
|
+
BOOST_MP_ASSERT((gb >= static_cast<int>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count) - 1));
|
|
378
|
+
//
|
|
379
|
+
// Check for rounding conditions we have to
|
|
380
|
+
// handle ourselves:
|
|
381
|
+
//
|
|
382
|
+
int roundup = 0;
|
|
383
|
+
if (gb == cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1)
|
|
384
|
+
{
|
|
385
|
+
// Exactly the right number of bits, use the remainder to round:
|
|
386
|
+
roundup = boost::multiprecision::cpp_bf_io_detail::get_round_mode(r, d, error, q);
|
|
387
|
+
}
|
|
388
|
+
else if (bit_test(q, static_cast<std::size_t>(gb - static_cast<std::ptrdiff_t>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count))) && (static_cast<std::ptrdiff_t>(lsb(q)) == static_cast<std::ptrdiff_t>(gb - static_cast<std::ptrdiff_t>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count))))
|
|
389
|
+
{
|
|
390
|
+
// Too many bits in q and the bits in q indicate a tie, but we can break that using r,
|
|
391
|
+
// note that the radius of error in r is error/2 * q:
|
|
392
|
+
std::ptrdiff_t lshift = gb - static_cast<int>(cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count) + 1;
|
|
393
|
+
q >>= lshift;
|
|
394
|
+
final_exponent += static_cast<Exponent>(lshift);
|
|
395
|
+
BOOST_MP_ASSERT((msb(q) >= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - 1));
|
|
396
|
+
if (error && (r < (error / 2) * q))
|
|
397
|
+
roundup = -1;
|
|
398
|
+
else if (error && (r + (error / 2) * q >= d))
|
|
399
|
+
roundup = -1;
|
|
400
|
+
else
|
|
401
|
+
roundup = r ? 2 : 1;
|
|
402
|
+
}
|
|
403
|
+
else if (error && (((error / 2) * q + r >= d) || (r < (error / 2) * q)))
|
|
404
|
+
{
|
|
405
|
+
// We might have been rounding up, or got the wrong quotient: can't tell!
|
|
406
|
+
roundup = -1;
|
|
407
|
+
}
|
|
408
|
+
if (roundup < 0)
|
|
409
|
+
{
|
|
410
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
411
|
+
max_bits += 32;
|
|
412
|
+
#else
|
|
413
|
+
max_bits *= 2;
|
|
414
|
+
#endif
|
|
415
|
+
error = 0;
|
|
416
|
+
if (shift > 0)
|
|
417
|
+
{
|
|
418
|
+
n >>= shift;
|
|
419
|
+
final_exponent += static_cast<Exponent>(shift);
|
|
420
|
+
}
|
|
421
|
+
continue;
|
|
422
|
+
}
|
|
423
|
+
else if ((roundup == 2) || ((roundup == 1) && q.backend().limbs()[0] & 1))
|
|
424
|
+
++q;
|
|
425
|
+
if (final_exponent > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
|
|
426
|
+
{
|
|
427
|
+
// Overflow:
|
|
428
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
|
|
429
|
+
final_exponent -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent;
|
|
430
|
+
}
|
|
431
|
+
else if (final_exponent < cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent)
|
|
432
|
+
{
|
|
433
|
+
// Underflow:
|
|
434
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
|
|
435
|
+
final_exponent -= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent;
|
|
436
|
+
}
|
|
437
|
+
else
|
|
438
|
+
{
|
|
439
|
+
exponent() = static_cast<Exponent>(final_exponent);
|
|
440
|
+
final_exponent = 0;
|
|
441
|
+
}
|
|
442
|
+
copy_and_round(*this, q.backend());
|
|
443
|
+
if (ss != sign())
|
|
444
|
+
negate();
|
|
445
|
+
break;
|
|
446
|
+
} while (true);
|
|
447
|
+
}
|
|
448
|
+
//
|
|
449
|
+
// Check for scaling and/or over/under-flow:
|
|
450
|
+
//
|
|
451
|
+
final_exponent += exponent();
|
|
452
|
+
if (final_exponent > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
|
|
453
|
+
{
|
|
454
|
+
// Overflow:
|
|
455
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_infinity;
|
|
456
|
+
bits() = limb_type(0);
|
|
457
|
+
}
|
|
458
|
+
else if (final_exponent < cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::min_exponent)
|
|
459
|
+
{
|
|
460
|
+
// Underflow:
|
|
461
|
+
exponent() = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::exponent_zero;
|
|
462
|
+
bits() = limb_type(0);
|
|
463
|
+
sign() = 0;
|
|
464
|
+
}
|
|
465
|
+
else
|
|
466
|
+
{
|
|
467
|
+
exponent() = static_cast<Exponent>(final_exponent);
|
|
468
|
+
}
|
|
469
|
+
return *this;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
template <unsigned Digits, digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinE, Exponent MaxE>
|
|
473
|
+
std::string cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::str(std::streamsize dig, std::ios_base::fmtflags f) const
|
|
474
|
+
{
|
|
475
|
+
bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
|
|
476
|
+
bool fixed = !scientific && (f & std::ios_base::fixed);
|
|
477
|
+
|
|
478
|
+
if (dig == 0 && !fixed)
|
|
479
|
+
dig = std::numeric_limits<number<cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE> > >::max_digits10;
|
|
480
|
+
|
|
481
|
+
std::string s;
|
|
482
|
+
|
|
483
|
+
if (exponent() <= cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::max_exponent)
|
|
484
|
+
{
|
|
485
|
+
// How far to left-shift in order to demormalise the mantissa:
|
|
486
|
+
std::intmax_t shift = (std::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - (std::intmax_t)exponent() - 1;
|
|
487
|
+
std::intmax_t digits_wanted = static_cast<int>(dig);
|
|
488
|
+
std::intmax_t base10_exp = exponent() >= 0 ? static_cast<std::intmax_t>(std::floor(0.30103 * exponent())) : static_cast<std::intmax_t>(std::ceil(0.30103 * exponent()));
|
|
489
|
+
//
|
|
490
|
+
// For fixed formatting we want /dig/ digits after the decimal point,
|
|
491
|
+
// so if the exponent is zero, allowing for the one digit before the
|
|
492
|
+
// decimal point, we want 1 + dig digits etc.
|
|
493
|
+
//
|
|
494
|
+
if (fixed)
|
|
495
|
+
digits_wanted += 1 + base10_exp;
|
|
496
|
+
if (scientific)
|
|
497
|
+
digits_wanted += 1;
|
|
498
|
+
if (digits_wanted < -1)
|
|
499
|
+
{
|
|
500
|
+
// Fixed precision, no significant digits, and nothing to round!
|
|
501
|
+
s = "0";
|
|
502
|
+
if (sign())
|
|
503
|
+
s.insert(static_cast<std::string::size_type>(0), 1, '-');
|
|
504
|
+
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, true);
|
|
505
|
+
return s;
|
|
506
|
+
}
|
|
507
|
+
//
|
|
508
|
+
// power10 is the base10 exponent we need to multiply/divide by in order
|
|
509
|
+
// to convert our denormalised number to an integer with the right number of digits:
|
|
510
|
+
//
|
|
511
|
+
std::intmax_t power10 = digits_wanted - base10_exp - 1;
|
|
512
|
+
//
|
|
513
|
+
// If we calculate 5^power10 rather than 10^power10 we need to move
|
|
514
|
+
// 2^power10 into /shift/
|
|
515
|
+
//
|
|
516
|
+
shift -= power10;
|
|
517
|
+
cpp_int i;
|
|
518
|
+
int roundup = 0; // 0=no rounding, 1=tie, 2=up
|
|
519
|
+
constexpr std::size_t limb_bits = sizeof(limb_type) * CHAR_BIT;
|
|
520
|
+
//
|
|
521
|
+
// Set our working precision - this is heuristic based, we want
|
|
522
|
+
// a value as small as possible > cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count to avoid large computations
|
|
523
|
+
// and excessive memory usage, but we also want to avoid having to
|
|
524
|
+
// up the computation and start again at a higher precision.
|
|
525
|
+
// So we round cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count up to the nearest whole number of limbs, and add
|
|
526
|
+
// one limb for good measure. This works very well for small exponents,
|
|
527
|
+
// but for larger exponents we add a few extra limbs to max_bits:
|
|
528
|
+
//
|
|
529
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
530
|
+
std::intmax_t max_bits = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + 32;
|
|
531
|
+
#else
|
|
532
|
+
std::intmax_t max_bits = cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count + ((cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count % limb_bits) ? (limb_bits - cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count % limb_bits) : 0) + limb_bits;
|
|
533
|
+
if (power10)
|
|
534
|
+
{
|
|
535
|
+
const std::uintmax_t abs_power10 = static_cast<std::uintmax_t>(boost::multiprecision::detail::abs(power10));
|
|
536
|
+
const std::intmax_t msb_div8 = static_cast<std::intmax_t>(msb(abs_power10) / 8u);
|
|
537
|
+
|
|
538
|
+
max_bits += (msb_div8 * static_cast<std::intmax_t>(limb_bits));
|
|
539
|
+
}
|
|
540
|
+
#endif
|
|
541
|
+
do
|
|
542
|
+
{
|
|
543
|
+
std::int64_t error = 0;
|
|
544
|
+
std::intmax_t calc_exp = 0;
|
|
545
|
+
//
|
|
546
|
+
// Our integer result is: bits() * 2^-shift * 5^power10
|
|
547
|
+
//
|
|
548
|
+
i = bits();
|
|
549
|
+
if (shift < 0)
|
|
550
|
+
{
|
|
551
|
+
if (power10 >= 0)
|
|
552
|
+
{
|
|
553
|
+
// We go straight to the answer with all integer arithmetic,
|
|
554
|
+
// the result is always exact and never needs rounding:
|
|
555
|
+
BOOST_MP_ASSERT(power10 <= (std::intmax_t)INT_MAX);
|
|
556
|
+
i <<= -shift;
|
|
557
|
+
if (power10)
|
|
558
|
+
i *= pow(cpp_int(5), static_cast<unsigned>(power10));
|
|
559
|
+
}
|
|
560
|
+
else if (power10 < 0)
|
|
561
|
+
{
|
|
562
|
+
cpp_int d;
|
|
563
|
+
calc_exp = boost::multiprecision::cpp_bf_io_detail::restricted_pow(d, cpp_int(5), -power10, max_bits, error);
|
|
564
|
+
shift += calc_exp;
|
|
565
|
+
BOOST_MP_ASSERT(shift < 0); // Must still be true!
|
|
566
|
+
i <<= -shift;
|
|
567
|
+
cpp_int r;
|
|
568
|
+
divide_qr(i, d, i, r);
|
|
569
|
+
roundup = boost::multiprecision::cpp_bf_io_detail::get_round_mode(r, d, error, i);
|
|
570
|
+
if (roundup < 0)
|
|
571
|
+
{
|
|
572
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
573
|
+
max_bits += 32;
|
|
574
|
+
#else
|
|
575
|
+
max_bits *= 2;
|
|
576
|
+
#endif
|
|
577
|
+
shift = (std::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10;
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
else
|
|
583
|
+
{
|
|
584
|
+
//
|
|
585
|
+
// Our integer is bits() * 2^-shift * 10^power10
|
|
586
|
+
//
|
|
587
|
+
if (power10 > 0)
|
|
588
|
+
{
|
|
589
|
+
if (power10)
|
|
590
|
+
{
|
|
591
|
+
cpp_int t;
|
|
592
|
+
calc_exp = boost::multiprecision::cpp_bf_io_detail::restricted_pow(t, cpp_int(5), power10, max_bits, error);
|
|
593
|
+
calc_exp += boost::multiprecision::cpp_bf_io_detail::restricted_multiply(i, i, t, max_bits, error);
|
|
594
|
+
shift -= calc_exp;
|
|
595
|
+
}
|
|
596
|
+
if ((shift < 0) || ((shift == 0) && error))
|
|
597
|
+
{
|
|
598
|
+
// We only get here if we were asked for a crazy number of decimal digits -
|
|
599
|
+
// more than are present in a 2^max_bits number.
|
|
600
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
601
|
+
max_bits += 32;
|
|
602
|
+
#else
|
|
603
|
+
max_bits *= 2;
|
|
604
|
+
#endif
|
|
605
|
+
shift = (std::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10;
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
if (shift)
|
|
609
|
+
{
|
|
610
|
+
roundup = boost::multiprecision::cpp_bf_io_detail::get_round_mode(i, shift - 1, error);
|
|
611
|
+
if (roundup < 0)
|
|
612
|
+
{
|
|
613
|
+
#ifdef BOOST_MP_STRESS_IO
|
|
614
|
+
max_bits += 32;
|
|
615
|
+
#else
|
|
616
|
+
max_bits *= 2;
|
|
617
|
+
#endif
|
|
618
|
+
shift = (std::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10;
|
|
619
|
+
continue;
|
|
620
|
+
}
|
|
621
|
+
i >>= shift;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
else
|
|
625
|
+
{
|
|
626
|
+
// We're right shifting, *and* dividing by 5^-power10,
|
|
627
|
+
// so 5^-power10 can never be that large or we'd simply
|
|
628
|
+
// get zero as a result, and that case is already handled above:
|
|
629
|
+
cpp_int r;
|
|
630
|
+
BOOST_MP_ASSERT(-power10 < INT_MAX);
|
|
631
|
+
cpp_int d = pow(cpp_int(5), static_cast<unsigned>(-power10));
|
|
632
|
+
d <<= shift;
|
|
633
|
+
divide_qr(i, d, i, r);
|
|
634
|
+
r <<= 1;
|
|
635
|
+
int c = r.compare(d);
|
|
636
|
+
roundup = c < 0 ? 0 : c == 0 ? 1 : 2;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
s = i.str(0, std::ios_base::fmtflags(0));
|
|
640
|
+
//
|
|
641
|
+
// Check if we got the right number of digits, this
|
|
642
|
+
// is really a test of whether we calculated the
|
|
643
|
+
// decimal exponent correctly:
|
|
644
|
+
//
|
|
645
|
+
std::intmax_t digits_got = i ? static_cast<std::intmax_t>(s.size()) : 0;
|
|
646
|
+
if (digits_got != digits_wanted)
|
|
647
|
+
{
|
|
648
|
+
base10_exp += digits_got - digits_wanted;
|
|
649
|
+
if (fixed)
|
|
650
|
+
digits_wanted = digits_got; // strange but true.
|
|
651
|
+
power10 = digits_wanted - base10_exp - 1;
|
|
652
|
+
shift = (std::intmax_t)cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinE, MaxE>::bit_count - exponent() - 1 - power10;
|
|
653
|
+
if (fixed)
|
|
654
|
+
break;
|
|
655
|
+
roundup = 0;
|
|
656
|
+
}
|
|
657
|
+
else
|
|
658
|
+
break;
|
|
659
|
+
} while (true);
|
|
660
|
+
//
|
|
661
|
+
// Check whether we need to round up: note that we could equally round up
|
|
662
|
+
// the integer /i/ above, but since we need to perform the rounding *after*
|
|
663
|
+
// the conversion to a string and the digit count check, we might as well
|
|
664
|
+
// do it here:
|
|
665
|
+
//
|
|
666
|
+
if ((roundup == 2) || ((roundup == 1) && ((s[s.size() - 1] - '0') & 1)))
|
|
667
|
+
{
|
|
668
|
+
boost::multiprecision::detail::round_string_up_at(s, static_cast<int>(s.size() - 1), base10_exp);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
if (sign())
|
|
672
|
+
s.insert(static_cast<std::string::size_type>(0), 1, '-');
|
|
673
|
+
|
|
674
|
+
boost::multiprecision::detail::format_float_string(s, base10_exp, dig, f, false);
|
|
675
|
+
}
|
|
676
|
+
else
|
|
677
|
+
{
|
|
678
|
+
switch (exponent())
|
|
679
|
+
{
|
|
680
|
+
case exponent_zero:
|
|
681
|
+
s = sign() ? "-0" : f & std::ios_base::showpos ? "+0" : "0";
|
|
682
|
+
boost::multiprecision::detail::format_float_string(s, 0, dig, f, true);
|
|
683
|
+
break;
|
|
684
|
+
case exponent_nan:
|
|
685
|
+
s = "nan";
|
|
686
|
+
break;
|
|
687
|
+
case exponent_infinity:
|
|
688
|
+
s = sign() ? "-inf" : f & std::ios_base::showpos ? "+inf" : "inf";
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return s;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
} // namespace backends
|
|
696
|
+
}} // namespace boost::multiprecision
|
|
697
|
+
|
|
698
|
+
#endif
|