classiq 0.53.0__py3-none-any.whl → 0.54.0__py3-none-any.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.
- classiq/__init__.py +1 -3
- classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
- classiq/_internals/__init__.py +0 -20
- classiq/_internals/api_wrapper.py +8 -8
- classiq/_internals/async_utils.py +1 -3
- classiq/_internals/authentication/auth0.py +5 -5
- classiq/_internals/authentication/device.py +5 -4
- classiq/_internals/authentication/password_manager.py +3 -3
- classiq/_internals/authentication/token_manager.py +3 -2
- classiq/_internals/client.py +10 -12
- classiq/_internals/config.py +2 -2
- classiq/_internals/jobs.py +7 -6
- classiq/_internals/type_validation.py +9 -9
- classiq/analyzer/__init__.py +1 -3
- classiq/analyzer/analyzer.py +8 -7
- classiq/analyzer/analyzer_utilities.py +8 -8
- classiq/analyzer/rb.py +11 -11
- classiq/applications/__init__.py +1 -3
- classiq/applications/chemistry/__init__.py +1 -3
- classiq/applications/chemistry/ansatz_parameters.py +4 -4
- classiq/applications/chemistry/chemistry_model_constructor.py +10 -9
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +26 -9
- classiq/applications/combinatorial_helpers/encoding_mapping.py +10 -10
- classiq/applications/combinatorial_helpers/encoding_utils.py +4 -4
- classiq/applications/combinatorial_helpers/memory.py +5 -7
- classiq/applications/combinatorial_helpers/optimization_model.py +43 -24
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +4 -6
- classiq/applications/combinatorial_helpers/pyomo_utils.py +95 -24
- classiq/applications/combinatorial_helpers/sympy_utils.py +2 -2
- classiq/applications/combinatorial_helpers/transformations/encoding.py +8 -8
- classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -5
- classiq/applications/combinatorial_helpers/transformations/ising_converter.py +7 -9
- classiq/applications/combinatorial_helpers/transformations/penalty.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -2
- classiq/applications/combinatorial_helpers/transformations/slack_variables.py +1 -2
- classiq/applications/combinatorial_optimization/__init__.py +1 -3
- classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
- classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
- classiq/applications/finance/__init__.py +1 -3
- classiq/applications/grover/__init__.py +1 -3
- classiq/applications/grover/grover_model_constructor.py +7 -9
- classiq/applications/hamiltonian/pauli_decomposition.py +6 -6
- classiq/applications/qnn/__init__.py +1 -3
- classiq/applications/qnn/circuit_utils.py +5 -5
- classiq/applications/qnn/datasets/__init__.py +1 -3
- classiq/applications/qnn/datasets/dataset_base_classes.py +5 -4
- classiq/applications/qnn/datasets/dataset_parity.py +2 -2
- classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
- classiq/applications/qnn/qlayer.py +3 -3
- classiq/applications/qnn/torch_utils.py +2 -2
- classiq/applications/qnn/types.py +5 -5
- classiq/applications/qsvm/qsvm.py +1 -3
- classiq/applications/qsvm/qsvm_data_generation.py +3 -3
- classiq/applications/qsvm/qsvm_model_constructor.py +5 -5
- classiq/execution/__init__.py +1 -3
- classiq/execution/all_hardware_devices.py +1 -3
- classiq/execution/execution_session.py +16 -16
- classiq/execution/jobs.py +4 -4
- classiq/execution/qaoa.py +3 -3
- classiq/execution/qnn.py +3 -3
- classiq/executor.py +3 -3
- classiq/interface/_version.py +1 -1
- classiq/interface/analyzer/analysis_params.py +9 -10
- classiq/interface/analyzer/cytoscape_graph.py +5 -5
- classiq/interface/analyzer/result.py +17 -17
- classiq/interface/applications/qsvm.py +6 -10
- classiq/interface/backend/backend_preferences.py +4 -3
- classiq/interface/backend/ionq/ionq_quantum_program.py +4 -5
- classiq/interface/backend/pydantic_backend.py +1 -2
- classiq/interface/chemistry/fermionic_operator.py +5 -5
- classiq/interface/chemistry/ground_state_problem.py +7 -8
- classiq/interface/chemistry/molecule.py +4 -4
- classiq/interface/chemistry/operator.py +11 -13
- classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -3
- classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
- classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
- classiq/interface/combinatorial_optimization/examples/mht.py +2 -3
- classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
- classiq/interface/combinatorial_optimization/examples/set_cover.py +1 -2
- classiq/interface/combinatorial_optimization/mht_qaoa_input.py +5 -7
- classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
- classiq/interface/combinatorial_optimization/result.py +1 -3
- classiq/interface/debug_info/debug_info.py +8 -7
- classiq/interface/exceptions.py +8 -6
- classiq/interface/execution/jobs.py +2 -2
- classiq/interface/execution/primitives.py +3 -3
- classiq/interface/executor/aws_execution_cost.py +4 -4
- classiq/interface/executor/execution_request.py +2 -3
- classiq/interface/executor/execution_result.py +3 -3
- classiq/interface/executor/iqae_result.py +3 -5
- classiq/interface/executor/optimizer_preferences.py +2 -2
- classiq/interface/executor/quantum_code.py +6 -6
- classiq/interface/executor/register_initialization.py +2 -4
- classiq/interface/executor/result.py +23 -27
- classiq/interface/executor/vqe_result.py +8 -8
- classiq/interface/finance/function_input.py +2 -2
- classiq/interface/finance/gaussian_model_input.py +5 -5
- classiq/interface/finance/log_normal_model_input.py +2 -2
- classiq/interface/finance/model_input.py +1 -2
- classiq/interface/generator/adjacency.py +1 -3
- classiq/interface/generator/ansatz_library.py +4 -4
- classiq/interface/generator/application_apis/finance_declarations.py +1 -1
- classiq/interface/generator/arith/argument_utils.py +3 -3
- classiq/interface/generator/arith/arithmetic.py +7 -7
- classiq/interface/generator/arith/arithmetic_arg_type_validator.py +5 -5
- classiq/interface/generator/arith/arithmetic_expression_abc.py +11 -11
- classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
- classiq/interface/generator/arith/arithmetic_expression_validator.py +8 -8
- classiq/interface/generator/arith/arithmetic_operations.py +4 -3
- classiq/interface/generator/arith/arithmetic_param_getters.py +6 -6
- classiq/interface/generator/arith/arithmetic_result_builder.py +9 -9
- classiq/interface/generator/arith/ast_node_rewrite.py +2 -1
- classiq/interface/generator/arith/binary_ops.py +10 -13
- classiq/interface/generator/arith/extremum_operations.py +3 -2
- classiq/interface/generator/arith/logical_ops.py +7 -6
- classiq/interface/generator/arith/number_utils.py +4 -4
- classiq/interface/generator/arith/register_user_input.py +4 -4
- classiq/interface/generator/arith/unary_ops.py +2 -1
- classiq/interface/generator/builtin_api_builder.py +2 -1
- classiq/interface/generator/circuit_code/circuit_code.py +4 -4
- classiq/interface/generator/circuit_code/types_and_constants.py +3 -5
- classiq/interface/generator/complex_type.py +1 -2
- classiq/interface/generator/control_state.py +2 -2
- classiq/interface/generator/custom_ansatz.py +1 -3
- classiq/interface/generator/distance.py +3 -5
- classiq/interface/generator/excitations.py +3 -2
- classiq/interface/generator/expressions/enums/finance_functions.py +1 -3
- classiq/interface/generator/expressions/evaluated_expression.py +4 -3
- classiq/interface/generator/expressions/expression.py +4 -5
- classiq/interface/generator/expressions/expression_constants.py +4 -4
- classiq/interface/generator/expressions/qmod_qarray_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_qstruct_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -1
- classiq/interface/generator/expressions/qmod_struct_instance.py +2 -1
- classiq/interface/generator/expressions/sympy_supported_expressions.py +11 -13
- classiq/interface/generator/finance.py +2 -2
- classiq/interface/generator/function_param_library.py +6 -6
- classiq/interface/generator/function_params.py +13 -19
- classiq/interface/generator/functions/classical_function_declaration.py +4 -3
- classiq/interface/generator/functions/classical_type.py +13 -13
- classiq/interface/generator/functions/concrete_types.py +1 -2
- classiq/interface/generator/functions/function_declaration.py +1 -1
- classiq/interface/generator/functions/qmod_python_interface.py +2 -1
- classiq/interface/generator/functions/type_name.py +3 -2
- classiq/interface/generator/generated_circuit_data.py +34 -22
- classiq/interface/generator/grover_diffuser.py +7 -7
- classiq/interface/generator/grover_operator.py +2 -2
- classiq/interface/generator/hardware/hardware_data.py +7 -6
- classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
- classiq/interface/generator/identity.py +5 -6
- classiq/interface/generator/linear_pauli_rotations.py +6 -6
- classiq/interface/generator/mcu.py +2 -2
- classiq/interface/generator/mcx.py +6 -6
- classiq/interface/generator/model/__init__.py +1 -3
- classiq/interface/generator/model/constraints.py +2 -2
- classiq/interface/generator/model/model.py +5 -6
- classiq/interface/generator/model/preferences/preferences.py +7 -6
- classiq/interface/generator/model/quantum_register.py +6 -11
- classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
- classiq/interface/generator/oracles/custom_oracle.py +2 -2
- classiq/interface/generator/oracles/oracle_abc.py +6 -5
- classiq/interface/generator/partitioned_register.py +6 -5
- classiq/interface/generator/piecewise_linear_amplitude_loading.py +8 -7
- classiq/interface/generator/qpe.py +4 -4
- classiq/interface/generator/qsvm.py +3 -3
- classiq/interface/generator/quantum_function_call.py +24 -29
- classiq/interface/generator/quantum_program.py +9 -9
- classiq/interface/generator/register_role.py +2 -4
- classiq/interface/generator/slice_parsing_utils.py +4 -3
- classiq/interface/generator/standard_gates/standard_gates.py +3 -3
- classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
- classiq/interface/generator/state_preparation/distributions.py +6 -5
- classiq/interface/generator/state_preparation/metrics.py +2 -4
- classiq/interface/generator/state_preparation/state_preparation.py +4 -4
- classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +3 -3
- classiq/interface/generator/transpiler_basis_gates.py +2 -2
- classiq/interface/generator/types/enum_declaration.py +2 -3
- classiq/interface/generator/types/qstruct_declaration.py +2 -1
- classiq/interface/generator/types/struct_declaration.py +3 -2
- classiq/interface/generator/ucc.py +2 -1
- classiq/interface/generator/unitary_gate.py +2 -2
- classiq/interface/generator/user_defined_function_params.py +1 -1
- classiq/interface/generator/validations/flow_graph.py +6 -5
- classiq/interface/generator/validations/validator_functions.py +3 -2
- classiq/interface/generator/visitor.py +9 -14
- classiq/interface/hardware.py +5 -6
- classiq/interface/helpers/custom_encoders.py +2 -2
- classiq/interface/helpers/custom_pydantic_types.py +8 -9
- classiq/interface/helpers/hashable_mixin.py +3 -2
- classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
- classiq/interface/helpers/pydantic_model_helpers.py +4 -3
- classiq/interface/helpers/validation_helpers.py +2 -2
- classiq/interface/ide/ide_data.py +11 -15
- classiq/interface/ide/visual_model.py +20 -22
- classiq/interface/jobs.py +2 -2
- classiq/interface/model/bind_operation.py +5 -4
- classiq/interface/model/classical_parameter_declaration.py +2 -2
- classiq/interface/model/handle_binding.py +3 -2
- classiq/interface/model/inplace_binary_operation.py +2 -1
- classiq/interface/model/model.py +12 -11
- classiq/interface/model/port_declaration.py +2 -2
- classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +3 -2
- classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -2
- classiq/interface/model/quantum_expressions/quantum_expression.py +8 -7
- classiq/interface/model/quantum_function_call.py +9 -14
- classiq/interface/model/quantum_function_declaration.py +10 -12
- classiq/interface/model/quantum_lambda_function.py +3 -16
- classiq/interface/model/quantum_statement.py +4 -3
- classiq/interface/model/quantum_type.py +5 -5
- classiq/interface/model/statement_block.py +2 -3
- classiq/interface/model/validation_handle.py +5 -4
- classiq/interface/server/global_versions.py +3 -3
- classiq/model_expansions/atomic_expression_functions_defs.py +3 -2
- classiq/model_expansions/call_to_model_converter.py +190 -0
- classiq/model_expansions/capturing/captured_var_manager.py +4 -6
- classiq/model_expansions/capturing/propagated_var_stack.py +7 -7
- classiq/model_expansions/closure.py +17 -9
- classiq/model_expansions/evaluators/arg_type_match.py +3 -2
- classiq/model_expansions/evaluators/argument_types.py +3 -3
- classiq/model_expansions/evaluators/control.py +3 -3
- classiq/model_expansions/evaluators/parameter_types.py +7 -7
- classiq/model_expansions/evaluators/quantum_type_utils.py +2 -1
- classiq/model_expansions/evaluators/type_type_match.py +1 -1
- classiq/model_expansions/expression_evaluator.py +10 -9
- classiq/model_expansions/expression_renamer.py +6 -6
- classiq/model_expansions/function_builder.py +19 -12
- classiq/model_expansions/generative_functions.py +3 -2
- classiq/model_expansions/interpreter.py +31 -19
- classiq/model_expansions/model_tables.py +14 -14
- classiq/model_expansions/quantum_operations/bind.py +2 -4
- classiq/model_expansions/quantum_operations/classicalif.py +1 -1
- classiq/model_expansions/quantum_operations/control.py +2 -4
- classiq/model_expansions/quantum_operations/emitter.py +10 -13
- classiq/model_expansions/quantum_operations/expression_operation.py +23 -16
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py +160 -35
- classiq/model_expansions/quantum_operations/phase.py +6 -6
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +25 -5
- classiq/model_expansions/quantum_operations/quantum_function_call.py +41 -2
- classiq/model_expansions/quantum_operations/repeat.py +1 -3
- classiq/model_expansions/scope.py +11 -10
- classiq/model_expansions/scope_initialization.py +6 -5
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +6 -6
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +2 -2
- classiq/model_expansions/visitors/variable_references.py +5 -4
- classiq/qmod/builtins/classical_execution_primitives.py +9 -9
- classiq/qmod/builtins/functions/__init__.py +72 -55
- classiq/qmod/builtins/functions/amplitude_estimation.py +4 -1
- classiq/qmod/builtins/functions/arithmetic.py +14 -1
- classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +86 -6
- classiq/qmod/builtins/functions/grover.py +41 -45
- classiq/qmod/builtins/functions/hea.py +60 -4
- classiq/qmod/builtins/functions/linear_pauli_rotation.py +26 -4
- classiq/qmod/builtins/functions/modular_exponentiation.py +90 -29
- classiq/qmod/builtins/functions/operators.py +1 -1
- classiq/qmod/builtins/functions/qaoa_penalty.py +14 -5
- classiq/qmod/builtins/functions/qft_functions.py +57 -0
- classiq/qmod/builtins/functions/qpe.py +20 -4
- classiq/qmod/builtins/functions/qsvt.py +49 -4
- classiq/qmod/builtins/functions/standard_gates.py +4 -4
- classiq/qmod/builtins/functions/state_preparation.py +92 -10
- classiq/qmod/builtins/functions/swap_test.py +7 -1
- classiq/qmod/builtins/functions/utility_functions.py +43 -0
- classiq/qmod/builtins/functions/variational.py +18 -2
- classiq/qmod/builtins/operations.py +4 -5
- classiq/qmod/cfunc.py +2 -2
- classiq/qmod/classical_function.py +3 -7
- classiq/qmod/create_model_function.py +7 -6
- classiq/qmod/declaration_inferrer.py +7 -10
- classiq/qmod/expression_query.py +3 -3
- classiq/qmod/generative.py +2 -1
- classiq/qmod/model_state_container.py +5 -7
- classiq/qmod/native/__init__.py +1 -3
- classiq/qmod/native/expression_to_qmod.py +9 -8
- classiq/qmod/native/pretty_printer.py +6 -5
- classiq/qmod/pretty_print/__init__.py +1 -3
- classiq/qmod/pretty_print/expression_to_python.py +13 -12
- classiq/qmod/pretty_print/pretty_printer.py +13 -12
- classiq/qmod/python_classical_type.py +8 -4
- classiq/qmod/qfunc.py +4 -4
- classiq/qmod/qmod_variable.py +11 -10
- classiq/qmod/quantum_expandable.py +12 -15
- classiq/qmod/quantum_function.py +10 -3
- classiq/qmod/semantics/annotation.py +1 -1
- classiq/qmod/semantics/error_manager.py +8 -7
- classiq/qmod/semantics/static_semantics_visitor.py +19 -24
- classiq/qmod/semantics/validation/constants_validation.py +1 -1
- classiq/qmod/semantics/validation/func_call_validation.py +2 -2
- classiq/qmod/semantics/validation/main_validation.py +33 -0
- classiq/qmod/semantics/validation/types_validation.py +2 -1
- classiq/qmod/symbolic.py +5 -8
- classiq/qmod/symbolic_type.py +2 -2
- {classiq-0.53.0.dist-info → classiq-0.54.0.dist-info}/METADATA +1 -1
- {classiq-0.53.0.dist-info → classiq-0.54.0.dist-info}/RECORD +295 -292
- classiq/qmod/builtins/functions/qft.py +0 -23
- {classiq-0.53.0.dist-info → classiq-0.54.0.dist-info}/WHEEL +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import
|
1
|
+
from typing import Final, Optional, Union
|
2
2
|
|
3
3
|
from classiq.interface.exceptions import ClassiqError
|
4
4
|
from classiq.interface.executor.execution_preferences import QaeWithQpeEstimationMethod
|
@@ -15,7 +15,7 @@ from classiq.interface.generator.functions.qmod_python_interface import QmodPySt
|
|
15
15
|
from classiq.applications.qsvm.qsvm import Data, Labels
|
16
16
|
from classiq.qmod.builtins.enums import Optimizer
|
17
17
|
|
18
|
-
ExecutionParams =
|
18
|
+
ExecutionParams = dict[str, Union[float, int, list[int], list[float]]]
|
19
19
|
|
20
20
|
_CALL_IN_QFUNC_ERROR = (
|
21
21
|
'Cannot call "{}" in a quantum context. "{}" is a classical execution primitive.'
|
@@ -39,28 +39,28 @@ def sample( # type: ignore[return]
|
|
39
39
|
|
40
40
|
|
41
41
|
def batch_sample( # type: ignore[return]
|
42
|
-
batch_execution_params:
|
42
|
+
batch_execution_params: list[ExecutionParams],
|
43
43
|
) -> MultipleExecutionDetails:
|
44
44
|
_raise_error("batch_sample")
|
45
45
|
|
46
46
|
|
47
47
|
def estimate( # type: ignore[return]
|
48
|
-
hamiltonian:
|
48
|
+
hamiltonian: list[QmodPyStruct], execution_params: Optional[ExecutionParams] = None
|
49
49
|
) -> EstimationResult:
|
50
50
|
_raise_error("estimate")
|
51
51
|
|
52
52
|
|
53
53
|
def batch_estimate( # type: ignore[return]
|
54
|
-
hamiltonian:
|
55
|
-
batch_execution_params:
|
54
|
+
hamiltonian: list[QmodPyStruct],
|
55
|
+
batch_execution_params: list[ExecutionParams],
|
56
56
|
) -> EstimationResults:
|
57
57
|
_raise_error("batch_estimate")
|
58
58
|
|
59
59
|
|
60
60
|
def vqe( # type: ignore[return]
|
61
|
-
hamiltonian:
|
61
|
+
hamiltonian: list[QmodPyStruct],
|
62
62
|
maximize: bool,
|
63
|
-
initial_point:
|
63
|
+
initial_point: list[float],
|
64
64
|
optimizer: Optimizer,
|
65
65
|
max_iteration: int,
|
66
66
|
tolerance: float,
|
@@ -118,5 +118,5 @@ __all__ = [
|
|
118
118
|
]
|
119
119
|
|
120
120
|
|
121
|
-
def __dir__() ->
|
121
|
+
def __dir__() -> list[str]:
|
122
122
|
return __all__
|
@@ -1,3 +1,6 @@
|
|
1
|
+
from classiq.interface.model.native_function_definition import NativeFunctionDefinition
|
2
|
+
|
3
|
+
from ...quantum_function import GenerativeQFunc
|
1
4
|
from .amplitude_estimation import *
|
2
5
|
from .arithmetic import *
|
3
6
|
from .benchmarking import *
|
@@ -14,7 +17,7 @@ from .modular_exponentiation import *
|
|
14
17
|
from .modular_exponentiation import _check_msb, _ctrl_x
|
15
18
|
from .operators import *
|
16
19
|
from .qaoa_penalty import *
|
17
|
-
from .
|
20
|
+
from .qft_functions import *
|
18
21
|
from .qpe import *
|
19
22
|
from .qsvm import *
|
20
23
|
from .qsvt import *
|
@@ -22,6 +25,7 @@ from .standard_gates import *
|
|
22
25
|
from .state_preparation import *
|
23
26
|
from .state_preparation import _prepare_uniform_trimmed_state_step
|
24
27
|
from .swap_test import *
|
28
|
+
from .utility_functions import *
|
25
29
|
from .variational import *
|
26
30
|
|
27
31
|
CORE_LIB_DECLS = [
|
@@ -86,62 +90,75 @@ CORE_LIB_DECLS = [
|
|
86
90
|
)
|
87
91
|
]
|
88
92
|
|
93
|
+
OPEN_LIBRARY_UNPROCESSED_FUNCTIONS = [
|
94
|
+
qpe_flexible,
|
95
|
+
qpe,
|
96
|
+
_single_pauli,
|
97
|
+
linear_pauli_rotations,
|
98
|
+
amplitude_estimation,
|
99
|
+
phase_oracle,
|
100
|
+
reflect_about_zero,
|
101
|
+
grover_diffuser,
|
102
|
+
grover_operator,
|
103
|
+
grover_search,
|
104
|
+
hadamard_transform,
|
105
|
+
apply_to_all,
|
106
|
+
qft_no_swap,
|
107
|
+
qft_space_add_const,
|
108
|
+
cc_modular_add,
|
109
|
+
c_modular_multiply,
|
110
|
+
multiswap,
|
111
|
+
inplace_c_modular_multiply,
|
112
|
+
modular_exp,
|
113
|
+
qsvt_step,
|
114
|
+
qsvt,
|
115
|
+
projector_controlled_phase,
|
116
|
+
qsvt_inversion,
|
117
|
+
allocate_num,
|
118
|
+
qaoa_mixer_layer,
|
119
|
+
qaoa_cost_layer,
|
120
|
+
qaoa_layer,
|
121
|
+
qaoa_init,
|
122
|
+
qaoa_penalty,
|
123
|
+
full_hea,
|
124
|
+
swap_test,
|
125
|
+
prepare_uniform_trimmed_state,
|
126
|
+
prepare_uniform_interval_state,
|
127
|
+
prepare_ghz_state,
|
128
|
+
prepare_exponential_state,
|
129
|
+
prepare_bell_state,
|
130
|
+
inplace_prepare_int,
|
131
|
+
prepare_int,
|
132
|
+
switch,
|
133
|
+
qct_qst_type1,
|
134
|
+
qct_qst_type2,
|
135
|
+
qct_type2,
|
136
|
+
qst_type2,
|
137
|
+
modular_increment,
|
138
|
+
qft,
|
139
|
+
_ctrl_x,
|
140
|
+
_prepare_uniform_trimmed_state_step,
|
141
|
+
_qct_d_operator,
|
142
|
+
_qct_pi_operator,
|
143
|
+
_check_msb,
|
144
|
+
encode_in_angle,
|
145
|
+
encode_on_bloch,
|
146
|
+
]
|
147
|
+
|
148
|
+
OPEN_LIBRARY_FUNCTIONS: list[NativeFunctionDefinition] = []
|
149
|
+
|
150
|
+
|
151
|
+
def load_open_library_implementations() -> None:
|
152
|
+
OPEN_LIBRARY_FUNCTIONS.extend(
|
153
|
+
[func.get_implementation() for func in OPEN_LIBRARY_UNPROCESSED_FUNCTIONS]
|
154
|
+
)
|
155
|
+
|
156
|
+
|
157
|
+
OPEN_LIBRARY_GENERATIVE_FUNCTIONS: list[GenerativeQFunc] = []
|
158
|
+
|
89
159
|
OPEN_LIB_DECLS = [
|
90
160
|
func.func_decl
|
91
|
-
for func in
|
92
|
-
qpe_flexible,
|
93
|
-
qpe,
|
94
|
-
_single_pauli,
|
95
|
-
linear_pauli_rotations,
|
96
|
-
amplitude_estimation,
|
97
|
-
phase_oracle,
|
98
|
-
reflect_about_zero,
|
99
|
-
grover_diffuser,
|
100
|
-
grover_operator,
|
101
|
-
grover_search,
|
102
|
-
hadamard_transform,
|
103
|
-
apply_to_all,
|
104
|
-
qft_no_swap,
|
105
|
-
qft_space_add_const,
|
106
|
-
cc_modular_add,
|
107
|
-
c_modular_multiply,
|
108
|
-
multiswap,
|
109
|
-
inplace_c_modular_multiply,
|
110
|
-
modular_exp,
|
111
|
-
qsvt_step,
|
112
|
-
qsvt,
|
113
|
-
projector_controlled_phase,
|
114
|
-
qsvt_inversion,
|
115
|
-
allocate_num,
|
116
|
-
qaoa_mixer_layer,
|
117
|
-
qaoa_cost_layer,
|
118
|
-
qaoa_layer,
|
119
|
-
qaoa_init,
|
120
|
-
qaoa_penalty,
|
121
|
-
full_hea,
|
122
|
-
swap_test,
|
123
|
-
prepare_uniform_trimmed_state,
|
124
|
-
prepare_uniform_interval_state,
|
125
|
-
prepare_ghz_state,
|
126
|
-
prepare_exponential_state,
|
127
|
-
prepare_bell_state,
|
128
|
-
inplace_prepare_int,
|
129
|
-
prepare_int,
|
130
|
-
switch,
|
131
|
-
qct_qst_type1,
|
132
|
-
qct_qst_type2,
|
133
|
-
qct_type2,
|
134
|
-
qst_type2,
|
135
|
-
modular_increment,
|
136
|
-
qft,
|
137
|
-
_ctrl_x,
|
138
|
-
_prepare_uniform_trimmed_state_step,
|
139
|
-
_qct_d_operator,
|
140
|
-
_qct_pi_operator,
|
141
|
-
_check_msb,
|
142
|
-
encode_in_angle,
|
143
|
-
encode_on_bloch,
|
144
|
-
)
|
161
|
+
for func in OPEN_LIBRARY_GENERATIVE_FUNCTIONS + OPEN_LIBRARY_UNPROCESSED_FUNCTIONS
|
145
162
|
]
|
146
163
|
|
147
164
|
STD_QMOD_OPERATORS = [func.func_decl for func in (apply, permute)]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
from classiq.qmod.builtins.functions.grover import grover_operator
|
2
|
+
from classiq.qmod.builtins.functions.qpe import qpe
|
1
3
|
from classiq.qmod.qfunc import qfunc
|
2
4
|
from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
3
5
|
from classiq.qmod.quantum_callable import QCallable
|
@@ -24,4 +26,5 @@ def amplitude_estimation(
|
|
24
26
|
phase: Assuming this variable starts from the zero state -this variable output holds the $phase=\\theta$ result in the [0,1] domain, which relates to the estimated probability $a$ through $a=\\sin^2(\\pi \\theta)$.
|
25
27
|
packed_vars: The variable that holds the state to be estimated. Assumed to be in the zero state at the beginning of the algorithm.
|
26
28
|
"""
|
27
|
-
|
29
|
+
space_transform(packed_vars)
|
30
|
+
qpe(lambda: grover_operator(oracle, space_transform, packed_vars), phase)
|
@@ -1,9 +1,13 @@
|
|
1
1
|
from typing import Literal
|
2
2
|
|
3
|
+
from classiq.qmod.builtins.functions.qft_functions import qft
|
4
|
+
from classiq.qmod.builtins.functions.standard_gates import PHASE
|
5
|
+
from classiq.qmod.builtins.operations import bind, repeat, within_apply
|
3
6
|
from classiq.qmod.cparam import CInt
|
4
7
|
from classiq.qmod.qfunc import qfunc
|
5
8
|
from classiq.qmod.qmod_parameter import CArray, CReal
|
6
9
|
from classiq.qmod.qmod_variable import Output, QArray, QBit, QNum
|
10
|
+
from classiq.qmod.symbolic import pi
|
7
11
|
|
8
12
|
|
9
13
|
@qfunc(external=True)
|
@@ -75,4 +79,13 @@ def modular_increment(a: CInt, x: QNum) -> None:
|
|
75
79
|
x: A quantum number that is assumed to be non-negative integer.
|
76
80
|
|
77
81
|
"""
|
78
|
-
|
82
|
+
array_cast: QArray = QArray("array_cast")
|
83
|
+
within_apply(
|
84
|
+
lambda: ( # type:ignore[arg-type]
|
85
|
+
bind(x, array_cast), # type:ignore[func-returns-value]
|
86
|
+
qft(array_cast),
|
87
|
+
),
|
88
|
+
lambda: repeat(
|
89
|
+
x.size, lambda i: PHASE(a * 2 * pi * 2**i / (2**x.size), array_cast[i])
|
90
|
+
),
|
91
|
+
)
|
@@ -1,15 +1,85 @@
|
|
1
|
+
from classiq.qmod.builtins.functions.arithmetic import modular_increment
|
2
|
+
from classiq.qmod.builtins.functions.qft_functions import qft
|
3
|
+
from classiq.qmod.builtins.functions.standard_gates import PHASE, H, S, X, Z
|
4
|
+
from classiq.qmod.builtins.functions.state_preparation import allocate
|
5
|
+
from classiq.qmod.builtins.functions.utility_functions import apply_to_all
|
6
|
+
from classiq.qmod.builtins.operations import bind, control, invert, repeat, within_apply
|
1
7
|
from classiq.qmod.qfunc import qfunc
|
2
8
|
from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
9
|
+
from classiq.qmod.symbolic import pi
|
10
|
+
|
11
|
+
|
12
|
+
def _b_operator(q: QBit) -> None:
|
13
|
+
S(q)
|
14
|
+
H(q)
|
3
15
|
|
4
16
|
|
5
17
|
@qfunc(external=True)
|
6
18
|
def _qct_d_operator(x: QNum, q: QBit) -> None:
|
7
|
-
|
19
|
+
_b_operator(q)
|
20
|
+
control(x == 0, lambda: invert(lambda: _b_operator(q)))
|
8
21
|
|
9
22
|
|
10
23
|
@qfunc(external=True)
|
11
24
|
def _qct_pi_operator(x: QArray[QBit], q: QBit) -> None:
|
12
|
-
|
25
|
+
control(q == 1, lambda: apply_to_all(X, x))
|
26
|
+
control(q == 1, lambda: modular_increment(1, x))
|
27
|
+
|
28
|
+
|
29
|
+
def _t_operator(x: QArray) -> None:
|
30
|
+
_qct_d_operator(x[0 : x.len - 1], x[x.len - 1])
|
31
|
+
_qct_pi_operator(x[0 : x.len - 1], x[x.len - 1])
|
32
|
+
|
33
|
+
|
34
|
+
def _vn_operator(x: QArray[QBit], q: QBit) -> None:
|
35
|
+
H(q)
|
36
|
+
control(q == 1, lambda: apply_to_all(X, x))
|
37
|
+
|
38
|
+
|
39
|
+
def _d1_operator(x: QArray[QBit], q: QBit) -> None:
|
40
|
+
omega_exp = 2 * pi / (4 * 2**x.len)
|
41
|
+
|
42
|
+
# Li
|
43
|
+
control(q == 0, lambda: repeat(x.len, lambda k: PHASE(omega_exp * (2**k), x[k])))
|
44
|
+
# Ki
|
45
|
+
control(
|
46
|
+
q == 1,
|
47
|
+
lambda: repeat(
|
48
|
+
x.len,
|
49
|
+
lambda k: within_apply(
|
50
|
+
lambda: X(x[k]), lambda: PHASE(-omega_exp * (2**k), x[k])
|
51
|
+
),
|
52
|
+
),
|
53
|
+
)
|
54
|
+
PHASE(-omega_exp, q)
|
55
|
+
|
56
|
+
|
57
|
+
def _pi2_operator(x: QArray[QBit], q: QBit) -> None:
|
58
|
+
control(q == 1, lambda: modular_increment(1, x))
|
59
|
+
|
60
|
+
|
61
|
+
def _j_operator(q: QBit) -> None:
|
62
|
+
within_apply(lambda: Z(q), lambda: (S(q), H(q), S(q))) # type:ignore[arg-type]
|
63
|
+
|
64
|
+
|
65
|
+
def _b_t_operator(q: QBit) -> None:
|
66
|
+
H(q)
|
67
|
+
S(q)
|
68
|
+
|
69
|
+
|
70
|
+
def _d0dt_operator(x: QArray, q: QBit) -> None:
|
71
|
+
x_num: QNum = QNum("x_num", x.len, False, 0)
|
72
|
+
bind(x, x_num)
|
73
|
+
_b_t_operator(q)
|
74
|
+
control(x_num == 0, lambda: _j_operator(q))
|
75
|
+
bind(x_num, x)
|
76
|
+
|
77
|
+
|
78
|
+
def _un_dag_operator(x: QArray[QBit], q: QBit) -> None:
|
79
|
+
_d1_operator(x, q)
|
80
|
+
invert(lambda: _qct_pi_operator(x, q))
|
81
|
+
_d0dt_operator(x, q)
|
82
|
+
invert(lambda: _pi2_operator(x, q))
|
13
83
|
|
14
84
|
|
15
85
|
@qfunc(external=True)
|
@@ -39,7 +109,7 @@ def qct_qst_type1(x: QArray[QBit]) -> None:
|
|
39
109
|
Links:
|
40
110
|
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
41
111
|
"""
|
42
|
-
|
112
|
+
within_apply(lambda: _t_operator(x), lambda: qft(x))
|
43
113
|
|
44
114
|
|
45
115
|
@qfunc(external=True)
|
@@ -68,7 +138,12 @@ def qct_qst_type2(x: QArray[QBit], q: QBit) -> None:
|
|
68
138
|
Links:
|
69
139
|
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
70
140
|
"""
|
71
|
-
|
141
|
+
extended_state: QArray = QArray("extended_state")
|
142
|
+
_vn_operator(x, q)
|
143
|
+
bind([x, q], extended_state)
|
144
|
+
qft(extended_state)
|
145
|
+
bind(extended_state, [x, q])
|
146
|
+
_un_dag_operator(x, q)
|
72
147
|
|
73
148
|
|
74
149
|
@qfunc(external=True)
|
@@ -85,7 +160,8 @@ def qct_type2(x: QArray[QBit]) -> None:
|
|
85
160
|
Links:
|
86
161
|
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
87
162
|
"""
|
88
|
-
|
163
|
+
q = QBit("q")
|
164
|
+
within_apply(lambda: allocate(1, q), lambda: qct_qst_type2(x, q))
|
89
165
|
|
90
166
|
|
91
167
|
@qfunc(external=True)
|
@@ -102,4 +178,8 @@ def qst_type2(x: QArray[QBit]) -> None:
|
|
102
178
|
Links:
|
103
179
|
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
104
180
|
"""
|
105
|
-
|
181
|
+
q = QBit("q")
|
182
|
+
within_apply(
|
183
|
+
lambda: (allocate(1, q), X(q)), # type:ignore[arg-type]
|
184
|
+
lambda: qct_qst_type2(x, q),
|
185
|
+
)
|
@@ -1,9 +1,18 @@
|
|
1
|
-
from
|
2
|
-
|
1
|
+
from classiq.qmod.builtins.functions.standard_gates import H, U, X
|
2
|
+
from classiq.qmod.builtins.functions.state_preparation import allocate
|
3
|
+
from classiq.qmod.builtins.functions.utility_functions import hadamard_transform
|
4
|
+
from classiq.qmod.builtins.operations import (
|
5
|
+
bind,
|
6
|
+
control,
|
7
|
+
invert,
|
8
|
+
power,
|
9
|
+
within_apply,
|
10
|
+
)
|
3
11
|
from classiq.qmod.qfunc import qfunc
|
4
12
|
from classiq.qmod.qmod_parameter import CInt
|
5
|
-
from classiq.qmod.qmod_variable import QArray, QBit
|
13
|
+
from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
6
14
|
from classiq.qmod.quantum_callable import QCallable
|
15
|
+
from classiq.qmod.symbolic import pi
|
7
16
|
|
8
17
|
|
9
18
|
@qfunc(external=True)
|
@@ -36,7 +45,11 @@ def phase_oracle(
|
|
36
45
|
|
37
46
|
[Hidden shift](https://docs.classiq.io/latest/explore/algorithms/algebraic/hidden_shift/hidden_shift/)
|
38
47
|
"""
|
39
|
-
|
48
|
+
aux = QBit("aux")
|
49
|
+
within_apply(
|
50
|
+
within=lambda: (allocate(1, aux), X(aux), H(aux)), # type:ignore[arg-type]
|
51
|
+
apply=lambda: predicate(target, aux),
|
52
|
+
)
|
40
53
|
|
41
54
|
|
42
55
|
@qfunc(external=True)
|
@@ -56,7 +69,14 @@ def reflect_about_zero(packed_vars: QArray[QBit]) -> None:
|
|
56
69
|
Args:
|
57
70
|
packed_vars: The quantum state to reflect.
|
58
71
|
"""
|
59
|
-
|
72
|
+
msbs: QNum = QNum("msbs", packed_vars.len - 1, False, 0)
|
73
|
+
lsb = QBit("lsb")
|
74
|
+
bind(packed_vars, [msbs, lsb])
|
75
|
+
within_apply(
|
76
|
+
lambda: (X(lsb), H(lsb)), # type:ignore[arg-type]
|
77
|
+
lambda: control(msbs == 0, lambda: X(lsb)),
|
78
|
+
)
|
79
|
+
bind([msbs, lsb], packed_vars)
|
60
80
|
|
61
81
|
|
62
82
|
@qfunc(external=True)
|
@@ -81,7 +101,10 @@ def grover_diffuser(
|
|
81
101
|
space_transform: The operator which encodes the axis of reflection.
|
82
102
|
packed_vars: The state to which to apply the diffuser.
|
83
103
|
"""
|
84
|
-
|
104
|
+
within_apply(
|
105
|
+
lambda: invert(lambda: space_transform(packed_vars)),
|
106
|
+
lambda: reflect_about_zero(packed_vars),
|
107
|
+
)
|
85
108
|
|
86
109
|
|
87
110
|
@qfunc(external=True)
|
@@ -115,7 +138,9 @@ def grover_operator(
|
|
115
138
|
- [Wikipedia page](https://en.wikipedia.org/wiki/Grover%27s_algorithm).
|
116
139
|
|
117
140
|
"""
|
118
|
-
|
141
|
+
oracle(packed_vars)
|
142
|
+
grover_diffuser(lambda qba: space_transform(qba), packed_vars)
|
143
|
+
U(0, 0, 0, pi, packed_vars[0])
|
119
144
|
|
120
145
|
|
121
146
|
@qfunc(external=True)
|
@@ -138,41 +163,12 @@ def grover_search(
|
|
138
163
|
[Grover Algorithm](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/grover_operator/grover_operator/)
|
139
164
|
|
140
165
|
"""
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
Corresponds to the braket notation:
|
152
|
-
|
153
|
-
$$
|
154
|
-
H^{\\otimes n} |x\rangle = \frac{1}{\\sqrt{2^n}} \\sum_{y=0}^{2^n - 1} (-1)^{x \\cdot y} |y\rangle
|
155
|
-
$$
|
156
|
-
|
157
|
-
Args:
|
158
|
-
target: qubits to apply to Hadamard transform to.
|
159
|
-
|
160
|
-
"""
|
161
|
-
pass
|
162
|
-
|
163
|
-
|
164
|
-
@qfunc(external=True)
|
165
|
-
def apply_to_all(
|
166
|
-
gate_operand: QCallable[Annotated[QBit, "target"]], target: QArray[QBit]
|
167
|
-
) -> None:
|
168
|
-
"""
|
169
|
-
[Qmod Classiq-library function]
|
170
|
-
|
171
|
-
Applies the single-qubit operand `gate_operand` to each qubit in the qubit
|
172
|
-
array `target`.
|
173
|
-
|
174
|
-
Args:
|
175
|
-
gate_operand: The single-qubit gate to apply to each qubit in the array.
|
176
|
-
target: The qubit array to apply the gate to.
|
177
|
-
"""
|
178
|
-
pass
|
166
|
+
hadamard_transform(packed_vars)
|
167
|
+
power(
|
168
|
+
reps,
|
169
|
+
lambda: grover_operator(
|
170
|
+
lambda qba: oracle(qba),
|
171
|
+
lambda qba: hadamard_transform(qba),
|
172
|
+
packed_vars,
|
173
|
+
),
|
174
|
+
)
|
@@ -1,11 +1,11 @@
|
|
1
|
-
from typing import Literal
|
2
|
-
|
3
|
-
from typing_extensions import Annotated
|
1
|
+
from typing import Annotated, Literal
|
4
2
|
|
3
|
+
from classiq.qmod.builtins.operations import if_, repeat
|
5
4
|
from classiq.qmod.qfunc import qfunc
|
6
5
|
from classiq.qmod.qmod_parameter import CArray, CInt, CReal
|
7
6
|
from classiq.qmod.qmod_variable import QArray, QBit
|
8
7
|
from classiq.qmod.quantum_callable import QCallableList
|
8
|
+
from classiq.qmod.symbolic import floor, sum
|
9
9
|
|
10
10
|
|
11
11
|
@qfunc(external=True)
|
@@ -56,4 +56,60 @@ def full_hea(
|
|
56
56
|
operands_2qubit: A list of operations on two qubits
|
57
57
|
x: The quantum object to be transformed by the ansatz
|
58
58
|
"""
|
59
|
-
|
59
|
+
repeat(
|
60
|
+
reps,
|
61
|
+
lambda r: [ # type:ignore[arg-type]
|
62
|
+
repeat( # type:ignore[func-returns-value]
|
63
|
+
operands_1qubit.len,
|
64
|
+
lambda i1: repeat(
|
65
|
+
num_qubits,
|
66
|
+
lambda index: if_(
|
67
|
+
condition=is_parametrized[i1] == 1,
|
68
|
+
then=lambda: operands_1qubit[i1](
|
69
|
+
angle_params[
|
70
|
+
sum(is_parametrized[0:i1]) # type:ignore[index]
|
71
|
+
+ floor((angle_params.len / reps) * r)
|
72
|
+
+ index
|
73
|
+
],
|
74
|
+
x[index],
|
75
|
+
),
|
76
|
+
else_=lambda: operands_1qubit[i1](0, x[index]),
|
77
|
+
),
|
78
|
+
),
|
79
|
+
),
|
80
|
+
repeat( # type:ignore[func-returns-value]
|
81
|
+
operands_2qubit.len,
|
82
|
+
lambda i2: repeat(
|
83
|
+
connectivity_map.len,
|
84
|
+
lambda index: if_(
|
85
|
+
condition=is_parametrized[operands_1qubit.len + i2] == 1,
|
86
|
+
then=lambda: operands_2qubit[i2](
|
87
|
+
angle_params[
|
88
|
+
num_qubits
|
89
|
+
* sum(
|
90
|
+
is_parametrized[
|
91
|
+
0 : operands_1qubit.len
|
92
|
+
] # type:ignore[index]
|
93
|
+
)
|
94
|
+
+ connectivity_map.len
|
95
|
+
* sum(
|
96
|
+
is_parametrized[
|
97
|
+
operands_1qubit.len : operands_1qubit.len + i2
|
98
|
+
]
|
99
|
+
)
|
100
|
+
+ floor((angle_params.len / reps) * r)
|
101
|
+
+ index
|
102
|
+
],
|
103
|
+
x[connectivity_map[index][0]],
|
104
|
+
x[connectivity_map[index][1]],
|
105
|
+
),
|
106
|
+
else_=lambda: operands_2qubit[i2](
|
107
|
+
0,
|
108
|
+
x[connectivity_map[index][0]],
|
109
|
+
x[connectivity_map[index][1]],
|
110
|
+
),
|
111
|
+
),
|
112
|
+
),
|
113
|
+
),
|
114
|
+
],
|
115
|
+
)
|
@@ -1,6 +1,9 @@
|
|
1
|
-
from
|
1
|
+
from typing import Annotated
|
2
2
|
|
3
3
|
from classiq.qmod.builtins.enums import Pauli
|
4
|
+
from classiq.qmod.builtins.functions.operators import switch
|
5
|
+
from classiq.qmod.builtins.functions.standard_gates import IDENTITY, RX, RY, RZ
|
6
|
+
from classiq.qmod.builtins.operations import control, repeat
|
4
7
|
from classiq.qmod.qfunc import qfunc
|
5
8
|
from classiq.qmod.qmod_parameter import CArray, CReal
|
6
9
|
from classiq.qmod.qmod_variable import QArray, QBit
|
@@ -15,7 +18,10 @@ def _single_pauli(
|
|
15
18
|
x: QArray[QBit],
|
16
19
|
q: QBit,
|
17
20
|
) -> None:
|
18
|
-
|
21
|
+
repeat(
|
22
|
+
x.len, lambda index: control(x[index], lambda: q1_qfunc(2**index * slope, q))
|
23
|
+
)
|
24
|
+
q1_qfunc(offset, q)
|
19
25
|
|
20
26
|
|
21
27
|
@qfunc(external=True)
|
@@ -61,5 +67,21 @@ def linear_pauli_rotations(
|
|
61
67
|
Links:
|
62
68
|
[linear_pauli_rotations](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/linear_pauli_rotations/linear_pauli_rotations)
|
63
69
|
"""
|
64
|
-
|
65
|
-
|
70
|
+
repeat(
|
71
|
+
q.len,
|
72
|
+
lambda index: _single_pauli(
|
73
|
+
slope=slopes[index],
|
74
|
+
offset=offsets[index],
|
75
|
+
q1_qfunc=lambda theta, target: switch(
|
76
|
+
bases[index],
|
77
|
+
[
|
78
|
+
lambda: IDENTITY(target),
|
79
|
+
lambda: RX(theta, target),
|
80
|
+
lambda: RY(theta, target),
|
81
|
+
lambda: RZ(theta, target),
|
82
|
+
],
|
83
|
+
),
|
84
|
+
x=x,
|
85
|
+
q=q[index],
|
86
|
+
),
|
87
|
+
)
|