classiq 0.45.0__py3-none-any.whl → 0.46.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.
Files changed (146) hide show
  1. classiq/__init__.py +0 -1
  2. classiq/_internals/__init__.py +20 -0
  3. classiq/_internals/authentication/authentication.py +11 -0
  4. classiq/analyzer/analyzer.py +12 -10
  5. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +1 -1
  6. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +1 -1
  7. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +1 -1
  8. classiq/applications/libraries/qmci_library.py +4 -9
  9. classiq/execution/execution_session.py +68 -7
  10. classiq/executor.py +14 -2
  11. classiq/interface/_version.py +1 -1
  12. classiq/interface/backend/backend_preferences.py +189 -0
  13. classiq/interface/backend/quantum_backend_providers.py +38 -0
  14. classiq/interface/debug_info/debug_info.py +22 -2
  15. classiq/interface/exceptions.py +16 -1
  16. classiq/interface/executor/execution_preferences.py +18 -0
  17. classiq/interface/generator/application_apis/chemistry_declarations.py +1 -177
  18. classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +0 -12
  19. classiq/interface/generator/application_apis/finance_declarations.py +8 -43
  20. classiq/interface/generator/application_apis/qsvm_declarations.py +0 -78
  21. classiq/interface/generator/builtin_api_builder.py +0 -3
  22. classiq/interface/generator/functions/__init__.py +0 -2
  23. classiq/interface/generator/functions/builtins/__init__.py +0 -15
  24. classiq/interface/generator/generated_circuit_data.py +2 -0
  25. classiq/interface/generator/hardware/hardware_data.py +37 -0
  26. classiq/interface/generator/model/constraints.py +18 -1
  27. classiq/interface/generator/model/preferences/preferences.py +53 -1
  28. classiq/interface/generator/model/quantum_register.py +1 -1
  29. classiq/interface/generator/quantum_program.py +10 -2
  30. classiq/interface/generator/transpiler_basis_gates.py +4 -0
  31. classiq/interface/generator/types/builtin_enum_declarations.py +136 -21
  32. classiq/interface/generator/types/enum_declaration.py +1 -3
  33. classiq/interface/generator/types/struct_declaration.py +1 -3
  34. classiq/interface/hardware.py +5 -0
  35. classiq/interface/ide/visual_model.py +1 -1
  36. classiq/interface/model/classical_parameter_declaration.py +6 -0
  37. classiq/interface/model/inplace_binary_operation.py +0 -14
  38. classiq/interface/model/model.py +1 -18
  39. classiq/interface/model/port_declaration.py +4 -2
  40. classiq/interface/model/quantum_function_declaration.py +19 -6
  41. classiq/interface/model/quantum_lambda_function.py +11 -1
  42. classiq/interface/model/quantum_variable_declaration.py +1 -1
  43. classiq/model_expansions/__init__.py +0 -0
  44. classiq/model_expansions/atomic_expression_functions_defs.py +250 -0
  45. classiq/model_expansions/capturing/__init__.py +0 -0
  46. classiq/model_expansions/capturing/captured_var_manager.py +50 -0
  47. classiq/model_expansions/capturing/mangling_utils.py +17 -0
  48. classiq/model_expansions/capturing/propagated_var_stack.py +180 -0
  49. classiq/model_expansions/closure.py +160 -0
  50. classiq/model_expansions/debug_flag.py +3 -0
  51. classiq/model_expansions/evaluators/__init__.py +0 -0
  52. classiq/model_expansions/evaluators/arg_type_match.py +160 -0
  53. classiq/model_expansions/evaluators/argument_types.py +42 -0
  54. classiq/model_expansions/evaluators/classical_expression.py +36 -0
  55. classiq/model_expansions/evaluators/control.py +144 -0
  56. classiq/model_expansions/evaluators/parameter_types.py +227 -0
  57. classiq/model_expansions/evaluators/quantum_type_utils.py +235 -0
  58. classiq/model_expansions/evaluators/type_type_match.py +90 -0
  59. classiq/model_expansions/expression_evaluator.py +125 -0
  60. classiq/model_expansions/expression_renamer.py +76 -0
  61. classiq/model_expansions/function_builder.py +192 -0
  62. classiq/model_expansions/generative_functions.py +101 -0
  63. classiq/model_expansions/interpreter.py +365 -0
  64. classiq/model_expansions/model_tables.py +105 -0
  65. classiq/model_expansions/quantum_operations/__init__.py +19 -0
  66. classiq/model_expansions/quantum_operations/bind.py +64 -0
  67. classiq/model_expansions/quantum_operations/classicalif.py +39 -0
  68. classiq/model_expansions/quantum_operations/control.py +235 -0
  69. classiq/model_expansions/quantum_operations/emitter.py +215 -0
  70. classiq/model_expansions/quantum_operations/expression_operation.py +218 -0
  71. classiq/model_expansions/quantum_operations/inplace_binary_operation.py +250 -0
  72. classiq/model_expansions/quantum_operations/invert.py +38 -0
  73. classiq/model_expansions/quantum_operations/power.py +74 -0
  74. classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +174 -0
  75. classiq/model_expansions/quantum_operations/quantum_function_call.py +15 -0
  76. classiq/model_expansions/quantum_operations/repeat.py +33 -0
  77. classiq/model_expansions/quantum_operations/variable_decleration.py +28 -0
  78. classiq/model_expansions/quantum_operations/within_apply.py +46 -0
  79. classiq/model_expansions/scope.py +226 -0
  80. classiq/model_expansions/scope_initialization.py +136 -0
  81. classiq/model_expansions/sympy_conversion/__init__.py +0 -0
  82. classiq/model_expansions/sympy_conversion/arithmetics.py +49 -0
  83. classiq/model_expansions/sympy_conversion/expression_to_sympy.py +150 -0
  84. classiq/model_expansions/sympy_conversion/sympy_to_python.py +113 -0
  85. classiq/model_expansions/utils/__init__.py +0 -0
  86. classiq/model_expansions/utils/counted_name_allocator.py +11 -0
  87. classiq/model_expansions/visitors/__init__.py +0 -0
  88. classiq/model_expansions/visitors/boolean_expression_transformers.py +214 -0
  89. classiq/model_expansions/visitors/variable_references.py +115 -0
  90. classiq/qmod/__init__.py +1 -3
  91. classiq/qmod/builtins/enums.py +33 -2
  92. classiq/qmod/builtins/functions/__init__.py +251 -0
  93. classiq/qmod/builtins/functions/amplitude_estimation.py +26 -0
  94. classiq/qmod/builtins/functions/arithmetic.py +68 -0
  95. classiq/qmod/builtins/functions/benchmarking.py +8 -0
  96. classiq/qmod/builtins/functions/chemistry.py +91 -0
  97. classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +105 -0
  98. classiq/qmod/builtins/functions/exponentiation.py +110 -0
  99. classiq/qmod/builtins/functions/finance.py +34 -0
  100. classiq/qmod/builtins/functions/grover.py +179 -0
  101. classiq/qmod/builtins/functions/hea.py +59 -0
  102. classiq/qmod/builtins/functions/linear_pauli_rotation.py +65 -0
  103. classiq/qmod/builtins/functions/modular_exponentiation.py +137 -0
  104. classiq/qmod/builtins/functions/operators.py +22 -0
  105. classiq/qmod/builtins/functions/qaoa_penalty.py +116 -0
  106. classiq/qmod/builtins/functions/qft.py +23 -0
  107. classiq/qmod/builtins/functions/qpe.py +39 -0
  108. classiq/qmod/builtins/functions/qsvm.py +24 -0
  109. classiq/qmod/builtins/functions/qsvt.py +136 -0
  110. classiq/qmod/builtins/functions/standard_gates.py +739 -0
  111. classiq/qmod/builtins/functions/state_preparation.py +356 -0
  112. classiq/qmod/builtins/functions/swap_test.py +25 -0
  113. classiq/qmod/builtins/structs.py +50 -28
  114. classiq/qmod/cparam.py +64 -0
  115. classiq/qmod/create_model_function.py +190 -0
  116. classiq/qmod/declaration_inferrer.py +52 -81
  117. classiq/qmod/expression_query.py +16 -0
  118. classiq/qmod/generative.py +48 -0
  119. classiq/qmod/model_state_container.py +1 -2
  120. classiq/qmod/native/pretty_printer.py +7 -11
  121. classiq/qmod/pretty_print/pretty_printer.py +7 -11
  122. classiq/qmod/python_classical_type.py +67 -0
  123. classiq/qmod/qfunc.py +19 -4
  124. classiq/qmod/qmod_parameter.py +15 -64
  125. classiq/qmod/qmod_variable.py +28 -46
  126. classiq/qmod/quantum_callable.py +1 -1
  127. classiq/qmod/quantum_expandable.py +10 -4
  128. classiq/qmod/quantum_function.py +22 -40
  129. classiq/qmod/semantics/error_manager.py +22 -10
  130. classiq/qmod/semantics/static_semantics_visitor.py +10 -12
  131. classiq/qmod/semantics/validation/types_validation.py +6 -7
  132. classiq/qmod/utilities.py +2 -2
  133. classiq/qmod/write_qmod.py +14 -0
  134. classiq/show.py +10 -0
  135. classiq/synthesis.py +46 -2
  136. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/METADATA +1 -1
  137. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/RECORD +138 -74
  138. classiq/interface/generator/functions/builtins/core_library/__init__.py +0 -16
  139. classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +0 -710
  140. classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +0 -105
  141. classiq/interface/generator/functions/builtins/open_lib_functions.py +0 -2489
  142. classiq/interface/generator/functions/builtins/quantum_operators.py +0 -24
  143. classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
  144. classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +0 -21
  145. classiq/qmod/builtins/functions.py +0 -1029
  146. {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,116 @@
1
+ from typing import Literal
2
+
3
+ from classiq.qmod.builtins.structs import PauliTerm
4
+ from classiq.qmod.qfunc import qfunc
5
+ from classiq.qmod.qmod_parameter import CArray, CInt, CReal
6
+ from classiq.qmod.qmod_variable import QArray, QBit
7
+
8
+
9
+ @qfunc(external=True)
10
+ def qaoa_mixer_layer(b: CReal, target: QArray[QBit]) -> None:
11
+ """
12
+ Qmod Classiq-library function
13
+
14
+ Generates the mixer layer for the QAOA algorithm.
15
+ The mixer layer is a sequence of `X` gates applied to each qubit in the target quantum
16
+ array variable.
17
+
18
+ Please refer to the [QAOA mixer tutorial](https://docs.classiq.io/latest/reference-manual/built-in-algorithms/combinatorial-optimization/problem-solving/) for an example
19
+
20
+
21
+ Args:
22
+ b: The rotation parameter for the mixer layer.
23
+ target: The target quantum array.
24
+ """
25
+ pass
26
+
27
+
28
+ @qfunc(external=True)
29
+ def qaoa_cost_layer(
30
+ g: CReal, hamiltonian: CArray[PauliTerm], target: QArray[QBit]
31
+ ) -> None:
32
+ """
33
+ Qmod Classiq-library function
34
+
35
+ Apply the cost layer to the QAOA model.
36
+
37
+ This function integrates the problem-specific cost function into the QAOA model's objective function.
38
+ The cost layer represents the primary objective that the QAOA algorithm seeks to optimize, such as
39
+ minimizing energy or maximizing profit, depending on the application.
40
+
41
+ For more details on defining cost functions in QAOA models using Pyomo, see: [Problem Formulation](https://docs.classiq.io/latest/reference-manual/built-in-algorithms/combinatorial-optimization/)
42
+ Args:
43
+ g: The rotation parameter for the cost layer (prefactor).
44
+ hamiltonian: The Hamiltonian terms for the QAOA model.
45
+ target: The target quantum array variable.
46
+ """
47
+ pass
48
+
49
+
50
+ @qfunc(external=True)
51
+ def qaoa_layer(
52
+ g: CReal, b: CReal, hamiltonian: CArray[PauliTerm], target: QArray[QBit]
53
+ ) -> None:
54
+ """
55
+ Qmod Classiq-library function
56
+
57
+ Apply the QAOA layer, which concatenates the cost layer and the mixer layer.
58
+
59
+ The `qaoa_layer` function integrates both the cost and mixer layers, essential components of the
60
+ Quantum Approximate Optimization Algorithm (QAOA). The cost layer encodes the problem's objective,
61
+ while the mixer layer introduces quantum superposition and drives the search across the solution space.
62
+
63
+ For more details mon the QAOA problem formulation, please see the following [tutorial](https://docs.classiq.io/latest/reference-manual/built-in-algorithms/combinatorial-optimization/)
64
+ Args:
65
+ g: The rotation parameter for the cost layer.
66
+ b: The rotation parameter for the mixer layer.
67
+ hamiltonian: The Hamiltonian terms for the QAOA model.
68
+ target: The target quantum array variable.
69
+
70
+ """
71
+ pass
72
+
73
+
74
+ @qfunc(external=True)
75
+ def qaoa_init(target: QArray[QBit]) -> None:
76
+ """
77
+ Qmod Classiq-library function
78
+
79
+ Initialize the QAOA circuit by applying the Hadamard gate to all qubits.
80
+
81
+ In the Quantum Approximate Optimization Algorithm (QAOA), the initial state is a uniform superposition
82
+ created by applying the Hadamard gate to each qubit. This function prepares the qubits for the subsequent
83
+ application of the cost and mixer layers by preparing them in an equal superposition state.
84
+
85
+ Args:
86
+ target: The target quantum array variable.
87
+ """
88
+ pass
89
+
90
+
91
+ @qfunc(external=True)
92
+ def qaoa_penalty(
93
+ num_qubits: CInt,
94
+ params_list: CArray[CReal],
95
+ hamiltonian: CArray[PauliTerm],
96
+ target: QArray[QBit, Literal["num_qubits"]],
97
+ ) -> None:
98
+ """
99
+ Qmod Classiq-library function
100
+
101
+ Apply the penalty layer to the QAOA model.
102
+
103
+ This function adds a penalty term to the objective function of the QAOA model to
104
+ enforce certain constraints (e.g., binary or integer variables) during the
105
+ optimization process.
106
+
107
+ Please refer to the [Optimization Problem tutorial](https://docs.classiq.io/latest/reference-manual/built-in-algorithms/combinatorial-optimization/problem-formulation/) for details.
108
+
109
+
110
+ Args:
111
+ num_qubits: The number of qubits in the quantum circuit.
112
+ params_list The list of QAOA parameters.
113
+ hamiltonian: The Hamiltonian terms for the QAOA model.
114
+ target: The target quantum array variable.
115
+ """
116
+ pass
@@ -0,0 +1,23 @@
1
+ from classiq.qmod.qfunc import qfunc
2
+ from classiq.qmod.qmod_variable import QArray, QBit
3
+
4
+
5
+ @qfunc(external=True)
6
+ def qft(target: QArray[QBit]) -> None:
7
+ """
8
+ Qmod Classiq-library function.
9
+
10
+ Performs the Quantum Fourier Transform (QFT) on `target` in-place.
11
+ Implements the following transformation:
12
+
13
+ $$
14
+ y_{k} = \\frac{1}{\\sqrt{N}} \\sum_{j=0}^{N-1} x_j e^{2\\pi i \\frac{jk}{N}}
15
+ $$
16
+
17
+ Args:
18
+ target: The quantum object to be transformed
19
+
20
+ Further reading in Classiq Library:
21
+ Link: [qft library reference](https://github.com/Classiq/classiq-library/blob/main/functions/qmod_library_reference/classiq_open_library/qft/qft.ipynb)
22
+ """
23
+ pass
@@ -0,0 +1,39 @@
1
+ from classiq.qmod.qfunc import qfunc
2
+ from classiq.qmod.qmod_parameter import CInt
3
+ from classiq.qmod.qmod_variable import QNum
4
+ from classiq.qmod.quantum_callable import QCallable
5
+
6
+
7
+ @qfunc(external=True)
8
+ def qpe_flexible(unitary_with_power: QCallable[CInt], phase: QNum) -> None:
9
+ """
10
+ Qmod Classiq-library function.
11
+
12
+ Implements the Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator $U$.
13
+ This is a flexible version that allows the user to provide a callable that generates the unitary operator $U^k$ for a given integer $k$, offering greater flexibility in handling different quantum circuits using some powering rule.
14
+
15
+ Args:
16
+ unitary_with_power: A callable that returns the unitary operator $U^k$ given an integer $k$. This callable is used to control the application of powers of the unitary operator.
17
+ phase: The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero.
18
+
19
+ Further reading in Classiq Library:
20
+ Link: [qpe library reference](https://github.com/Classiq/classiq-library/blob/main/functions/qmod_library_reference/classiq_open_library/qpe/qpe.ipynb)
21
+ """
22
+ pass
23
+
24
+
25
+ @qfunc(external=True)
26
+ def qpe(unitary: QCallable, phase: QNum) -> None:
27
+ """
28
+ Qmod Classiq-library function.
29
+
30
+ Implements the standard Quantum Phase Estimation (QPE) algorithm, which estimates the phase (eigenvalue) associated with an eigenstate of a given unitary operator $U$.
31
+
32
+ Args:
33
+ unitary: A callable representing the unitary operator $U$, whose eigenvalue is to be estimated.
34
+ phase: The quantum variable that represents the estimated phase (eigenvalue), assuming initialized to zero.
35
+
36
+ Further reading in Classiq Library:
37
+ Link: [qpe library reference](https://github.com/Classiq/classiq-library/blob/main/functions/qmod_library_reference/classiq_open_library/qpe/qpe.ipynb)
38
+ """
39
+ pass
@@ -0,0 +1,24 @@
1
+ from typing import Literal
2
+
3
+ from classiq.qmod.builtins.structs import (
4
+ QSVMFeatureMapPauli,
5
+ )
6
+ from classiq.qmod.qfunc import qfunc
7
+ from classiq.qmod.qmod_parameter import CInt
8
+ from classiq.qmod.qmod_variable import QArray, QBit
9
+
10
+
11
+ @qfunc(external=True)
12
+ def pauli_feature_map(
13
+ feature_map: QSVMFeatureMapPauli,
14
+ qbv: QArray[QBit, Literal["get_field(feature_map, 'feature_dimension')"]],
15
+ ) -> None:
16
+ pass
17
+
18
+
19
+ @qfunc(external=True)
20
+ def bloch_sphere_feature_map(
21
+ feature_dimension: CInt,
22
+ qbv: QArray[QBit, Literal["ceiling(feature_dimension / 2)"]],
23
+ ) -> None:
24
+ pass
@@ -0,0 +1,136 @@
1
+ from classiq.qmod.qfunc import qfunc
2
+ from classiq.qmod.qmod_parameter import CArray, CReal
3
+ from classiq.qmod.qmod_variable import QArray, QBit
4
+ from classiq.qmod.quantum_callable import QCallable
5
+
6
+
7
+ @qfunc(external=True)
8
+ def qsvt_step(
9
+ phase1: CReal,
10
+ phase2: CReal,
11
+ proj_cnot_1: QCallable[QArray[QBit], QBit],
12
+ proj_cnot_2: QCallable[QArray[QBit], QBit],
13
+ u: QCallable[QArray[QBit]],
14
+ qvar: QArray[QBit],
15
+ aux: QBit,
16
+ ) -> None:
17
+ r"""
18
+ Qmod Classiq-library function.
19
+
20
+ Applies a single QSVT step, composed of 2 projector-controlled-phase rotations, and applications of the block encoding unitary `u` and its inverse:
21
+
22
+ $$
23
+ \Pi_{\phi_2}U^{\dagger}\tilde{\Pi}_{\phi_{1}}U
24
+ $$
25
+
26
+ Args:
27
+ phase1: 1st rotation phase.
28
+ phase2: 2nd rotation phase.
29
+ proj_cnot_1: Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.
30
+ proj_cnot_2: Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.
31
+ u: A block encoded unitary matrix.
32
+ qvar: The quantum variable to which U is applied, which resides in the entire block encoding space.
33
+ aux: A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.
34
+
35
+ Further reading in Classiq Library:
36
+ [QSVT function usage example](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/qsvt/qsvt/)
37
+ """
38
+ pass
39
+
40
+
41
+ @qfunc(external=True)
42
+ def qsvt(
43
+ phase_seq: CArray[CReal],
44
+ proj_cnot_1: QCallable[QArray[QBit], QBit],
45
+ proj_cnot_2: QCallable[QArray[QBit], QBit],
46
+ u: QCallable[QArray[QBit]],
47
+ qvar: QArray[QBit],
48
+ aux: QBit,
49
+ ) -> None:
50
+ r"""
51
+ Qmod Classiq-library function.
52
+
53
+ Implements the Quantum Singular Value Transformation (QSVT) - an algorithmic framework, used to apply polynomial transformations of degree `d` on the singular values of a block encoded matrix, given as the unitary `u`. Given a unitary $U$, a list of phase angles $\phi_1, \phi_2, ..., \phi_{d+1}$ and 2 projector-controlled-not operands $C_{\Pi}NOT,C_{\tilde{\Pi}}NOT$, the QSVT sequence is as follows:
54
+ Given a unitary $U$, a list of phase angles $\phi_1, \phi_2, ..., \phi_{d+1}$ and 2 projector-controlled-not operands $C_{\Pi}NOT,C_{\tilde{\Pi}}NOT$, the QSVT sequence is as follows:
55
+
56
+ $$
57
+ \tilde{\Pi}_{\phi_{d+1}}U \prod_{k=1}^{(d-1)/2} (\Pi_{\phi_{d-2k}} U^{\dagger}\tilde{\Pi}_{\phi_{d - (2k+1)}}U)\Pi_{\phi_{1}}
58
+ $$
59
+
60
+ for odd $d$, and:
61
+
62
+ $$
63
+ \prod_{k=1}^{d/2} (\Pi_{\phi_{d-(2k-1)}} U^{\dagger}\tilde{\Pi}_{\phi_{d-2k}}U)\Pi_{\phi_{1}}
64
+ $$
65
+
66
+ for even $d$.
67
+
68
+ Each of the $\Pi$s is a projector-controlled-phase unitary, according to the given projectors.
69
+
70
+ Args:
71
+ phase_seq: A sequence of phase angles of length d+1.
72
+ proj_cnot_1: Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.
73
+ proj_cnot_2: Projector-controlled-not unitary that locates the encoded matrix rows within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.
74
+ u: A block encoded unitary matrix.
75
+ qvar: The quantum variable to which U is applied, which resides in the entire block encoding space.
76
+ aux: A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.
77
+
78
+ Further reading in Classiq Library:
79
+ [QSVT function usage example](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/qsvt/qsvt/)
80
+ """
81
+ pass
82
+
83
+
84
+ @qfunc(external=True)
85
+ def projector_controlled_phase(
86
+ phase: CReal,
87
+ proj_cnot: QCallable[QArray[QBit], QBit],
88
+ qvar: QArray[QBit],
89
+ aux: QBit,
90
+ ) -> None:
91
+ r"""
92
+ Qmod Classiq-library function.
93
+
94
+ Assigns a phase to the entire subspace determined by the given projector. Corresponds to the operation:
95
+
96
+ $$
97
+ \Pi_{\phi} = (C_{\Pi}NOT) e^{-i\frac{\phi}{2}Z}(C_{\Pi}NOT)
98
+ $$
99
+
100
+ Args:
101
+ phase_seq: A rotation phase.
102
+ proj_cnot: Projector-controlled-not unitary that sets an auxilliary qubit to |1> when the state is in the projection.
103
+ qvar: The quantum variable to which the rotation applies, which resides in the entire block encoding space.
104
+ aux: A zero auxilliary qubit, used for the projector-controlled-phase rotation. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.
105
+
106
+ Further reading in Classiq Library:
107
+ [QSVT function usage example](https://docs.classiq.io/latest/explore/functions/qmod_library_reference/classiq_open_library/qsvt/qsvt/)
108
+ """
109
+ pass
110
+
111
+
112
+ @qfunc(external=True)
113
+ def qsvt_inversion(
114
+ phase_seq: CArray[CReal],
115
+ block_encoding_cnot: QCallable[QArray[QBit], QBit],
116
+ u: QCallable[QArray[QBit]],
117
+ qvar: QArray[QBit],
118
+ aux: QBit,
119
+ ) -> None:
120
+ r"""
121
+ Qmod Classiq-library function.
122
+
123
+ Implements matrix inversion on a given block-encoding of a square matrix, using the QSVT framework. Applies a polynomial approximation
124
+ of the inverse of the singular values of the matrix encoded in `u`. The phases for the polynomial should be pre-calculated and passed into the function.
125
+
126
+ Args:
127
+ phase_seq: A sequence of phase angles of length d+1, corresponding to an odd polynomial approximation of the scaled inverse function.
128
+ block_encoding_cnot: Projector-controlled-not unitary that locates the encoded matrix columns within U. Accepts a quantum variable of the same size as qvar, and a qubit that is set to |1> when the state is in the block.
129
+ u: A block encoded unitary matrix.
130
+ qvar: The quantum variable to which U is applied, which resides in the entire block encoding space.
131
+ aux: A zero auxilliary qubit, used for the projector-controlled-phase rotations. Given as an inout so that qsvt can be used as a building-block in a larger algorithm.
132
+
133
+ For usage example, see:
134
+ [QSVT matrix inversion example](https://docs.classiq.io/latest/explore/algorithms/qsvt/qsvt_matrix_inversion/qsvt_matrix_inversion)
135
+ """
136
+ pass