mqt-core 3.3.2__cp312-cp312-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.cp312-win_amd64.pyd +0 -0
- mqt/core/dd.pyi +1016 -0
- mqt/core/dd_evaluation.py +368 -0
- mqt/core/fomac.cp312-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.cp312-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.cp312-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
mqt/core/ir/__init__.pyi
ADDED
|
@@ -0,0 +1,2078 @@
|
|
|
1
|
+
# Copyright (c) 2023 - 2025 Chair for Design Automation, TUM
|
|
2
|
+
# Copyright (c) 2025 Munich Quantum Software Company GmbH
|
|
3
|
+
# All rights reserved.
|
|
4
|
+
#
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the MIT License
|
|
8
|
+
|
|
9
|
+
"""MQT Core IR - The MQT Core Intermediate Representation (IR) module."""
|
|
10
|
+
|
|
11
|
+
from collections.abc import ItemsView, Iterable, Iterator, Mapping, MutableMapping, MutableSequence, Sequence
|
|
12
|
+
from os import PathLike
|
|
13
|
+
from typing import overload
|
|
14
|
+
|
|
15
|
+
from .operations import ComparisonKind, Control, Operation, OpType
|
|
16
|
+
from .registers import ClassicalRegister, QuantumRegister
|
|
17
|
+
from .symbolic import Expression, Variable
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Permutation",
|
|
21
|
+
"QuantumComputation",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
class Permutation(MutableMapping[int, int]):
|
|
25
|
+
"""A class to represent a permutation of the qubits in a quantum circuit.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
permutation: The permutation to initialize the object with.
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, permutation: dict[int, int] | None = None) -> None:
|
|
33
|
+
"""Initialize the permutation."""
|
|
34
|
+
|
|
35
|
+
def __getitem__(self, idx: int) -> int:
|
|
36
|
+
"""Get the value of the permutation at the given index.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
idx: The index to get the value of the permutation at.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
The value of the permutation at the given index.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __setitem__(self, idx: int, val: int) -> None:
|
|
46
|
+
"""Set the value of the permutation at the given index.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
idx: The index to set the value of the permutation at.
|
|
50
|
+
val: The value to set the permutation at the given index to.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
def __delitem__(self, key: int) -> None:
|
|
54
|
+
"""Delete the value of the permutation at the given index.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
key: The index to delete the value of the permutation at.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __iter__(self) -> Iterator[int]:
|
|
61
|
+
"""Return an iterator over the indices of the permutation."""
|
|
62
|
+
|
|
63
|
+
def items(self) -> ItemsView[int, int]:
|
|
64
|
+
"""Return an iterable over the items of the permutation."""
|
|
65
|
+
|
|
66
|
+
def __len__(self) -> int:
|
|
67
|
+
"""Return the number of indices in the permutation."""
|
|
68
|
+
|
|
69
|
+
def __eq__(self, other: object) -> bool:
|
|
70
|
+
"""Check if the permutation is equal to another permutation."""
|
|
71
|
+
|
|
72
|
+
def __ne__(self, other: object) -> bool:
|
|
73
|
+
"""Check if the permutation is not equal to another permutation."""
|
|
74
|
+
|
|
75
|
+
def __hash__(self) -> int:
|
|
76
|
+
"""Return the hash of the permutation."""
|
|
77
|
+
|
|
78
|
+
def clear(self) -> None:
|
|
79
|
+
"""Clear the permutation of all indices and values."""
|
|
80
|
+
|
|
81
|
+
@overload
|
|
82
|
+
def apply(self, controls: set[Control]) -> set[Control]:
|
|
83
|
+
"""Apply the permutation to a set of controls.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
controls: The set of controls to apply the permutation to.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
The set of controls with the permutation applied.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
@overload
|
|
93
|
+
def apply(self, targets: list[int]) -> list[int]:
|
|
94
|
+
"""Apply the permutation to a list of targets.
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
targets: The list of targets to apply the permutation to.
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
The list of targets with the permutation applied.
|
|
101
|
+
"""
|
|
102
|
+
|
|
103
|
+
class QuantumComputation(MutableSequence[Operation]):
|
|
104
|
+
"""The main class for representing quantum computations within the MQT.
|
|
105
|
+
|
|
106
|
+
Acts as mutable sequence of :class:`~mqt.core.ir.operations.Operation` objects,
|
|
107
|
+
which represent the individual operations in the quantum computation.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
nq: The number of qubits in the quantum computation.
|
|
111
|
+
nc: The number of classical bits in the quantum computation.
|
|
112
|
+
seed: The seed to use for the internal random number generator.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
# --------------------------------------------------------------------------
|
|
116
|
+
# Constructors
|
|
117
|
+
# --------------------------------------------------------------------------
|
|
118
|
+
def __init__(self, nq: int = 0, nc: int = 0, seed: int = 0) -> None: ...
|
|
119
|
+
@staticmethod
|
|
120
|
+
def from_qasm_str(qasm: str) -> QuantumComputation:
|
|
121
|
+
"""Create a QuantumComputation object from an OpenQASM string.
|
|
122
|
+
|
|
123
|
+
Args:
|
|
124
|
+
qasm: The OpenQASM string to create the QuantumComputation object from.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
The QuantumComputation object created from the OpenQASM string.
|
|
128
|
+
"""
|
|
129
|
+
@staticmethod
|
|
130
|
+
def from_qasm(filename: str) -> QuantumComputation:
|
|
131
|
+
"""Create a QuantumComputation object from an OpenQASM file.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
filename: The filename of the OpenQASM file to create the QuantumComputation object from.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
The QuantumComputation object created from the OpenQASM file.
|
|
138
|
+
"""
|
|
139
|
+
|
|
140
|
+
# --------------------------------------------------------------------------
|
|
141
|
+
# General Properties
|
|
142
|
+
# --------------------------------------------------------------------------
|
|
143
|
+
|
|
144
|
+
name: str
|
|
145
|
+
"""
|
|
146
|
+
The name of the quantum computation.
|
|
147
|
+
"""
|
|
148
|
+
global_phase: float
|
|
149
|
+
"""
|
|
150
|
+
The global phase of the quantum computation.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def num_qubits(self) -> int:
|
|
155
|
+
"""The total number of qubits in the quantum computation."""
|
|
156
|
+
|
|
157
|
+
@property
|
|
158
|
+
def num_ancilla_qubits(self) -> int:
|
|
159
|
+
r"""The number of ancilla qubits in the quantum computation.
|
|
160
|
+
|
|
161
|
+
Note:
|
|
162
|
+
Ancilla qubits are qubits that always start in a fixed state (usually :math:`|0\\rangle`).
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def num_garbage_qubits(self) -> int:
|
|
167
|
+
"""The number of garbage qubits in the quantum computation.
|
|
168
|
+
|
|
169
|
+
Note:
|
|
170
|
+
Garbage qubits are qubits whose final state is not relevant for the computation.
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def num_measured_qubits(self) -> int:
|
|
175
|
+
"""The number of qubits that are measured in the quantum computation.
|
|
176
|
+
|
|
177
|
+
Computed as :math:`|qubits| - |garbage|`.
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def num_data_qubits(self) -> int:
|
|
182
|
+
"""The number of data qubits in the quantum computation.
|
|
183
|
+
|
|
184
|
+
Computed as :math:`|qubits| - |ancilla|`.
|
|
185
|
+
"""
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def num_classical_bits(self) -> int:
|
|
189
|
+
"""The number of classical bits in the quantum computation."""
|
|
190
|
+
|
|
191
|
+
@property
|
|
192
|
+
def num_ops(self) -> int:
|
|
193
|
+
"""The number of operations in the quantum computation."""
|
|
194
|
+
|
|
195
|
+
def num_single_qubit_ops(self) -> int:
|
|
196
|
+
"""Return the number of single-qubit operations in the quantum computation."""
|
|
197
|
+
|
|
198
|
+
def num_total_ops(self) -> int:
|
|
199
|
+
"""Return the total number of operations in the quantum computation.
|
|
200
|
+
|
|
201
|
+
Recursively counts sub-operations (e.g., from :class:`~mqt.core.ir.operations.CompoundOperation` objects).
|
|
202
|
+
"""
|
|
203
|
+
|
|
204
|
+
def depth(self) -> int:
|
|
205
|
+
"""Return the depth of the quantum computation."""
|
|
206
|
+
|
|
207
|
+
def invert(self) -> None:
|
|
208
|
+
"""Invert the quantum computation in-place by inverting each operation and reversing the order of operations."""
|
|
209
|
+
|
|
210
|
+
def to_operation(self) -> Operation:
|
|
211
|
+
"""Convert the quantum computation to a single operation.
|
|
212
|
+
|
|
213
|
+
This gives ownership of the operations to the resulting operation,
|
|
214
|
+
so the quantum computation will be empty after this operation.
|
|
215
|
+
|
|
216
|
+
When the quantum computation contains more than one operation,
|
|
217
|
+
the resulting operation is a :class:`~mqt.core.ir.operations.CompoundOperation`.
|
|
218
|
+
|
|
219
|
+
Returns:
|
|
220
|
+
The operation representing the quantum computation.
|
|
221
|
+
"""
|
|
222
|
+
|
|
223
|
+
# --------------------------------------------------------------------------
|
|
224
|
+
# Mutable Sequence Interface
|
|
225
|
+
# --------------------------------------------------------------------------
|
|
226
|
+
|
|
227
|
+
def __len__(self) -> int:
|
|
228
|
+
"""Return the number of operations in the quantum computation."""
|
|
229
|
+
|
|
230
|
+
@overload
|
|
231
|
+
def __getitem__(self, idx: int) -> Operation:
|
|
232
|
+
"""Get the operation at the given index.
|
|
233
|
+
|
|
234
|
+
Note:
|
|
235
|
+
This gives write access to the operation at the given index.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
idx: The index of the operation to get.
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
The operation at the given index.
|
|
242
|
+
"""
|
|
243
|
+
|
|
244
|
+
@overload
|
|
245
|
+
def __getitem__(self, idx: slice) -> list[Operation]:
|
|
246
|
+
"""Get a slice of operations from the quantum computation.
|
|
247
|
+
|
|
248
|
+
Note:
|
|
249
|
+
This gives write access to the operations in the given slice.
|
|
250
|
+
|
|
251
|
+
Args:
|
|
252
|
+
idx: The slice of operations to get.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
The operations in the given slice.
|
|
256
|
+
"""
|
|
257
|
+
|
|
258
|
+
@overload
|
|
259
|
+
def __setitem__(self, idx: int, op: Operation) -> None:
|
|
260
|
+
"""Set the operation at the given index.
|
|
261
|
+
|
|
262
|
+
Args:
|
|
263
|
+
idx: The index of the operation to set.
|
|
264
|
+
op: The operation to set at the given index.
|
|
265
|
+
"""
|
|
266
|
+
|
|
267
|
+
@overload
|
|
268
|
+
def __setitem__(self, idx: slice, ops: Iterable[Operation]) -> None:
|
|
269
|
+
"""Set the operations in the given slice.
|
|
270
|
+
|
|
271
|
+
Args:
|
|
272
|
+
idx: The slice of operations to set.
|
|
273
|
+
ops: The operations to set in the given slice.
|
|
274
|
+
"""
|
|
275
|
+
|
|
276
|
+
@overload
|
|
277
|
+
def __delitem__(self, idx: int) -> None:
|
|
278
|
+
"""Delete the operation at the given index.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
idx: The index of the operation to delete.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
@overload
|
|
285
|
+
def __delitem__(self, idx: slice) -> None:
|
|
286
|
+
"""Delete the operations in the given slice.
|
|
287
|
+
|
|
288
|
+
Args:
|
|
289
|
+
idx: The slice of operations to delete.
|
|
290
|
+
"""
|
|
291
|
+
|
|
292
|
+
def insert(self, idx: int, op: Operation) -> None:
|
|
293
|
+
"""Insert an operation at the given index.
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
idx: The index to insert the operation at.
|
|
297
|
+
op: The operation to insert.
|
|
298
|
+
"""
|
|
299
|
+
|
|
300
|
+
def append(self, op: Operation) -> None:
|
|
301
|
+
"""Append an operation to the end of the quantum computation.
|
|
302
|
+
|
|
303
|
+
Args:
|
|
304
|
+
op: The operation to append.
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
def reverse(self) -> None:
|
|
308
|
+
"""Reverse the order of the operations in the quantum computation (in-place)."""
|
|
309
|
+
|
|
310
|
+
def clear(self) -> None:
|
|
311
|
+
"""Clear the quantum computation of all operations."""
|
|
312
|
+
|
|
313
|
+
# --------------------------------------------------------------------------
|
|
314
|
+
# (Qu)Bit Registers
|
|
315
|
+
# --------------------------------------------------------------------------
|
|
316
|
+
|
|
317
|
+
def add_ancillary_register(self, n: int, name: str = "anc") -> QuantumRegister:
|
|
318
|
+
"""Add an ancillary register to the quantum computation.
|
|
319
|
+
|
|
320
|
+
Args:
|
|
321
|
+
n: The number of qubits in the ancillary register.
|
|
322
|
+
name: The name of the ancillary register.
|
|
323
|
+
|
|
324
|
+
Returns:
|
|
325
|
+
The ancillary register added to the quantum computation.
|
|
326
|
+
"""
|
|
327
|
+
|
|
328
|
+
def add_classical_register(self, n: int, name: str = "c") -> ClassicalRegister:
|
|
329
|
+
"""Add a classical register to the quantum computation.
|
|
330
|
+
|
|
331
|
+
Args:
|
|
332
|
+
n: The number of bits in the classical register.
|
|
333
|
+
name: The name of the classical register.
|
|
334
|
+
|
|
335
|
+
Returns:
|
|
336
|
+
The classical register added to the quantum computation.
|
|
337
|
+
"""
|
|
338
|
+
|
|
339
|
+
def add_qubit_register(self, n: int, name: str = "q") -> QuantumRegister:
|
|
340
|
+
"""Add a qubit register to the quantum computation.
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
n: The number of qubits in the qubit register.
|
|
344
|
+
name: The name of the qubit register.
|
|
345
|
+
|
|
346
|
+
Returns:
|
|
347
|
+
The qubit register added to the quantum computation.
|
|
348
|
+
"""
|
|
349
|
+
|
|
350
|
+
def unify_quantum_registers(self, name: str = "q") -> QuantumRegister:
|
|
351
|
+
"""Unify all quantum registers in the quantum computation.
|
|
352
|
+
|
|
353
|
+
Args:
|
|
354
|
+
name: The name of the unified quantum register.
|
|
355
|
+
|
|
356
|
+
Returns:
|
|
357
|
+
The unified quantum register.
|
|
358
|
+
"""
|
|
359
|
+
|
|
360
|
+
@property
|
|
361
|
+
def qregs(self) -> dict[str, QuantumRegister]:
|
|
362
|
+
"""The quantum registers in the quantum computation."""
|
|
363
|
+
|
|
364
|
+
@property
|
|
365
|
+
def cregs(self) -> dict[str, ClassicalRegister]:
|
|
366
|
+
"""The classical registers in the quantum computation."""
|
|
367
|
+
|
|
368
|
+
@property
|
|
369
|
+
def ancregs(self) -> dict[str, QuantumRegister]:
|
|
370
|
+
"""The ancillary registers in the quantum computation."""
|
|
371
|
+
|
|
372
|
+
# --------------------------------------------------------------------------
|
|
373
|
+
# Initial Layout and Output Permutation
|
|
374
|
+
# --------------------------------------------------------------------------
|
|
375
|
+
|
|
376
|
+
initial_layout: Permutation
|
|
377
|
+
"""
|
|
378
|
+
The initial layout of the qubits in the quantum computation.
|
|
379
|
+
|
|
380
|
+
This is a permutation of the qubits in the quantum computation. It is mainly
|
|
381
|
+
used to track the mapping of circuit qubits to device qubits during quantum
|
|
382
|
+
circuit compilation. The keys are the device qubits (in which a compiled circuit
|
|
383
|
+
is expressed in), and the values are the circuit qubits (in which the original
|
|
384
|
+
quantum circuit is expressed in).
|
|
385
|
+
|
|
386
|
+
Any operations in the quantum circuit are expected to be expressed in terms
|
|
387
|
+
of the keys of the initial layout.
|
|
388
|
+
|
|
389
|
+
Examples:
|
|
390
|
+
- If no initial layout is explicitly specified (which is the default),
|
|
391
|
+
the initial layout is assumed to be the identity permutation.
|
|
392
|
+
- Assume a three-qubit circuit has been compiled to a four qubit device
|
|
393
|
+
and circuit qubit 0 is mapped to device qubit 1, circuit qubit 1 is
|
|
394
|
+
mapped to device qubit 2, and circuit qubit 2 is mapped to device qubit 3.
|
|
395
|
+
Then the initial layout is {1: 0, 2: 1, 3: 2}.
|
|
396
|
+
|
|
397
|
+
"""
|
|
398
|
+
output_permutation: Permutation
|
|
399
|
+
"""
|
|
400
|
+
The output permutation of the qubits in the quantum computation.
|
|
401
|
+
|
|
402
|
+
This is a permutation of the qubits in the quantum computation. It is mainly
|
|
403
|
+
used to track where individual qubits end up at the end of the quantum computation,
|
|
404
|
+
for example after a circuit has been compiled to a specific device and SWAP
|
|
405
|
+
gates have been inserted, which permute the qubits. The keys are the qubits
|
|
406
|
+
in the circuit and the values are the actual qubits being measured.
|
|
407
|
+
|
|
408
|
+
Similar to the initial layout, the keys in the output permutation are the
|
|
409
|
+
qubits actually present in the circuit and the values are the qubits in the
|
|
410
|
+
"original" circuit.
|
|
411
|
+
|
|
412
|
+
Examples:
|
|
413
|
+
- If no output permutation is explicitly specified and the circuit does
|
|
414
|
+
not contain measurements at the end, the output permutation is assumed
|
|
415
|
+
to be the identity permutation.
|
|
416
|
+
- If the circuit contains measurements at the end, these measurements
|
|
417
|
+
are used to infer the output permutation. Assume a three-qubit circuit
|
|
418
|
+
has been compiled to a four qubit device and, at the end of the circuit,
|
|
419
|
+
circuit qubit 0 is measured into classical bit 2, circuit qubit 1 is
|
|
420
|
+
measured into classical bit 1, and circuit qubit 3 is measured into
|
|
421
|
+
classical bit 0. Then the output permutation is {0: 2, 1: 1, 3: 0}.
|
|
422
|
+
"""
|
|
423
|
+
|
|
424
|
+
def initialize_io_mapping(self) -> None:
|
|
425
|
+
"""Initialize the I/O mapping of the quantum computation.
|
|
426
|
+
|
|
427
|
+
If no initial layout is explicitly specified, the initial layout is assumed
|
|
428
|
+
to be the identity permutation. If the circuit contains measurements at the
|
|
429
|
+
end, these measurements are used to infer the output permutation.
|
|
430
|
+
"""
|
|
431
|
+
|
|
432
|
+
# --------------------------------------------------------------------------
|
|
433
|
+
# Ancilla and Garbage Handling
|
|
434
|
+
# --------------------------------------------------------------------------
|
|
435
|
+
|
|
436
|
+
@property
|
|
437
|
+
def ancillary(self) -> list[bool]:
|
|
438
|
+
"""A list of booleans indicating whether each qubit is ancillary."""
|
|
439
|
+
|
|
440
|
+
def set_circuit_qubit_ancillary(self, q: int) -> None:
|
|
441
|
+
"""Set a circuit (i.e., logical) qubit to be ancillary.
|
|
442
|
+
|
|
443
|
+
Args:
|
|
444
|
+
q: The index of the circuit qubit to set as ancillary.
|
|
445
|
+
"""
|
|
446
|
+
|
|
447
|
+
def set_circuit_qubits_ancillary(self, q_min: int, q_max: int) -> None:
|
|
448
|
+
"""Set a range of circuit (i.e., logical) qubits to be ancillary.
|
|
449
|
+
|
|
450
|
+
Args:
|
|
451
|
+
q_min: The minimum index of the circuit qubits to set as ancillary.
|
|
452
|
+
q_max: The maximum index of the circuit qubits to set as ancillary.
|
|
453
|
+
"""
|
|
454
|
+
|
|
455
|
+
def is_circuit_qubit_ancillary(self, q: int) -> bool:
|
|
456
|
+
"""Check if a circuit (i.e., logical) qubit is ancillary.
|
|
457
|
+
|
|
458
|
+
Args:
|
|
459
|
+
q: The index of the circuit qubit to check.
|
|
460
|
+
|
|
461
|
+
Returns:
|
|
462
|
+
True if the circuit qubit is ancillary, False otherwise.
|
|
463
|
+
"""
|
|
464
|
+
|
|
465
|
+
@property
|
|
466
|
+
def garbage(self) -> list[bool]:
|
|
467
|
+
"""A list of booleans indicating whether each qubit is garbage."""
|
|
468
|
+
|
|
469
|
+
def set_circuit_qubit_garbage(self, q: int) -> None:
|
|
470
|
+
"""Set a circuit (i.e., logical) qubit to be garbage.
|
|
471
|
+
|
|
472
|
+
Args:
|
|
473
|
+
q: The index of the circuit qubit to set as garbage.
|
|
474
|
+
"""
|
|
475
|
+
|
|
476
|
+
def set_circuit_qubits_garbage(self, q_min: int, q_max: int) -> None:
|
|
477
|
+
"""Set a range of circuit (i.e., logical) qubits to be garbage.
|
|
478
|
+
|
|
479
|
+
Args:
|
|
480
|
+
q_min: The minimum index of the circuit qubits to set as garbage.
|
|
481
|
+
q_max: The maximum index of the circuit qubits to set as garbage.
|
|
482
|
+
"""
|
|
483
|
+
|
|
484
|
+
def is_circuit_qubit_garbage(self, q: int) -> bool:
|
|
485
|
+
"""Check if a circuit (i.e., logical) qubit is garbage.
|
|
486
|
+
|
|
487
|
+
Args:
|
|
488
|
+
q: The index of the circuit qubit to check.
|
|
489
|
+
|
|
490
|
+
Returns:
|
|
491
|
+
True if the circuit qubit is garbage, False otherwise.
|
|
492
|
+
"""
|
|
493
|
+
|
|
494
|
+
# --------------------------------------------------------------------------
|
|
495
|
+
# Symbolic Circuit Handling
|
|
496
|
+
# --------------------------------------------------------------------------
|
|
497
|
+
|
|
498
|
+
@property
|
|
499
|
+
def variables(self) -> set[Variable]:
|
|
500
|
+
"""The set of variables in the quantum computation."""
|
|
501
|
+
|
|
502
|
+
def add_variable(self, var: Expression | float) -> None:
|
|
503
|
+
"""Add a variable to the quantum computation.
|
|
504
|
+
|
|
505
|
+
Args:
|
|
506
|
+
var: The variable to add.
|
|
507
|
+
"""
|
|
508
|
+
|
|
509
|
+
def add_variables(self, vars_: Sequence[Expression | float]) -> None:
|
|
510
|
+
"""Add multiple variables to the quantum computation.
|
|
511
|
+
|
|
512
|
+
Args:
|
|
513
|
+
vars_: The variables to add.
|
|
514
|
+
"""
|
|
515
|
+
|
|
516
|
+
def is_variable_free(self) -> bool:
|
|
517
|
+
"""Check if the quantum computation is free of variables.
|
|
518
|
+
|
|
519
|
+
Returns:
|
|
520
|
+
True if the quantum computation is free of variables, False otherwise.
|
|
521
|
+
"""
|
|
522
|
+
|
|
523
|
+
def instantiate(self, assignment: Mapping[Variable, float]) -> QuantumComputation:
|
|
524
|
+
"""Instantiate the quantum computation with the given variable assignment.
|
|
525
|
+
|
|
526
|
+
Args:
|
|
527
|
+
assignment: The variable assignment to instantiate the quantum computation with.
|
|
528
|
+
|
|
529
|
+
Returns:
|
|
530
|
+
The instantiated quantum computation.
|
|
531
|
+
"""
|
|
532
|
+
|
|
533
|
+
def instantiate_inplace(self, assignment: Mapping[Variable, float]) -> None:
|
|
534
|
+
"""Instantiate the quantum computation with the given variable assignment in-place.
|
|
535
|
+
|
|
536
|
+
Args:
|
|
537
|
+
assignment: The variable assignment to instantiate the quantum computation with.
|
|
538
|
+
"""
|
|
539
|
+
|
|
540
|
+
# --------------------------------------------------------------------------
|
|
541
|
+
# Output Handling
|
|
542
|
+
# --------------------------------------------------------------------------
|
|
543
|
+
|
|
544
|
+
def qasm2_str(self) -> str:
|
|
545
|
+
"""Return the OpenQASM2 representation of the quantum computation as a string.
|
|
546
|
+
|
|
547
|
+
Note:
|
|
548
|
+
This uses some custom extensions to OpenQASM 2.0 that allow for easier
|
|
549
|
+
definition of multi-controlled gates. These extensions might not be
|
|
550
|
+
supported by all OpenQASM 2.0 parsers. Consider using the :meth:`qasm3_str`
|
|
551
|
+
method instead, which uses OpenQASM 3.0 that natively supports
|
|
552
|
+
multi-controlled gates. The export also assumes the bigger, non-standard
|
|
553
|
+
`qelib1.inc` from Qiskit is available.
|
|
554
|
+
|
|
555
|
+
Returns:
|
|
556
|
+
The OpenQASM2 representation of the quantum computation as a string.
|
|
557
|
+
"""
|
|
558
|
+
|
|
559
|
+
def qasm2(self, filename: PathLike[str] | str) -> None:
|
|
560
|
+
"""Write the OpenQASM2 representation of the quantum computation to a file.
|
|
561
|
+
|
|
562
|
+
See Also:
|
|
563
|
+
:meth:`qasm2_str`
|
|
564
|
+
|
|
565
|
+
Args:
|
|
566
|
+
filename: The filename of the file to write the OpenQASM2 representation to.
|
|
567
|
+
"""
|
|
568
|
+
|
|
569
|
+
def qasm3_str(self) -> str:
|
|
570
|
+
"""Return the OpenQASM3 representation of the quantum computation as a string.
|
|
571
|
+
|
|
572
|
+
Returns:
|
|
573
|
+
The OpenQASM3 representation of the quantum computation as a string.
|
|
574
|
+
"""
|
|
575
|
+
|
|
576
|
+
def qasm3(self, filename: PathLike[str] | str) -> None:
|
|
577
|
+
"""Write the OpenQASM3 representation of the quantum computation to a file.
|
|
578
|
+
|
|
579
|
+
See Also:
|
|
580
|
+
:meth:`qasm3_str`
|
|
581
|
+
|
|
582
|
+
Args:
|
|
583
|
+
filename: The filename of the file to write the OpenQASM3 representation to.
|
|
584
|
+
"""
|
|
585
|
+
|
|
586
|
+
# --------------------------------------------------------------------------
|
|
587
|
+
# Operations
|
|
588
|
+
# --------------------------------------------------------------------------
|
|
589
|
+
|
|
590
|
+
def i(self, q: int) -> None:
|
|
591
|
+
r"""Apply an identity operation.
|
|
592
|
+
|
|
593
|
+
.. math::
|
|
594
|
+
I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}
|
|
595
|
+
|
|
596
|
+
Args:
|
|
597
|
+
q: The target qubit
|
|
598
|
+
"""
|
|
599
|
+
|
|
600
|
+
def ci(self, control: Control | int, target: int) -> None:
|
|
601
|
+
"""Apply a controlled identity operation.
|
|
602
|
+
|
|
603
|
+
Args:
|
|
604
|
+
control: The control qubit
|
|
605
|
+
target: The target qubit
|
|
606
|
+
|
|
607
|
+
See Also:
|
|
608
|
+
:meth:`i`
|
|
609
|
+
"""
|
|
610
|
+
|
|
611
|
+
def mci(self, controls: set[Control | int], target: int) -> None:
|
|
612
|
+
"""Apply a multi-controlled identity operation.
|
|
613
|
+
|
|
614
|
+
Args:
|
|
615
|
+
controls: The control qubits
|
|
616
|
+
target: The target qubit
|
|
617
|
+
|
|
618
|
+
See Also:
|
|
619
|
+
:meth:`i`
|
|
620
|
+
"""
|
|
621
|
+
|
|
622
|
+
def x(self, q: int) -> None:
|
|
623
|
+
r"""Apply a Pauli-X gate.
|
|
624
|
+
|
|
625
|
+
.. math::
|
|
626
|
+
X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}
|
|
627
|
+
|
|
628
|
+
Args:
|
|
629
|
+
q: The target qubit
|
|
630
|
+
"""
|
|
631
|
+
|
|
632
|
+
def cx(self, control: Control | int, target: int) -> None:
|
|
633
|
+
"""Apply a controlled Pauli-X (CNOT / CX) gate.
|
|
634
|
+
|
|
635
|
+
Args:
|
|
636
|
+
control: The control qubit
|
|
637
|
+
target: The target qubit
|
|
638
|
+
|
|
639
|
+
See Also:
|
|
640
|
+
:meth:`x`
|
|
641
|
+
"""
|
|
642
|
+
|
|
643
|
+
def mcx(self, controls: set[Control | int], target: int) -> None:
|
|
644
|
+
"""Apply a multi-controlled Pauli-X (Toffoli / MCX) gate.
|
|
645
|
+
|
|
646
|
+
Args:
|
|
647
|
+
controls: The control qubits
|
|
648
|
+
target: The target qubit
|
|
649
|
+
|
|
650
|
+
See Also:
|
|
651
|
+
:meth:`x`
|
|
652
|
+
"""
|
|
653
|
+
|
|
654
|
+
def y(self, q: int) -> None:
|
|
655
|
+
r"""Apply a Pauli-Y gate.
|
|
656
|
+
|
|
657
|
+
.. math::
|
|
658
|
+
Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}
|
|
659
|
+
|
|
660
|
+
Args:
|
|
661
|
+
q: The target qubit
|
|
662
|
+
"""
|
|
663
|
+
|
|
664
|
+
def cy(self, control: Control | int, target: int) -> None:
|
|
665
|
+
"""Apply a controlled Pauli-Y gate.
|
|
666
|
+
|
|
667
|
+
Args:
|
|
668
|
+
control: The control qubit
|
|
669
|
+
target: The target qubit
|
|
670
|
+
|
|
671
|
+
See Also:
|
|
672
|
+
:meth:`y`
|
|
673
|
+
"""
|
|
674
|
+
|
|
675
|
+
def mcy(self, controls: set[Control | int], target: int) -> None:
|
|
676
|
+
"""Apply a multi-controlled Pauli-Y gate.
|
|
677
|
+
|
|
678
|
+
Args:
|
|
679
|
+
controls: The control qubits
|
|
680
|
+
target: The target qubit
|
|
681
|
+
|
|
682
|
+
See Also:
|
|
683
|
+
:meth:`y`
|
|
684
|
+
"""
|
|
685
|
+
|
|
686
|
+
def z(self, q: int) -> None:
|
|
687
|
+
r"""Apply a Pauli-Z gate.
|
|
688
|
+
|
|
689
|
+
.. math::
|
|
690
|
+
Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}
|
|
691
|
+
|
|
692
|
+
Args:
|
|
693
|
+
q: The target qubit
|
|
694
|
+
"""
|
|
695
|
+
|
|
696
|
+
def cz(self, control: Control | int, target: int) -> None:
|
|
697
|
+
"""Apply a controlled Pauli-Z (CZ) gate.
|
|
698
|
+
|
|
699
|
+
Args:
|
|
700
|
+
control: The control qubit
|
|
701
|
+
target: The target qubit
|
|
702
|
+
|
|
703
|
+
See Also:
|
|
704
|
+
:meth:`z`
|
|
705
|
+
"""
|
|
706
|
+
|
|
707
|
+
def mcz(self, controls: set[Control | int], target: int) -> None:
|
|
708
|
+
"""Apply a multi-controlled Pauli-Z (MCZ) gate.
|
|
709
|
+
|
|
710
|
+
Args:
|
|
711
|
+
controls: The control qubits
|
|
712
|
+
target: The target qubit
|
|
713
|
+
|
|
714
|
+
See Also:
|
|
715
|
+
:meth:`z`
|
|
716
|
+
"""
|
|
717
|
+
|
|
718
|
+
def h(self, q: int) -> None:
|
|
719
|
+
r"""Apply a Hadamard gate.
|
|
720
|
+
|
|
721
|
+
.. math::
|
|
722
|
+
H = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}
|
|
723
|
+
|
|
724
|
+
Args:
|
|
725
|
+
q: The target qubit
|
|
726
|
+
"""
|
|
727
|
+
|
|
728
|
+
def ch(self, control: Control | int, target: int) -> None:
|
|
729
|
+
"""Apply a controlled Hadamard gate.
|
|
730
|
+
|
|
731
|
+
Args:
|
|
732
|
+
control: The control qubit
|
|
733
|
+
target: The target qubit
|
|
734
|
+
|
|
735
|
+
See Also:
|
|
736
|
+
:meth:`h`
|
|
737
|
+
"""
|
|
738
|
+
|
|
739
|
+
def mch(self, controls: set[Control | int], target: int) -> None:
|
|
740
|
+
"""Apply a multi-controlled Hadamard gate.
|
|
741
|
+
|
|
742
|
+
Args:
|
|
743
|
+
controls: The control qubits
|
|
744
|
+
target: The target qubit
|
|
745
|
+
|
|
746
|
+
See Also:
|
|
747
|
+
:meth:`h`
|
|
748
|
+
"""
|
|
749
|
+
|
|
750
|
+
def s(self, q: int) -> None:
|
|
751
|
+
r"""Apply an S gate (phase gate).
|
|
752
|
+
|
|
753
|
+
.. math::
|
|
754
|
+
S = \begin{pmatrix} 1 & 0 \\ 0 & i \end{pmatrix}
|
|
755
|
+
|
|
756
|
+
Args:
|
|
757
|
+
q: The target qubit
|
|
758
|
+
"""
|
|
759
|
+
|
|
760
|
+
def cs(self, control: Control | int, target: int) -> None:
|
|
761
|
+
"""Apply a controlled S gate (CS gate).
|
|
762
|
+
|
|
763
|
+
Args:
|
|
764
|
+
control: The control qubit
|
|
765
|
+
target: The target qubit
|
|
766
|
+
|
|
767
|
+
See Also:
|
|
768
|
+
:meth:`s`
|
|
769
|
+
"""
|
|
770
|
+
|
|
771
|
+
def mcs(self, controls: set[Control | int], target: int) -> None:
|
|
772
|
+
"""Apply a multi-controlled S gate.
|
|
773
|
+
|
|
774
|
+
Args:
|
|
775
|
+
controls: The control qubits
|
|
776
|
+
target: The target qubit
|
|
777
|
+
|
|
778
|
+
See Also:
|
|
779
|
+
:meth:`s`
|
|
780
|
+
"""
|
|
781
|
+
|
|
782
|
+
def sdg(self, q: int) -> None:
|
|
783
|
+
r"""Apply an :math:`S^{\dagger}` gate.
|
|
784
|
+
|
|
785
|
+
.. math::
|
|
786
|
+
S^{\dagger} = \begin{pmatrix} 1 & 0 \\ 0 & -i \end{pmatrix}
|
|
787
|
+
|
|
788
|
+
Args:
|
|
789
|
+
q: The target qubit
|
|
790
|
+
"""
|
|
791
|
+
|
|
792
|
+
def csdg(self, control: Control | int, target: int) -> None:
|
|
793
|
+
r"""Apply a controlled :math:`S^{\dagger}` gate.
|
|
794
|
+
|
|
795
|
+
Args:
|
|
796
|
+
control: The control qubit
|
|
797
|
+
target: The target qubit
|
|
798
|
+
|
|
799
|
+
See Also:
|
|
800
|
+
:meth:`sdg`
|
|
801
|
+
"""
|
|
802
|
+
|
|
803
|
+
def mcsdg(self, controls: set[Control | int], target: int) -> None:
|
|
804
|
+
r"""Apply a multi-controlled :math:`S^{\dagger}` gate.
|
|
805
|
+
|
|
806
|
+
Args:
|
|
807
|
+
controls: The control qubits
|
|
808
|
+
target: The target qubit
|
|
809
|
+
|
|
810
|
+
See Also:
|
|
811
|
+
:meth:`sdg`
|
|
812
|
+
"""
|
|
813
|
+
|
|
814
|
+
def t(self, q: int) -> None:
|
|
815
|
+
r"""Apply a T gate.
|
|
816
|
+
|
|
817
|
+
.. math::
|
|
818
|
+
T = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\pi/4} \end{pmatrix}
|
|
819
|
+
|
|
820
|
+
Args:
|
|
821
|
+
q: The target qubit
|
|
822
|
+
"""
|
|
823
|
+
|
|
824
|
+
def ct(self, control: Control | int, target: int) -> None:
|
|
825
|
+
"""Apply a controlled T gate.
|
|
826
|
+
|
|
827
|
+
Args:
|
|
828
|
+
control: The control qubit
|
|
829
|
+
target: The target qubit
|
|
830
|
+
|
|
831
|
+
See Also:
|
|
832
|
+
:meth:`t`
|
|
833
|
+
"""
|
|
834
|
+
|
|
835
|
+
def mct(self, controls: set[Control | int], target: int) -> None:
|
|
836
|
+
"""Apply a multi-controlled T gate.
|
|
837
|
+
|
|
838
|
+
Args:
|
|
839
|
+
controls: The control qubits
|
|
840
|
+
target: The target qubit
|
|
841
|
+
|
|
842
|
+
See Also:
|
|
843
|
+
:meth:`t`
|
|
844
|
+
"""
|
|
845
|
+
|
|
846
|
+
def tdg(self, q: int) -> None:
|
|
847
|
+
r"""Apply a :math:`T^{\dagger}` gate.
|
|
848
|
+
|
|
849
|
+
.. math::
|
|
850
|
+
T^{\dagger} = \begin{pmatrix} 1 & 0 \\ 0 & e^{-i\pi/4} \end{pmatrix}
|
|
851
|
+
|
|
852
|
+
Args:
|
|
853
|
+
q: The target qubit
|
|
854
|
+
"""
|
|
855
|
+
|
|
856
|
+
def ctdg(self, control: Control | int, target: int) -> None:
|
|
857
|
+
r"""Apply a controlled :math:`T^{\dagger}` gate.
|
|
858
|
+
|
|
859
|
+
Args:
|
|
860
|
+
control: The control qubit
|
|
861
|
+
target: The target qubit
|
|
862
|
+
|
|
863
|
+
See Also:
|
|
864
|
+
:meth:`tdg`
|
|
865
|
+
"""
|
|
866
|
+
|
|
867
|
+
def mctdg(self, controls: set[Control | int], target: int) -> None:
|
|
868
|
+
r"""Apply a multi-controlled :math:`T^{\dagger}` gate.
|
|
869
|
+
|
|
870
|
+
Args:
|
|
871
|
+
controls: The control qubits
|
|
872
|
+
target: The target qubit
|
|
873
|
+
|
|
874
|
+
See Also:
|
|
875
|
+
:meth:`tdg`
|
|
876
|
+
"""
|
|
877
|
+
|
|
878
|
+
def v(self, q: int) -> None:
|
|
879
|
+
r"""Apply a V gate.
|
|
880
|
+
|
|
881
|
+
.. math::
|
|
882
|
+
V = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -i \\ -i & 1 \end{pmatrix}
|
|
883
|
+
|
|
884
|
+
Args:
|
|
885
|
+
q: The target qubit
|
|
886
|
+
"""
|
|
887
|
+
|
|
888
|
+
def cv(self, control: Control | int, target: int) -> None:
|
|
889
|
+
"""Apply a controlled V gate.
|
|
890
|
+
|
|
891
|
+
Args:
|
|
892
|
+
control: The control qubit
|
|
893
|
+
target: The target qubit
|
|
894
|
+
|
|
895
|
+
See Also:
|
|
896
|
+
:meth:`v`
|
|
897
|
+
"""
|
|
898
|
+
|
|
899
|
+
def mcv(self, controls: set[Control | int], target: int) -> None:
|
|
900
|
+
"""Apply a multi-controlled V gate.
|
|
901
|
+
|
|
902
|
+
Args:
|
|
903
|
+
controls: The control qubits
|
|
904
|
+
target: The target qubit
|
|
905
|
+
|
|
906
|
+
See Also:
|
|
907
|
+
:meth:`v`
|
|
908
|
+
"""
|
|
909
|
+
|
|
910
|
+
def vdg(self, q: int) -> None:
|
|
911
|
+
r"""Apply a :math:`V^{\dagger}` gate.
|
|
912
|
+
|
|
913
|
+
.. math::
|
|
914
|
+
V^{\dagger} = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & i \\ i & 1 \end{pmatrix}
|
|
915
|
+
|
|
916
|
+
Args:
|
|
917
|
+
q: The target qubit
|
|
918
|
+
"""
|
|
919
|
+
|
|
920
|
+
def cvdg(self, control: Control | int, target: int) -> None:
|
|
921
|
+
r"""Apply a controlled :math:`V^{\dagger}` gate.
|
|
922
|
+
|
|
923
|
+
Args:
|
|
924
|
+
control: The control qubit
|
|
925
|
+
target: The target qubit
|
|
926
|
+
|
|
927
|
+
See Also:
|
|
928
|
+
:meth:`vdg`
|
|
929
|
+
"""
|
|
930
|
+
|
|
931
|
+
def mcvdg(self, controls: set[Control | int], target: int) -> None:
|
|
932
|
+
r"""Apply a multi-controlled :math:`V^{\dagger}` gate.
|
|
933
|
+
|
|
934
|
+
Args:
|
|
935
|
+
controls: The control qubits
|
|
936
|
+
target: The target qubit
|
|
937
|
+
|
|
938
|
+
See Also:
|
|
939
|
+
:meth:`vdg`
|
|
940
|
+
"""
|
|
941
|
+
|
|
942
|
+
def sx(self, q: int) -> None:
|
|
943
|
+
r"""Apply a :math:`\sqrt{X}` gate.
|
|
944
|
+
|
|
945
|
+
.. math::
|
|
946
|
+
\sqrt{X} = \frac{1}{2} \begin{pmatrix} 1 + i & 1 - i \\ 1 - i & 1 + i \end{pmatrix}
|
|
947
|
+
|
|
948
|
+
Args:
|
|
949
|
+
q: The target qubit
|
|
950
|
+
"""
|
|
951
|
+
|
|
952
|
+
def csx(self, control: Control | int, target: int) -> None:
|
|
953
|
+
r"""Apply a controlled :math:`\sqrt{X}` gate.
|
|
954
|
+
|
|
955
|
+
Args:
|
|
956
|
+
control: The control qubit
|
|
957
|
+
target: The target qubit
|
|
958
|
+
|
|
959
|
+
See Also:
|
|
960
|
+
:meth:`sx`
|
|
961
|
+
"""
|
|
962
|
+
|
|
963
|
+
def mcsx(self, controls: set[Control | int], target: int) -> None:
|
|
964
|
+
r"""Apply a multi-controlled :math:`\sqrt{X}` gate.
|
|
965
|
+
|
|
966
|
+
Args:
|
|
967
|
+
controls: The control qubits
|
|
968
|
+
target: The target qubit
|
|
969
|
+
|
|
970
|
+
See Also:
|
|
971
|
+
:meth:`sx`
|
|
972
|
+
"""
|
|
973
|
+
|
|
974
|
+
def sxdg(self, q: int) -> None:
|
|
975
|
+
r"""Apply a :math:`\sqrt{X}^{\dagger}` gate.
|
|
976
|
+
|
|
977
|
+
.. math::
|
|
978
|
+
\sqrt{X}^{\dagger} = \frac{1}{2} \begin{pmatrix} 1 - i & 1 + i \\ 1 + i & 1 - i \end{pmatrix}
|
|
979
|
+
|
|
980
|
+
Args:
|
|
981
|
+
q: The target qubit
|
|
982
|
+
"""
|
|
983
|
+
|
|
984
|
+
def csxdg(self, control: Control | int, target: int) -> None:
|
|
985
|
+
r"""Apply a controlled :math:`\sqrt{X}^{\dagger}` gate.
|
|
986
|
+
|
|
987
|
+
Args:
|
|
988
|
+
control: The control qubit
|
|
989
|
+
target: The target qubit
|
|
990
|
+
|
|
991
|
+
See Also:
|
|
992
|
+
:meth:`sxdg`
|
|
993
|
+
"""
|
|
994
|
+
|
|
995
|
+
def mcsxdg(self, controls: set[Control | int], target: int) -> None:
|
|
996
|
+
r"""Apply a multi-controlled :math:`\sqrt{X}^{\dagger}` gate.
|
|
997
|
+
|
|
998
|
+
Args:
|
|
999
|
+
controls: The control qubits
|
|
1000
|
+
target: The target qubit
|
|
1001
|
+
|
|
1002
|
+
See Also:
|
|
1003
|
+
:meth:`sxdg`
|
|
1004
|
+
"""
|
|
1005
|
+
|
|
1006
|
+
def r(self, theta: float | Expression, phi: float | Expression, q: int) -> None:
|
|
1007
|
+
r"""Apply an :math:`R(\theta, \phi)` gate.
|
|
1008
|
+
|
|
1009
|
+
.. math::
|
|
1010
|
+
R(\theta, \phi) = e^{-i\frac{\theta}{2}(\cos(\phi)X+\sin(\phi)Y)}
|
|
1011
|
+
= \begin{pmatrix} \cos(\theta/2) & -i e^{-i\phi} \sin(\theta/2) \\
|
|
1012
|
+
-i e^{i\phi} \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}
|
|
1013
|
+
|
|
1014
|
+
Args:
|
|
1015
|
+
theta: The rotation angle :math:`\theta`
|
|
1016
|
+
phi: The angle specifying the rotation axis given by :math:`\cos(\phi)X+\sin(\phi)Y`
|
|
1017
|
+
q: The target qubit
|
|
1018
|
+
"""
|
|
1019
|
+
|
|
1020
|
+
def cr(self, theta: float | Expression, phi: float | Expression, control: Control | int, target: int) -> None:
|
|
1021
|
+
r"""Apply a controlled :math:`R(\theta, \phi)` gate.
|
|
1022
|
+
|
|
1023
|
+
Args:
|
|
1024
|
+
theta: The rotation angle :math:`\theta`
|
|
1025
|
+
phi: The angle specifying the rotation axis given by :math:`\cos(\phi)X+\sin(\phi)Y`
|
|
1026
|
+
control: The control qubit
|
|
1027
|
+
target: The target qubit
|
|
1028
|
+
|
|
1029
|
+
See Also:
|
|
1030
|
+
:meth:`r`
|
|
1031
|
+
"""
|
|
1032
|
+
|
|
1033
|
+
def mcr(
|
|
1034
|
+
self, theta: float | Expression, phi: float | Expression, controls: set[Control | int], target: int
|
|
1035
|
+
) -> None:
|
|
1036
|
+
r"""Apply a multi-controlled :math:`R(\theta, \phi)` gate.
|
|
1037
|
+
|
|
1038
|
+
Args:
|
|
1039
|
+
theta: The rotation angle :math:`\theta`
|
|
1040
|
+
phi: The angle specifying the rotation axis given by :math:`\cos(\phi)X+\sin(\phi)Y`
|
|
1041
|
+
controls: The control qubits
|
|
1042
|
+
target: The target qubit
|
|
1043
|
+
|
|
1044
|
+
See Also:
|
|
1045
|
+
:meth:`r`
|
|
1046
|
+
"""
|
|
1047
|
+
|
|
1048
|
+
def rx(self, theta: float | Expression, q: int) -> None:
|
|
1049
|
+
r"""Apply an :math:`R_x(\theta)` gate.
|
|
1050
|
+
|
|
1051
|
+
.. math::
|
|
1052
|
+
R_x(\theta) = e^{-i\theta X/2} = \cos(\theta/2) I - i \sin(\theta/2) X
|
|
1053
|
+
= \begin{pmatrix} \cos(\theta/2) & -i \sin(\theta/2) \\ -i \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}
|
|
1054
|
+
|
|
1055
|
+
Args:
|
|
1056
|
+
theta: The rotation angle
|
|
1057
|
+
q: The target qubit
|
|
1058
|
+
"""
|
|
1059
|
+
|
|
1060
|
+
def crx(self, theta: float | Expression, control: Control | int, target: int) -> None:
|
|
1061
|
+
r"""Apply a controlled :math:`R_x(\theta)` gate.
|
|
1062
|
+
|
|
1063
|
+
Args:
|
|
1064
|
+
theta: The rotation angle
|
|
1065
|
+
control: The control qubit
|
|
1066
|
+
target: The target qubit
|
|
1067
|
+
|
|
1068
|
+
See Also:
|
|
1069
|
+
:meth:`rx`
|
|
1070
|
+
"""
|
|
1071
|
+
|
|
1072
|
+
def mcrx(self, theta: float | Expression, controls: set[Control | int], target: int) -> None:
|
|
1073
|
+
r"""Apply a multi-controlled :math:`R_x(\theta)` gate.
|
|
1074
|
+
|
|
1075
|
+
Args:
|
|
1076
|
+
theta: The rotation angle
|
|
1077
|
+
controls: The control qubits
|
|
1078
|
+
target: The target qubit
|
|
1079
|
+
|
|
1080
|
+
See Also:
|
|
1081
|
+
:meth:`rx`
|
|
1082
|
+
"""
|
|
1083
|
+
|
|
1084
|
+
def ry(self, theta: float | Expression, q: int) -> None:
|
|
1085
|
+
r"""Apply an :math:`R_y(\theta)` gate.
|
|
1086
|
+
|
|
1087
|
+
.. math::
|
|
1088
|
+
R_y(\theta) = e^{-i\theta Y/2} = \cos(\theta/2) I - i \sin(\theta/2) Y
|
|
1089
|
+
= \begin{pmatrix} \cos(\theta/2) & -\sin(\theta/2) \\ \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}
|
|
1090
|
+
|
|
1091
|
+
Args:
|
|
1092
|
+
theta: The rotation angle
|
|
1093
|
+
q: The target qubit
|
|
1094
|
+
"""
|
|
1095
|
+
|
|
1096
|
+
def cry(self, theta: float | Expression, control: Control | int, target: int) -> None:
|
|
1097
|
+
r"""Apply a controlled :math:`R_y(\theta)` gate.
|
|
1098
|
+
|
|
1099
|
+
Args:
|
|
1100
|
+
theta: The rotation angle
|
|
1101
|
+
control: The control qubit
|
|
1102
|
+
target: The target qubit
|
|
1103
|
+
|
|
1104
|
+
See Also:
|
|
1105
|
+
:meth:`ry`
|
|
1106
|
+
"""
|
|
1107
|
+
|
|
1108
|
+
def mcry(self, theta: float | Expression, controls: set[Control | int], target: int) -> None:
|
|
1109
|
+
r"""Apply a multi-controlled :math:`R_y(\theta)` gate.
|
|
1110
|
+
|
|
1111
|
+
Args:
|
|
1112
|
+
theta: The rotation angle
|
|
1113
|
+
controls: The control qubits
|
|
1114
|
+
target: The target qubit
|
|
1115
|
+
|
|
1116
|
+
See Also:
|
|
1117
|
+
:meth:`ry`
|
|
1118
|
+
"""
|
|
1119
|
+
|
|
1120
|
+
def rz(self, theta: float | Expression, q: int) -> None:
|
|
1121
|
+
r"""Apply an :math:`R_z(\theta)` gate.
|
|
1122
|
+
|
|
1123
|
+
.. math::
|
|
1124
|
+
R_z(\theta) = e^{-i\theta Z/2} = \begin{pmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{pmatrix}
|
|
1125
|
+
|
|
1126
|
+
Args:
|
|
1127
|
+
theta: The rotation angle
|
|
1128
|
+
q: The target qubit
|
|
1129
|
+
"""
|
|
1130
|
+
|
|
1131
|
+
def crz(self, theta: float | Expression, control: Control | int, target: int) -> None:
|
|
1132
|
+
r"""Apply a controlled :math:`R_z(\theta)` gate.
|
|
1133
|
+
|
|
1134
|
+
Args:
|
|
1135
|
+
theta: The rotation angle
|
|
1136
|
+
control: The control qubit
|
|
1137
|
+
target: The target qubit
|
|
1138
|
+
|
|
1139
|
+
See Also:
|
|
1140
|
+
:meth:`rz`
|
|
1141
|
+
"""
|
|
1142
|
+
|
|
1143
|
+
def mcrz(self, theta: float | Expression, controls: set[Control | int], target: int) -> None:
|
|
1144
|
+
r"""Apply a multi-controlled :math:`R_z(\theta)` gate.
|
|
1145
|
+
|
|
1146
|
+
Args:
|
|
1147
|
+
theta: The rotation angle
|
|
1148
|
+
controls: The control qubits
|
|
1149
|
+
target: The target qubit
|
|
1150
|
+
|
|
1151
|
+
See Also:
|
|
1152
|
+
:meth:`rz`
|
|
1153
|
+
"""
|
|
1154
|
+
|
|
1155
|
+
def p(self, theta: float | Expression, q: int) -> None:
|
|
1156
|
+
r"""Apply a phase gate.
|
|
1157
|
+
|
|
1158
|
+
.. math::
|
|
1159
|
+
P(\theta) = \begin{pmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{pmatrix}
|
|
1160
|
+
|
|
1161
|
+
Args:
|
|
1162
|
+
theta: The rotation angle
|
|
1163
|
+
q: The target qubit
|
|
1164
|
+
"""
|
|
1165
|
+
|
|
1166
|
+
def cp(self, theta: float | Expression, control: Control | int, target: int) -> None:
|
|
1167
|
+
"""Apply a controlled phase gate.
|
|
1168
|
+
|
|
1169
|
+
Args:
|
|
1170
|
+
theta: The rotation angle
|
|
1171
|
+
control: The control qubit
|
|
1172
|
+
target: The target qubit
|
|
1173
|
+
|
|
1174
|
+
See Also:
|
|
1175
|
+
:meth:`p`
|
|
1176
|
+
"""
|
|
1177
|
+
|
|
1178
|
+
def mcp(self, theta: float | Expression, controls: set[Control | int], target: int) -> None:
|
|
1179
|
+
"""Apply a multi-controlled phase gate.
|
|
1180
|
+
|
|
1181
|
+
Args:
|
|
1182
|
+
theta: The rotation angle
|
|
1183
|
+
controls: The control qubits
|
|
1184
|
+
target: The target qubit
|
|
1185
|
+
|
|
1186
|
+
See Also:
|
|
1187
|
+
:meth:`p`
|
|
1188
|
+
"""
|
|
1189
|
+
|
|
1190
|
+
def u2(self, phi: float | Expression, lambda_: float | Expression, q: int) -> None:
|
|
1191
|
+
r"""Apply a :math:`U_2(\phi, \lambda)` gate.
|
|
1192
|
+
|
|
1193
|
+
.. math::
|
|
1194
|
+
U_2(\phi, \lambda) =
|
|
1195
|
+
\frac{1}{\sqrt{2}} \begin{pmatrix} 1 & -e^{i\lambda} \\ e^{i\phi} & e^{i(\phi + \lambda)} \end{pmatrix}
|
|
1196
|
+
|
|
1197
|
+
Args:
|
|
1198
|
+
phi: The rotation angle
|
|
1199
|
+
lambda_: The rotation angle
|
|
1200
|
+
q: The target qubit
|
|
1201
|
+
"""
|
|
1202
|
+
|
|
1203
|
+
def cu2(self, phi: float | Expression, lambda_: float | Expression, control: Control | int, target: int) -> None:
|
|
1204
|
+
r"""Apply a controlled :math:`U_2(\phi, \lambda)` gate.
|
|
1205
|
+
|
|
1206
|
+
Args:
|
|
1207
|
+
phi: The rotation angle
|
|
1208
|
+
lambda_: The rotation angle
|
|
1209
|
+
control: The control qubit
|
|
1210
|
+
target: The target qubit
|
|
1211
|
+
|
|
1212
|
+
See Also:
|
|
1213
|
+
:meth:`u2`
|
|
1214
|
+
"""
|
|
1215
|
+
|
|
1216
|
+
def mcu2(
|
|
1217
|
+
self,
|
|
1218
|
+
phi: float | Expression,
|
|
1219
|
+
lambda_: float | Expression,
|
|
1220
|
+
controls: set[Control | int],
|
|
1221
|
+
target: int,
|
|
1222
|
+
) -> None:
|
|
1223
|
+
r"""Apply a multi-controlled :math:`U_2(\phi, \lambda)` gate.
|
|
1224
|
+
|
|
1225
|
+
Args:
|
|
1226
|
+
phi: The rotation angle
|
|
1227
|
+
lambda_: The rotation angle
|
|
1228
|
+
controls: The control qubits
|
|
1229
|
+
target: The target qubit
|
|
1230
|
+
|
|
1231
|
+
See Also:
|
|
1232
|
+
:meth:`u2`
|
|
1233
|
+
"""
|
|
1234
|
+
|
|
1235
|
+
def u(self, theta: float | Expression, phi: float | Expression, lambda_: float | Expression, q: int) -> None:
|
|
1236
|
+
r"""Apply a :math:`U(\theta, \phi, \lambda)` gate.
|
|
1237
|
+
|
|
1238
|
+
.. math::
|
|
1239
|
+
U(\theta, \phi, \lambda) =
|
|
1240
|
+
\begin{pmatrix} \cos(\theta/2) & -e^{i\lambda}\sin(\theta/2) \\
|
|
1241
|
+
e^{i\phi}\sin(\theta/2) & e^{i(\phi + \lambda)}\cos(\theta/2) \end{pmatrix}
|
|
1242
|
+
|
|
1243
|
+
Args:
|
|
1244
|
+
theta: The rotation angle
|
|
1245
|
+
phi: The rotation angle
|
|
1246
|
+
lambda_: The rotation angle
|
|
1247
|
+
q: The target qubit
|
|
1248
|
+
"""
|
|
1249
|
+
|
|
1250
|
+
def cu(
|
|
1251
|
+
self,
|
|
1252
|
+
theta: float | Expression,
|
|
1253
|
+
phi: float | Expression,
|
|
1254
|
+
lambda_: float | Expression,
|
|
1255
|
+
control: Control | int,
|
|
1256
|
+
target: int,
|
|
1257
|
+
) -> None:
|
|
1258
|
+
r"""Apply a controlled :math:`U(\theta, \phi, \lambda)` gate.
|
|
1259
|
+
|
|
1260
|
+
Args:
|
|
1261
|
+
theta: The rotation angle
|
|
1262
|
+
phi: The rotation angle
|
|
1263
|
+
lambda_: The rotation angle
|
|
1264
|
+
control: The control qubit
|
|
1265
|
+
target: The target qubit
|
|
1266
|
+
|
|
1267
|
+
See Also:
|
|
1268
|
+
:meth:`u`
|
|
1269
|
+
"""
|
|
1270
|
+
|
|
1271
|
+
def mcu(
|
|
1272
|
+
self,
|
|
1273
|
+
theta: float | Expression,
|
|
1274
|
+
phi: float | Expression,
|
|
1275
|
+
lambda_: float | Expression,
|
|
1276
|
+
controls: set[Control | int],
|
|
1277
|
+
target: int,
|
|
1278
|
+
) -> None:
|
|
1279
|
+
r"""Apply a multi-controlled :math:`U(\theta, \phi, \lambda)` gate.
|
|
1280
|
+
|
|
1281
|
+
Args:
|
|
1282
|
+
theta: The rotation angle
|
|
1283
|
+
phi: The rotation angle
|
|
1284
|
+
lambda_: The rotation angle
|
|
1285
|
+
controls: The control qubits
|
|
1286
|
+
target: The target qubit
|
|
1287
|
+
|
|
1288
|
+
See Also:
|
|
1289
|
+
:meth:`u`
|
|
1290
|
+
"""
|
|
1291
|
+
|
|
1292
|
+
def swap(self, target1: int, target2: int) -> None:
|
|
1293
|
+
r"""Apply a SWAP gate.
|
|
1294
|
+
|
|
1295
|
+
.. math::
|
|
1296
|
+
SWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}
|
|
1297
|
+
|
|
1298
|
+
Args:
|
|
1299
|
+
target1: The first target qubit
|
|
1300
|
+
target2: The second target qubit
|
|
1301
|
+
"""
|
|
1302
|
+
|
|
1303
|
+
def cswap(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1304
|
+
"""Apply a controlled SWAP gate.
|
|
1305
|
+
|
|
1306
|
+
Args:
|
|
1307
|
+
control: The control qubit
|
|
1308
|
+
target1: The first target qubit
|
|
1309
|
+
target2: The second target qubit
|
|
1310
|
+
|
|
1311
|
+
See Also:
|
|
1312
|
+
:meth:`swap`
|
|
1313
|
+
"""
|
|
1314
|
+
|
|
1315
|
+
def mcswap(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1316
|
+
"""Apply a multi-controlled SWAP gate.
|
|
1317
|
+
|
|
1318
|
+
Args:
|
|
1319
|
+
controls: The control qubits
|
|
1320
|
+
target1: The first target qubit
|
|
1321
|
+
target2: The second target qubit
|
|
1322
|
+
|
|
1323
|
+
See Also:
|
|
1324
|
+
:meth:`swap`
|
|
1325
|
+
"""
|
|
1326
|
+
|
|
1327
|
+
def dcx(self, target1: int, target2: int) -> None:
|
|
1328
|
+
r"""Apply a DCX (double CNOT) gate.
|
|
1329
|
+
|
|
1330
|
+
.. math::
|
|
1331
|
+
DCX = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \end{pmatrix}
|
|
1332
|
+
|
|
1333
|
+
Args:
|
|
1334
|
+
target1: The first target qubit
|
|
1335
|
+
target2: The second target qubit
|
|
1336
|
+
"""
|
|
1337
|
+
|
|
1338
|
+
def cdcx(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1339
|
+
"""Apply a controlled DCX (double CNOT) gate.
|
|
1340
|
+
|
|
1341
|
+
Args:
|
|
1342
|
+
control: The control qubit
|
|
1343
|
+
target1: The first target qubit
|
|
1344
|
+
target2: The second target qubit
|
|
1345
|
+
|
|
1346
|
+
See Also:
|
|
1347
|
+
:meth:`dcx`
|
|
1348
|
+
"""
|
|
1349
|
+
|
|
1350
|
+
def mcdcx(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1351
|
+
"""Apply a multi-controlled DCX (double CNOT) gate.
|
|
1352
|
+
|
|
1353
|
+
Args:
|
|
1354
|
+
controls: The control qubits
|
|
1355
|
+
target1: The first target qubit
|
|
1356
|
+
target2: The second target qubit
|
|
1357
|
+
|
|
1358
|
+
See Also:
|
|
1359
|
+
:meth:`dcx`
|
|
1360
|
+
"""
|
|
1361
|
+
|
|
1362
|
+
def ecr(self, target1: int, target2: int) -> None:
|
|
1363
|
+
r"""Apply an ECR (echoed cross-resonance) gate.
|
|
1364
|
+
|
|
1365
|
+
.. math::
|
|
1366
|
+
ECR = \frac{1}{\sqrt{2}}
|
|
1367
|
+
\begin{pmatrix} 0 & 0 & 1 & i \\ 0 & 0 & i & 1 \\ 1 & -i & 0 & 0 \\ -i & 1 & 0 & 0 \end{pmatrix}
|
|
1368
|
+
|
|
1369
|
+
Args:
|
|
1370
|
+
target1: The first target qubit
|
|
1371
|
+
target2: The second target qubit
|
|
1372
|
+
"""
|
|
1373
|
+
|
|
1374
|
+
def cecr(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1375
|
+
"""Apply a controlled ECR (echoed cross-resonance) gate.
|
|
1376
|
+
|
|
1377
|
+
Args:
|
|
1378
|
+
control: The control qubit
|
|
1379
|
+
target1: The first target qubit
|
|
1380
|
+
target2: The second target qubit
|
|
1381
|
+
|
|
1382
|
+
See Also:
|
|
1383
|
+
:meth:`ecr`
|
|
1384
|
+
"""
|
|
1385
|
+
|
|
1386
|
+
def mcecr(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1387
|
+
"""Apply a multi-controlled ECR (echoed cross-resonance) gate.
|
|
1388
|
+
|
|
1389
|
+
Args:
|
|
1390
|
+
controls: The control qubits
|
|
1391
|
+
target1: The first target qubit
|
|
1392
|
+
target2: The second target qubit
|
|
1393
|
+
|
|
1394
|
+
See Also:
|
|
1395
|
+
:meth:`ecr`
|
|
1396
|
+
"""
|
|
1397
|
+
|
|
1398
|
+
def iswap(self, target1: int, target2: int) -> None:
|
|
1399
|
+
r"""Apply an iSWAP gate.
|
|
1400
|
+
|
|
1401
|
+
.. math::
|
|
1402
|
+
iSWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}
|
|
1403
|
+
|
|
1404
|
+
Args:
|
|
1405
|
+
target1: The first target qubit
|
|
1406
|
+
target2: The second target qubit
|
|
1407
|
+
"""
|
|
1408
|
+
|
|
1409
|
+
def ciswap(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1410
|
+
"""Apply a controlled iSWAP gate.
|
|
1411
|
+
|
|
1412
|
+
Args:
|
|
1413
|
+
control: The control qubit
|
|
1414
|
+
target1: The first target qubit
|
|
1415
|
+
target2: The second target qubit
|
|
1416
|
+
|
|
1417
|
+
See Also:
|
|
1418
|
+
:meth:`iswap`
|
|
1419
|
+
"""
|
|
1420
|
+
|
|
1421
|
+
def mciswap(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1422
|
+
"""Apply a multi-controlled iSWAP gate.
|
|
1423
|
+
|
|
1424
|
+
Args:
|
|
1425
|
+
controls: The control qubits
|
|
1426
|
+
target1: The first target qubit
|
|
1427
|
+
target2: The second target qubit
|
|
1428
|
+
|
|
1429
|
+
See Also:
|
|
1430
|
+
:meth:`iswap`
|
|
1431
|
+
"""
|
|
1432
|
+
|
|
1433
|
+
def iswapdg(self, target1: int, target2: int) -> None:
|
|
1434
|
+
r"""Apply an :math:`iSWAP^{\dagger}` gate.
|
|
1435
|
+
|
|
1436
|
+
.. math::
|
|
1437
|
+
iSWAP^{\dagger} =
|
|
1438
|
+
\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & -i & 0 \\ 0 & -i & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}
|
|
1439
|
+
|
|
1440
|
+
Args:
|
|
1441
|
+
target1: The first target qubit
|
|
1442
|
+
target2: The second target qubit
|
|
1443
|
+
"""
|
|
1444
|
+
|
|
1445
|
+
def ciswapdg(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1446
|
+
r"""Apply a controlled :math:`iSWAP^{\dagger}` gate.
|
|
1447
|
+
|
|
1448
|
+
Args:
|
|
1449
|
+
control: The control qubit
|
|
1450
|
+
target1: The first target qubit
|
|
1451
|
+
target2: The second target qubit
|
|
1452
|
+
|
|
1453
|
+
See Also:
|
|
1454
|
+
:meth:`iswapdg`
|
|
1455
|
+
"""
|
|
1456
|
+
|
|
1457
|
+
def mciswapdg(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1458
|
+
r"""Apply a multi-controlled :math:`iSWAP^{\dagger}` gate.
|
|
1459
|
+
|
|
1460
|
+
Args:
|
|
1461
|
+
controls: The control qubits
|
|
1462
|
+
target1: The first target qubit
|
|
1463
|
+
target2: The second target qubit
|
|
1464
|
+
|
|
1465
|
+
See Also:
|
|
1466
|
+
:meth:`iswapdg`
|
|
1467
|
+
"""
|
|
1468
|
+
|
|
1469
|
+
def peres(self, target1: int, target2: int) -> None:
|
|
1470
|
+
r"""Apply a Peres gate.
|
|
1471
|
+
|
|
1472
|
+
.. math::
|
|
1473
|
+
Peres = \begin{pmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \end{pmatrix}
|
|
1474
|
+
|
|
1475
|
+
Args:
|
|
1476
|
+
target1: The first target qubit
|
|
1477
|
+
target2: The second target qubit
|
|
1478
|
+
"""
|
|
1479
|
+
|
|
1480
|
+
def cperes(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1481
|
+
"""Apply a controlled Peres gate.
|
|
1482
|
+
|
|
1483
|
+
Args:
|
|
1484
|
+
control: The control qubit
|
|
1485
|
+
target1: The first target qubit
|
|
1486
|
+
target2: The second target qubit
|
|
1487
|
+
|
|
1488
|
+
See Also:
|
|
1489
|
+
:meth:`peres`
|
|
1490
|
+
"""
|
|
1491
|
+
|
|
1492
|
+
def mcperes(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1493
|
+
"""Apply a multi-controlled Peres gate.
|
|
1494
|
+
|
|
1495
|
+
Args:
|
|
1496
|
+
controls: The control qubits
|
|
1497
|
+
target1: The first target qubit
|
|
1498
|
+
target2: The second target qubit
|
|
1499
|
+
|
|
1500
|
+
See Also:
|
|
1501
|
+
:meth:`peres`
|
|
1502
|
+
"""
|
|
1503
|
+
|
|
1504
|
+
def peresdg(self, target1: int, target2: int) -> None:
|
|
1505
|
+
r"""Apply a :math:`Peres^{\dagger}` gate.
|
|
1506
|
+
|
|
1507
|
+
.. math::
|
|
1508
|
+
Peres^{\dagger} =
|
|
1509
|
+
\begin{pmatrix} 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{pmatrix}
|
|
1510
|
+
|
|
1511
|
+
Args:
|
|
1512
|
+
target1: The first target qubit
|
|
1513
|
+
target2: The second target qubit
|
|
1514
|
+
"""
|
|
1515
|
+
|
|
1516
|
+
def cperesdg(self, control: Control | int, target1: int, target2: int) -> None:
|
|
1517
|
+
r"""Apply a controlled :math:`Peres^{\dagger}` gate.
|
|
1518
|
+
|
|
1519
|
+
Args:
|
|
1520
|
+
control: The control qubit
|
|
1521
|
+
target1: The first target qubit
|
|
1522
|
+
target2: The second target qubit
|
|
1523
|
+
|
|
1524
|
+
See Also:
|
|
1525
|
+
:meth:`peresdg`
|
|
1526
|
+
"""
|
|
1527
|
+
|
|
1528
|
+
def mcperesdg(self, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1529
|
+
r"""Apply a multi-controlled :math:`Peres^{\dagger}` gate.
|
|
1530
|
+
|
|
1531
|
+
Args:
|
|
1532
|
+
controls: The control qubits
|
|
1533
|
+
target1: The first target qubit
|
|
1534
|
+
target2: The second target qubit
|
|
1535
|
+
|
|
1536
|
+
See Also:
|
|
1537
|
+
:meth:`peresdg`
|
|
1538
|
+
"""
|
|
1539
|
+
|
|
1540
|
+
def rxx(self, theta: float | Expression, target1: int, target2: int) -> None:
|
|
1541
|
+
r"""Apply an :math:`R_{xx}(\theta)` gate.
|
|
1542
|
+
|
|
1543
|
+
.. math::
|
|
1544
|
+
R_{xx}(\theta) = e^{-i\theta XX/2} = \cos(\theta/2) I\otimes I - i \sin(\theta/2) X \otimes X
|
|
1545
|
+
= \begin{pmatrix} \cos(\theta/2) & 0 & 0 & -i \sin(\theta/2) \\
|
|
1546
|
+
0 & \cos(\theta/2) & -i \sin(\theta/2) & 0 \\
|
|
1547
|
+
0 & -i \sin(\theta/2) & \cos(\theta/2) & 0 \\
|
|
1548
|
+
-i \sin(\theta/2) & 0 & 0 & \cos(\theta/2) \end{pmatrix}
|
|
1549
|
+
|
|
1550
|
+
Args:
|
|
1551
|
+
theta: The rotation angle
|
|
1552
|
+
target1: The first target qubit
|
|
1553
|
+
target2: The second target qubit
|
|
1554
|
+
"""
|
|
1555
|
+
|
|
1556
|
+
def crxx(self, theta: float | Expression, control: Control | int, target1: int, target2: int) -> None:
|
|
1557
|
+
r"""Apply a controlled :math:`R_{xx}(\theta)` gate.
|
|
1558
|
+
|
|
1559
|
+
Args:
|
|
1560
|
+
theta: The rotation angle
|
|
1561
|
+
control: The control qubit
|
|
1562
|
+
target1: The first target qubit
|
|
1563
|
+
target2: The second target qubit
|
|
1564
|
+
|
|
1565
|
+
See Also:
|
|
1566
|
+
:meth:`rxx`
|
|
1567
|
+
"""
|
|
1568
|
+
|
|
1569
|
+
def mcrxx(self, theta: float | Expression, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1570
|
+
r"""Apply a multi-controlled :math:`R_{xx}(\theta)` gate.
|
|
1571
|
+
|
|
1572
|
+
Args:
|
|
1573
|
+
theta: The rotation angle
|
|
1574
|
+
controls: The control qubits
|
|
1575
|
+
target1: The first target qubit
|
|
1576
|
+
target2: The second target qubit
|
|
1577
|
+
|
|
1578
|
+
See Also:
|
|
1579
|
+
:meth:`rxx`
|
|
1580
|
+
"""
|
|
1581
|
+
|
|
1582
|
+
def ryy(self, theta: float | Expression, target1: int, target2: int) -> None:
|
|
1583
|
+
r"""Apply an :math:`R_{yy}(\theta)` gate.
|
|
1584
|
+
|
|
1585
|
+
.. math::
|
|
1586
|
+
R_{yy}(\theta) = e^{-i\theta YY/2} = \cos(\theta/2) I\otimes I - i \sin(\theta/2) Y \otimes Y
|
|
1587
|
+
= \begin{pmatrix} \cos(\theta/2) & 0 & 0 & i \sin(\theta/2) \\
|
|
1588
|
+
0 & \cos(\theta/2) & -i \sin(\theta/2) & 0 \\
|
|
1589
|
+
0 & -i \sin(\theta/2) & \cos(\theta/2) & 0 \\
|
|
1590
|
+
i \sin(\theta/2) & 0 & 0 & \cos(\theta/2) \end{pmatrix}
|
|
1591
|
+
|
|
1592
|
+
Args:
|
|
1593
|
+
theta: The rotation angle
|
|
1594
|
+
target1: The first target qubit
|
|
1595
|
+
target2: The second target qubit
|
|
1596
|
+
"""
|
|
1597
|
+
|
|
1598
|
+
def cryy(self, theta: float | Expression, control: Control | int, target1: int, target2: int) -> None:
|
|
1599
|
+
r"""Apply a controlled :math:`R_{yy}(\theta)` gate.
|
|
1600
|
+
|
|
1601
|
+
Args:
|
|
1602
|
+
theta: The rotation angle
|
|
1603
|
+
control: The control qubit
|
|
1604
|
+
target1: The first target qubit
|
|
1605
|
+
target2: The second target qubit
|
|
1606
|
+
|
|
1607
|
+
See Also:
|
|
1608
|
+
:meth:`ryy`
|
|
1609
|
+
"""
|
|
1610
|
+
|
|
1611
|
+
def mcryy(self, theta: float | Expression, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1612
|
+
r"""Apply a multi-controlled :math:`R_{yy}(\theta)` gate.
|
|
1613
|
+
|
|
1614
|
+
Args:
|
|
1615
|
+
theta: The rotation angle
|
|
1616
|
+
controls: The control qubits
|
|
1617
|
+
target1: The first target qubit
|
|
1618
|
+
target2: The second target qubit
|
|
1619
|
+
|
|
1620
|
+
See Also:
|
|
1621
|
+
:meth:`ryy`
|
|
1622
|
+
"""
|
|
1623
|
+
|
|
1624
|
+
def rzz(self, theta: float | Expression, target1: int, target2: int) -> None:
|
|
1625
|
+
r"""Apply an :math:`R_{zz}(\theta)` gate.
|
|
1626
|
+
|
|
1627
|
+
.. math::
|
|
1628
|
+
R_{zz}(\theta) = e^{-i\theta ZZ/2} =
|
|
1629
|
+
\begin{pmatrix} e^{-i\theta/2} & 0 & 0 & 0 \\
|
|
1630
|
+
0 & e^{i\theta/2} & 0 & 0 \\
|
|
1631
|
+
0 & 0 & e^{i\theta/2} & 0 \\
|
|
1632
|
+
0 & 0 & 0 & e^{-i\theta/2} \end{pmatrix}
|
|
1633
|
+
|
|
1634
|
+
Args:
|
|
1635
|
+
theta: The rotation angle
|
|
1636
|
+
target1: The first target qubit
|
|
1637
|
+
target2: The second target qubit
|
|
1638
|
+
"""
|
|
1639
|
+
|
|
1640
|
+
def crzz(self, theta: float | Expression, control: Control | int, target1: int, target2: int) -> None:
|
|
1641
|
+
r"""Apply a controlled :math:`R_{zz}(\theta)` gate.
|
|
1642
|
+
|
|
1643
|
+
Args:
|
|
1644
|
+
theta: The rotation angle
|
|
1645
|
+
control: The control qubit
|
|
1646
|
+
target1: The first target qubit
|
|
1647
|
+
target2: The second target qubit
|
|
1648
|
+
|
|
1649
|
+
See Also:
|
|
1650
|
+
:meth:`rzz`
|
|
1651
|
+
"""
|
|
1652
|
+
|
|
1653
|
+
def mcrzz(self, theta: float | Expression, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1654
|
+
r"""Apply a multi-controlled :math:`R_{zz}(\theta)` gate.
|
|
1655
|
+
|
|
1656
|
+
Args:
|
|
1657
|
+
theta: The rotation angle
|
|
1658
|
+
controls: The control qubits
|
|
1659
|
+
target1: The first target qubit
|
|
1660
|
+
target2: The second target qubit
|
|
1661
|
+
|
|
1662
|
+
See Also:
|
|
1663
|
+
:meth:`rzz`
|
|
1664
|
+
"""
|
|
1665
|
+
|
|
1666
|
+
def rzx(self, theta: float | Expression, target1: int, target2: int) -> None:
|
|
1667
|
+
r"""Apply an :math:`R_{zx}(\theta)` gate.
|
|
1668
|
+
|
|
1669
|
+
.. math::
|
|
1670
|
+
R_{zx}(\theta) = e^{-i\theta ZX/2} = \cos(\theta/2) I\otimes I - i \sin(\theta/2) Z \otimes X =
|
|
1671
|
+
\begin{pmatrix} \cos(\theta/2) & -i \sin(\theta/2) & 0 & 0 \\
|
|
1672
|
+
-i \sin(\theta/2) & \cos(\theta/2) & 0 & 0 \\
|
|
1673
|
+
0 & 0 & \cos(\theta/2) & i \sin(\theta/2) \\
|
|
1674
|
+
0 & 0 & i \sin(\theta/2) & \cos(\theta/2) \end{pmatrix}
|
|
1675
|
+
|
|
1676
|
+
Args:
|
|
1677
|
+
theta: The rotation angle
|
|
1678
|
+
target1: The first target qubit
|
|
1679
|
+
target2: The second target qubit
|
|
1680
|
+
"""
|
|
1681
|
+
|
|
1682
|
+
def crzx(self, theta: float | Expression, control: Control | int, target1: int, target2: int) -> None:
|
|
1683
|
+
r"""Apply a controlled :math:`R_{zx}(\theta)` gate.
|
|
1684
|
+
|
|
1685
|
+
Args:
|
|
1686
|
+
theta: The rotation angle
|
|
1687
|
+
control: The control qubit
|
|
1688
|
+
target1: The first target qubit
|
|
1689
|
+
target2: The second target qubit
|
|
1690
|
+
|
|
1691
|
+
See Also:
|
|
1692
|
+
:meth:`rzx`
|
|
1693
|
+
"""
|
|
1694
|
+
|
|
1695
|
+
def mcrzx(self, theta: float | Expression, controls: set[Control | int], target1: int, target2: int) -> None:
|
|
1696
|
+
r"""Apply a multi-controlled :math:`R_{zx}(\theta)` gate.
|
|
1697
|
+
|
|
1698
|
+
Args:
|
|
1699
|
+
theta: The rotation angle
|
|
1700
|
+
controls: The control qubits
|
|
1701
|
+
target1: The first target qubit
|
|
1702
|
+
target2: The second target qubit
|
|
1703
|
+
|
|
1704
|
+
See Also:
|
|
1705
|
+
:meth:`rzx`
|
|
1706
|
+
"""
|
|
1707
|
+
|
|
1708
|
+
def xx_minus_yy(self, theta: float | Expression, beta: float | Expression, target1: int, target2: int) -> None:
|
|
1709
|
+
r"""Apply an :math:`R_{XX - YY}(\theta, \beta)` gate.
|
|
1710
|
+
|
|
1711
|
+
.. math::
|
|
1712
|
+
R_{XX - YY}(\theta, \beta)
|
|
1713
|
+
= R_{z_2}(\beta) \cdot e^{-i\frac{\theta}{2} \frac{XX-YY}{2}} \cdot R_{z_2}(-\beta)
|
|
1714
|
+
= \begin{pmatrix} \cos(\theta/2) & 0 & 0 & -i \sin(\theta/2) e^{-i\beta} \\
|
|
1715
|
+
0 & 1 & 0 & 0 \\
|
|
1716
|
+
0 & 0 & 1 & 0 \\
|
|
1717
|
+
-i \sin(\theta/2) e^{i\beta} & 0 & 0 & \cos(\theta/2) \end{pmatrix}
|
|
1718
|
+
|
|
1719
|
+
Args:
|
|
1720
|
+
theta: The rotation angle
|
|
1721
|
+
beta: The rotation angle
|
|
1722
|
+
target1: The first target qubit
|
|
1723
|
+
target2: The second target qubit
|
|
1724
|
+
"""
|
|
1725
|
+
|
|
1726
|
+
def cxx_minus_yy(
|
|
1727
|
+
self,
|
|
1728
|
+
theta: float | Expression,
|
|
1729
|
+
beta: float | Expression,
|
|
1730
|
+
control: Control | int,
|
|
1731
|
+
target1: int,
|
|
1732
|
+
target2: int,
|
|
1733
|
+
) -> None:
|
|
1734
|
+
r"""Apply a controlled :math:`R_{XX - YY}(\theta, \beta)` gate.
|
|
1735
|
+
|
|
1736
|
+
Args:
|
|
1737
|
+
theta: The rotation angle
|
|
1738
|
+
beta: The rotation angle
|
|
1739
|
+
control: The control qubit
|
|
1740
|
+
target1: The first target qubit
|
|
1741
|
+
target2: The second target qubit
|
|
1742
|
+
|
|
1743
|
+
See Also:
|
|
1744
|
+
:meth:`xx_minus_yy`
|
|
1745
|
+
"""
|
|
1746
|
+
|
|
1747
|
+
def mcxx_minus_yy(
|
|
1748
|
+
self,
|
|
1749
|
+
theta: float | Expression,
|
|
1750
|
+
beta: float | Expression,
|
|
1751
|
+
controls: set[Control | int],
|
|
1752
|
+
target1: int,
|
|
1753
|
+
target2: int,
|
|
1754
|
+
) -> None:
|
|
1755
|
+
r"""Apply a multi-controlled :math:`R_{XX - YY}(\theta, \beta)` gate.
|
|
1756
|
+
|
|
1757
|
+
Args:
|
|
1758
|
+
theta: The rotation angle
|
|
1759
|
+
beta: The rotation angle
|
|
1760
|
+
controls: The control qubits
|
|
1761
|
+
target1: The first target qubit
|
|
1762
|
+
target2: The second target qubit
|
|
1763
|
+
|
|
1764
|
+
See Also:
|
|
1765
|
+
:meth:`xx_minus_yy`
|
|
1766
|
+
"""
|
|
1767
|
+
|
|
1768
|
+
def xx_plus_yy(self, theta: float | Expression, beta: float | Expression, target1: int, target2: int) -> None:
|
|
1769
|
+
r"""Apply an :math:`R_{XX + YY}(\theta, \beta)` gate.
|
|
1770
|
+
|
|
1771
|
+
.. math::
|
|
1772
|
+
R_{XX + YY}(\theta, \beta)
|
|
1773
|
+
= R_{z_1}(\beta) \cdot e^{-i\frac{\theta}{2} \frac{XX+YY}{2}} \cdot R_{z_1}(-\beta)
|
|
1774
|
+
= \begin{pmatrix} 1 & 0 & 0 & 0 \\
|
|
1775
|
+
0 & \cos(\theta/2) & -i \sin(\theta/2) e^{-i\beta} & 0 \\
|
|
1776
|
+
0 & -i \sin(\theta/2) e^{i\beta} & \cos(\theta/2) & 0 \\
|
|
1777
|
+
0 & 0 & 0 & 1 \end{pmatrix}
|
|
1778
|
+
|
|
1779
|
+
Args:
|
|
1780
|
+
theta: The rotation angle
|
|
1781
|
+
beta: The rotation angle
|
|
1782
|
+
target1: The first target qubit
|
|
1783
|
+
target2: The second target qubit
|
|
1784
|
+
"""
|
|
1785
|
+
|
|
1786
|
+
def cxx_plus_yy(
|
|
1787
|
+
self,
|
|
1788
|
+
theta: float | Expression,
|
|
1789
|
+
beta: float | Expression,
|
|
1790
|
+
control: Control | int,
|
|
1791
|
+
target1: int,
|
|
1792
|
+
target2: int,
|
|
1793
|
+
) -> None:
|
|
1794
|
+
r"""Apply a controlled :math:`R_{XX + YY}(\theta, \beta)` gate.
|
|
1795
|
+
|
|
1796
|
+
Args:
|
|
1797
|
+
theta: The rotation angle
|
|
1798
|
+
beta: The rotation angle
|
|
1799
|
+
control: The control qubit
|
|
1800
|
+
target1: The first target qubit
|
|
1801
|
+
target2: The second target qubit
|
|
1802
|
+
|
|
1803
|
+
See Also:
|
|
1804
|
+
:meth:`xx_plus_yy`
|
|
1805
|
+
"""
|
|
1806
|
+
|
|
1807
|
+
def mcxx_plus_yy(
|
|
1808
|
+
self,
|
|
1809
|
+
theta: float | Expression,
|
|
1810
|
+
beta: float | Expression,
|
|
1811
|
+
controls: set[Control | int],
|
|
1812
|
+
target1: int,
|
|
1813
|
+
target2: int,
|
|
1814
|
+
) -> None:
|
|
1815
|
+
r"""Apply a multi-controlled :math:`R_{XX + YY}(\theta, \beta)` gate.
|
|
1816
|
+
|
|
1817
|
+
Args:
|
|
1818
|
+
theta: The rotation angle
|
|
1819
|
+
beta: The rotation angle
|
|
1820
|
+
controls: The control qubits
|
|
1821
|
+
target1: The first target qubit
|
|
1822
|
+
target2: The second target qubit
|
|
1823
|
+
|
|
1824
|
+
See Also:
|
|
1825
|
+
:meth:`xx_plus_yy`
|
|
1826
|
+
"""
|
|
1827
|
+
|
|
1828
|
+
def gphase(self, theta: float) -> None:
|
|
1829
|
+
r"""Apply a global phase gate.
|
|
1830
|
+
|
|
1831
|
+
.. math::
|
|
1832
|
+
GPhase(\theta) = (e^{i\theta})
|
|
1833
|
+
|
|
1834
|
+
Args:
|
|
1835
|
+
theta: The rotation angle
|
|
1836
|
+
"""
|
|
1837
|
+
|
|
1838
|
+
@overload
|
|
1839
|
+
def measure(self, qubit: int, cbit: int) -> None:
|
|
1840
|
+
"""Measure a qubit and store the result in a classical bit.
|
|
1841
|
+
|
|
1842
|
+
Args:
|
|
1843
|
+
qubit: The qubit to measure
|
|
1844
|
+
cbit: The classical bit to store the result
|
|
1845
|
+
"""
|
|
1846
|
+
|
|
1847
|
+
@overload
|
|
1848
|
+
def measure(self, qubits: Sequence[int], cbits: Sequence[int]) -> None:
|
|
1849
|
+
"""Measure multiple qubits and store the results in classical bits.
|
|
1850
|
+
|
|
1851
|
+
This method is equivalent to calling :meth:`measure` multiple times.
|
|
1852
|
+
|
|
1853
|
+
Args:
|
|
1854
|
+
qubits: The qubits to measure
|
|
1855
|
+
cbits: The classical bits to store the results
|
|
1856
|
+
"""
|
|
1857
|
+
|
|
1858
|
+
def measure_all(self, *, add_bits: bool = True) -> None:
|
|
1859
|
+
"""Measure all qubits and store the results in classical bits.
|
|
1860
|
+
|
|
1861
|
+
Details:
|
|
1862
|
+
If `add_bits` is `True`, a new classical register (named "`meas`") with
|
|
1863
|
+
the same size as the number of qubits will be added to the circuit
|
|
1864
|
+
and the results will be stored in it. If `add_bits` is `False`, the
|
|
1865
|
+
classical register must already exist and have a sufficient number
|
|
1866
|
+
of bits to store the results.
|
|
1867
|
+
|
|
1868
|
+
Args:
|
|
1869
|
+
add_bits: Whether to explicitly add a classical register
|
|
1870
|
+
"""
|
|
1871
|
+
|
|
1872
|
+
@overload
|
|
1873
|
+
def reset(self, q: int) -> None:
|
|
1874
|
+
"""Add a reset operation to the circuit.
|
|
1875
|
+
|
|
1876
|
+
Args:
|
|
1877
|
+
q: The qubit to reset
|
|
1878
|
+
"""
|
|
1879
|
+
|
|
1880
|
+
@overload
|
|
1881
|
+
def reset(self, qubits: Sequence[int]) -> None:
|
|
1882
|
+
"""Add a reset operation to the circuit.
|
|
1883
|
+
|
|
1884
|
+
Args:
|
|
1885
|
+
qubits: The qubits to reset
|
|
1886
|
+
"""
|
|
1887
|
+
|
|
1888
|
+
@overload
|
|
1889
|
+
def barrier(self) -> None:
|
|
1890
|
+
"""Add a barrier to the circuit."""
|
|
1891
|
+
|
|
1892
|
+
@overload
|
|
1893
|
+
def barrier(self, q: int) -> None:
|
|
1894
|
+
"""Add a barrier to the circuit.
|
|
1895
|
+
|
|
1896
|
+
Args:
|
|
1897
|
+
q: The qubit to add the barrier to
|
|
1898
|
+
"""
|
|
1899
|
+
|
|
1900
|
+
@overload
|
|
1901
|
+
def barrier(self, qubits: Sequence[int]) -> None:
|
|
1902
|
+
"""Add a barrier to the circuit.
|
|
1903
|
+
|
|
1904
|
+
Args:
|
|
1905
|
+
qubits: The qubits to add the barrier to
|
|
1906
|
+
"""
|
|
1907
|
+
|
|
1908
|
+
@overload
|
|
1909
|
+
def if_else(
|
|
1910
|
+
self,
|
|
1911
|
+
then_operation: Operation,
|
|
1912
|
+
else_operation: Operation | None,
|
|
1913
|
+
control_register: ClassicalRegister,
|
|
1914
|
+
expected_value: int = 1,
|
|
1915
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
1916
|
+
) -> None:
|
|
1917
|
+
"""Add an if-else operation to the circuit.
|
|
1918
|
+
|
|
1919
|
+
Args:
|
|
1920
|
+
then_operation: The operation to apply if the condition is met
|
|
1921
|
+
else_operation: The operation to apply if the condition is not met
|
|
1922
|
+
control_register: The classical register to check against
|
|
1923
|
+
expected_value: The expected value of the control register
|
|
1924
|
+
comparison_kind: The kind of comparison to perform
|
|
1925
|
+
"""
|
|
1926
|
+
|
|
1927
|
+
@overload
|
|
1928
|
+
def if_else(
|
|
1929
|
+
self,
|
|
1930
|
+
then_operation: Operation,
|
|
1931
|
+
else_operation: Operation | None,
|
|
1932
|
+
control_bit: int,
|
|
1933
|
+
expected_value: int = 1,
|
|
1934
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
1935
|
+
) -> None:
|
|
1936
|
+
"""Add an if-else operation to the circuit.
|
|
1937
|
+
|
|
1938
|
+
Args:
|
|
1939
|
+
then_operation: The operation to apply if the condition is met
|
|
1940
|
+
else_operation: The operation to apply if the condition is not met
|
|
1941
|
+
control_bit: The index of the classical bit to check against
|
|
1942
|
+
expected_value: The expected value of the control bit
|
|
1943
|
+
comparison_kind: The kind of comparison to perform
|
|
1944
|
+
"""
|
|
1945
|
+
|
|
1946
|
+
@overload
|
|
1947
|
+
def if_(
|
|
1948
|
+
self,
|
|
1949
|
+
op_type: OpType,
|
|
1950
|
+
target: int,
|
|
1951
|
+
control_register: ClassicalRegister,
|
|
1952
|
+
expected_value: int = 1,
|
|
1953
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
1954
|
+
params: Sequence[float] = (),
|
|
1955
|
+
) -> None:
|
|
1956
|
+
"""Add an if operartion to the circuit.
|
|
1957
|
+
|
|
1958
|
+
Args:
|
|
1959
|
+
op_type: The operation to apply
|
|
1960
|
+
target: The target qubit
|
|
1961
|
+
control_register: The classical register to check against
|
|
1962
|
+
expected_value: The expected value of the control register
|
|
1963
|
+
comparison_kind: The kind of comparison to perform
|
|
1964
|
+
params: The parameters of the operation
|
|
1965
|
+
"""
|
|
1966
|
+
|
|
1967
|
+
@overload
|
|
1968
|
+
def if_(
|
|
1969
|
+
self,
|
|
1970
|
+
op_type: OpType,
|
|
1971
|
+
target: int,
|
|
1972
|
+
control: Control | int,
|
|
1973
|
+
control_register: ClassicalRegister,
|
|
1974
|
+
expected_value: int = 1,
|
|
1975
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
1976
|
+
params: Sequence[float] = (),
|
|
1977
|
+
) -> None:
|
|
1978
|
+
"""Add a classic-controlled operation to the circuit.
|
|
1979
|
+
|
|
1980
|
+
Args:
|
|
1981
|
+
op_type: The operation to apply
|
|
1982
|
+
target: The target qubit
|
|
1983
|
+
control: The control qubit
|
|
1984
|
+
control_register: The classical register to check against
|
|
1985
|
+
expected_value: The expected value of the control register
|
|
1986
|
+
comparison_kind: The kind of comparison to perform
|
|
1987
|
+
params: The parameters of the operation.
|
|
1988
|
+
"""
|
|
1989
|
+
|
|
1990
|
+
@overload
|
|
1991
|
+
def if_(
|
|
1992
|
+
self,
|
|
1993
|
+
op_type: OpType,
|
|
1994
|
+
target: int,
|
|
1995
|
+
controls: set[Control | int],
|
|
1996
|
+
control_register: ClassicalRegister,
|
|
1997
|
+
expected_value: int = 1,
|
|
1998
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
1999
|
+
params: Sequence[float] = (),
|
|
2000
|
+
) -> None:
|
|
2001
|
+
"""Add a classic-controlled operation to the circuit.
|
|
2002
|
+
|
|
2003
|
+
Args:
|
|
2004
|
+
op_type: The operation to apply
|
|
2005
|
+
target: The target qubit
|
|
2006
|
+
controls: The control qubits
|
|
2007
|
+
control_register: The classical register to check against
|
|
2008
|
+
expected_value: The expected value of the control register
|
|
2009
|
+
comparison_kind: The kind of comparison to perform
|
|
2010
|
+
params: The parameters of the operation.
|
|
2011
|
+
"""
|
|
2012
|
+
|
|
2013
|
+
@overload
|
|
2014
|
+
def if_(
|
|
2015
|
+
self,
|
|
2016
|
+
op_type: OpType,
|
|
2017
|
+
target: int,
|
|
2018
|
+
control_bit: int,
|
|
2019
|
+
expected_value: bool = True,
|
|
2020
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
2021
|
+
params: Sequence[float] = (),
|
|
2022
|
+
) -> None:
|
|
2023
|
+
"""Add a classic-controlled operation to the circuit.
|
|
2024
|
+
|
|
2025
|
+
Args:
|
|
2026
|
+
op_type: The operation to apply
|
|
2027
|
+
target: The target qubit
|
|
2028
|
+
control_bit: The index of the classical bit to check against
|
|
2029
|
+
expected_value: The expected value of the control bit
|
|
2030
|
+
comparison_kind: The kind of comparison to perform
|
|
2031
|
+
params: The parameters of the operation.
|
|
2032
|
+
"""
|
|
2033
|
+
|
|
2034
|
+
@overload
|
|
2035
|
+
def if_(
|
|
2036
|
+
self,
|
|
2037
|
+
op_type: OpType,
|
|
2038
|
+
target: int,
|
|
2039
|
+
control: Control | int,
|
|
2040
|
+
control_bit: int,
|
|
2041
|
+
expected_value: bool = True,
|
|
2042
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
2043
|
+
params: Sequence[float] = (),
|
|
2044
|
+
) -> None:
|
|
2045
|
+
"""Add a classic-controlled operation to the circuit.
|
|
2046
|
+
|
|
2047
|
+
Args:
|
|
2048
|
+
op_type: The operation to apply
|
|
2049
|
+
target: The target qubit
|
|
2050
|
+
control: The control qubit
|
|
2051
|
+
control_bit: The index of the classical bit to check against
|
|
2052
|
+
expected_value: The expected value of the control bit
|
|
2053
|
+
comparison_kind: The kind of comparison to perform
|
|
2054
|
+
params: The parameters of the operation.
|
|
2055
|
+
"""
|
|
2056
|
+
|
|
2057
|
+
@overload
|
|
2058
|
+
def if_(
|
|
2059
|
+
self,
|
|
2060
|
+
op_type: OpType,
|
|
2061
|
+
target: int,
|
|
2062
|
+
controls: set[Control | int],
|
|
2063
|
+
control_bit: int,
|
|
2064
|
+
expected_value: bool = True,
|
|
2065
|
+
comparison_kind: ComparisonKind = ComparisonKind.eq,
|
|
2066
|
+
params: Sequence[float] = (),
|
|
2067
|
+
) -> None:
|
|
2068
|
+
"""Add a classic-controlled operation to the circuit.
|
|
2069
|
+
|
|
2070
|
+
Args:
|
|
2071
|
+
op_type: The operation to apply
|
|
2072
|
+
target: The target qubit
|
|
2073
|
+
controls: The control qubits
|
|
2074
|
+
control_bit: The index of the classical bit to check against
|
|
2075
|
+
expected_value: The expected value of the control bit
|
|
2076
|
+
comparison_kind: The kind of comparison to perform
|
|
2077
|
+
params: The parameters of the operation.
|
|
2078
|
+
"""
|