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.
- classiq/__init__.py +0 -1
- classiq/_internals/__init__.py +20 -0
- classiq/_internals/authentication/authentication.py +11 -0
- classiq/analyzer/analyzer.py +12 -10
- classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +1 -1
- classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +1 -1
- classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +1 -1
- classiq/applications/libraries/qmci_library.py +4 -9
- classiq/execution/execution_session.py +68 -7
- classiq/executor.py +14 -2
- classiq/interface/_version.py +1 -1
- classiq/interface/backend/backend_preferences.py +189 -0
- classiq/interface/backend/quantum_backend_providers.py +38 -0
- classiq/interface/debug_info/debug_info.py +22 -2
- classiq/interface/exceptions.py +16 -1
- classiq/interface/executor/execution_preferences.py +18 -0
- classiq/interface/generator/application_apis/chemistry_declarations.py +1 -177
- classiq/interface/generator/application_apis/combinatorial_optimization_declarations.py +0 -12
- classiq/interface/generator/application_apis/finance_declarations.py +8 -43
- classiq/interface/generator/application_apis/qsvm_declarations.py +0 -78
- classiq/interface/generator/builtin_api_builder.py +0 -3
- classiq/interface/generator/functions/__init__.py +0 -2
- classiq/interface/generator/functions/builtins/__init__.py +0 -15
- classiq/interface/generator/generated_circuit_data.py +2 -0
- classiq/interface/generator/hardware/hardware_data.py +37 -0
- classiq/interface/generator/model/constraints.py +18 -1
- classiq/interface/generator/model/preferences/preferences.py +53 -1
- classiq/interface/generator/model/quantum_register.py +1 -1
- classiq/interface/generator/quantum_program.py +10 -2
- classiq/interface/generator/transpiler_basis_gates.py +4 -0
- classiq/interface/generator/types/builtin_enum_declarations.py +136 -21
- classiq/interface/generator/types/enum_declaration.py +1 -3
- classiq/interface/generator/types/struct_declaration.py +1 -3
- classiq/interface/hardware.py +5 -0
- classiq/interface/ide/visual_model.py +1 -1
- classiq/interface/model/classical_parameter_declaration.py +6 -0
- classiq/interface/model/inplace_binary_operation.py +0 -14
- classiq/interface/model/model.py +1 -18
- classiq/interface/model/port_declaration.py +4 -2
- classiq/interface/model/quantum_function_declaration.py +19 -6
- classiq/interface/model/quantum_lambda_function.py +11 -1
- classiq/interface/model/quantum_variable_declaration.py +1 -1
- classiq/model_expansions/__init__.py +0 -0
- classiq/model_expansions/atomic_expression_functions_defs.py +250 -0
- classiq/model_expansions/capturing/__init__.py +0 -0
- classiq/model_expansions/capturing/captured_var_manager.py +50 -0
- classiq/model_expansions/capturing/mangling_utils.py +17 -0
- classiq/model_expansions/capturing/propagated_var_stack.py +180 -0
- classiq/model_expansions/closure.py +160 -0
- classiq/model_expansions/debug_flag.py +3 -0
- classiq/model_expansions/evaluators/__init__.py +0 -0
- classiq/model_expansions/evaluators/arg_type_match.py +160 -0
- classiq/model_expansions/evaluators/argument_types.py +42 -0
- classiq/model_expansions/evaluators/classical_expression.py +36 -0
- classiq/model_expansions/evaluators/control.py +144 -0
- classiq/model_expansions/evaluators/parameter_types.py +227 -0
- classiq/model_expansions/evaluators/quantum_type_utils.py +235 -0
- classiq/model_expansions/evaluators/type_type_match.py +90 -0
- classiq/model_expansions/expression_evaluator.py +125 -0
- classiq/model_expansions/expression_renamer.py +76 -0
- classiq/model_expansions/function_builder.py +192 -0
- classiq/model_expansions/generative_functions.py +101 -0
- classiq/model_expansions/interpreter.py +365 -0
- classiq/model_expansions/model_tables.py +105 -0
- classiq/model_expansions/quantum_operations/__init__.py +19 -0
- classiq/model_expansions/quantum_operations/bind.py +64 -0
- classiq/model_expansions/quantum_operations/classicalif.py +39 -0
- classiq/model_expansions/quantum_operations/control.py +235 -0
- classiq/model_expansions/quantum_operations/emitter.py +215 -0
- classiq/model_expansions/quantum_operations/expression_operation.py +218 -0
- classiq/model_expansions/quantum_operations/inplace_binary_operation.py +250 -0
- classiq/model_expansions/quantum_operations/invert.py +38 -0
- classiq/model_expansions/quantum_operations/power.py +74 -0
- classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +174 -0
- classiq/model_expansions/quantum_operations/quantum_function_call.py +15 -0
- classiq/model_expansions/quantum_operations/repeat.py +33 -0
- classiq/model_expansions/quantum_operations/variable_decleration.py +28 -0
- classiq/model_expansions/quantum_operations/within_apply.py +46 -0
- classiq/model_expansions/scope.py +226 -0
- classiq/model_expansions/scope_initialization.py +136 -0
- classiq/model_expansions/sympy_conversion/__init__.py +0 -0
- classiq/model_expansions/sympy_conversion/arithmetics.py +49 -0
- classiq/model_expansions/sympy_conversion/expression_to_sympy.py +150 -0
- classiq/model_expansions/sympy_conversion/sympy_to_python.py +113 -0
- classiq/model_expansions/utils/__init__.py +0 -0
- classiq/model_expansions/utils/counted_name_allocator.py +11 -0
- classiq/model_expansions/visitors/__init__.py +0 -0
- classiq/model_expansions/visitors/boolean_expression_transformers.py +214 -0
- classiq/model_expansions/visitors/variable_references.py +115 -0
- classiq/qmod/__init__.py +1 -3
- classiq/qmod/builtins/enums.py +33 -2
- classiq/qmod/builtins/functions/__init__.py +251 -0
- classiq/qmod/builtins/functions/amplitude_estimation.py +26 -0
- classiq/qmod/builtins/functions/arithmetic.py +68 -0
- classiq/qmod/builtins/functions/benchmarking.py +8 -0
- classiq/qmod/builtins/functions/chemistry.py +91 -0
- classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +105 -0
- classiq/qmod/builtins/functions/exponentiation.py +110 -0
- classiq/qmod/builtins/functions/finance.py +34 -0
- classiq/qmod/builtins/functions/grover.py +179 -0
- classiq/qmod/builtins/functions/hea.py +59 -0
- classiq/qmod/builtins/functions/linear_pauli_rotation.py +65 -0
- classiq/qmod/builtins/functions/modular_exponentiation.py +137 -0
- classiq/qmod/builtins/functions/operators.py +22 -0
- classiq/qmod/builtins/functions/qaoa_penalty.py +116 -0
- classiq/qmod/builtins/functions/qft.py +23 -0
- classiq/qmod/builtins/functions/qpe.py +39 -0
- classiq/qmod/builtins/functions/qsvm.py +24 -0
- classiq/qmod/builtins/functions/qsvt.py +136 -0
- classiq/qmod/builtins/functions/standard_gates.py +739 -0
- classiq/qmod/builtins/functions/state_preparation.py +356 -0
- classiq/qmod/builtins/functions/swap_test.py +25 -0
- classiq/qmod/builtins/structs.py +50 -28
- classiq/qmod/cparam.py +64 -0
- classiq/qmod/create_model_function.py +190 -0
- classiq/qmod/declaration_inferrer.py +52 -81
- classiq/qmod/expression_query.py +16 -0
- classiq/qmod/generative.py +48 -0
- classiq/qmod/model_state_container.py +1 -2
- classiq/qmod/native/pretty_printer.py +7 -11
- classiq/qmod/pretty_print/pretty_printer.py +7 -11
- classiq/qmod/python_classical_type.py +67 -0
- classiq/qmod/qfunc.py +19 -4
- classiq/qmod/qmod_parameter.py +15 -64
- classiq/qmod/qmod_variable.py +28 -46
- classiq/qmod/quantum_callable.py +1 -1
- classiq/qmod/quantum_expandable.py +10 -4
- classiq/qmod/quantum_function.py +22 -40
- classiq/qmod/semantics/error_manager.py +22 -10
- classiq/qmod/semantics/static_semantics_visitor.py +10 -12
- classiq/qmod/semantics/validation/types_validation.py +6 -7
- classiq/qmod/utilities.py +2 -2
- classiq/qmod/write_qmod.py +14 -0
- classiq/show.py +10 -0
- classiq/synthesis.py +46 -2
- {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/METADATA +1 -1
- {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/RECORD +138 -74
- classiq/interface/generator/functions/builtins/core_library/__init__.py +0 -16
- classiq/interface/generator/functions/builtins/core_library/atomic_quantum_functions.py +0 -710
- classiq/interface/generator/functions/builtins/core_library/exponentiation_functions.py +0 -105
- classiq/interface/generator/functions/builtins/open_lib_functions.py +0 -2489
- classiq/interface/generator/functions/builtins/quantum_operators.py +0 -24
- classiq/interface/generator/types/builtin_struct_declarations/__init__.py +0 -1
- classiq/interface/generator/types/builtin_struct_declarations/pauli_struct_declarations.py +0 -21
- classiq/qmod/builtins/functions.py +0 -1029
- {classiq-0.45.0.dist-info → classiq-0.46.0.dist-info}/WHEEL +0 -0
classiq/qmod/builtins/enums.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# This file was generated automatically - do not edit manually
|
2
|
-
|
3
1
|
from enum import IntEnum
|
4
2
|
|
3
|
+
from classiq.interface.generator.types.enum_declaration import EnumDeclaration
|
4
|
+
|
5
5
|
|
6
6
|
class Element(IntEnum):
|
7
7
|
H = 0
|
@@ -152,10 +152,28 @@ class Optimizer(IntEnum):
|
|
152
152
|
|
153
153
|
|
154
154
|
class Pauli(IntEnum):
|
155
|
+
"""
|
156
|
+
Enumeration for the Pauli matrices used in quantum computing.
|
157
|
+
|
158
|
+
The Pauli matrices are fundamental operations in quantum computing, and this
|
159
|
+
enum assigns integer values to represent each matrix.
|
160
|
+
"""
|
161
|
+
|
155
162
|
I = 0 # noqa: E741
|
163
|
+
"""I (int): Identity matrix, represented by the integer 0. \n
|
164
|
+
$I = \\begin{bmatrix} 1 & 0 \\\\ 0 & 1 \\end{bmatrix}$"""
|
165
|
+
|
156
166
|
X = 1
|
167
|
+
"""X (int): Pauli-X matrix, represented by the integer 1. \n
|
168
|
+
$X = \\begin{bmatrix} 0 & 1 \\\\ 1 & 0 \\end{bmatrix}$"""
|
169
|
+
|
157
170
|
Y = 2
|
171
|
+
"""Y (int): Pauli-Y matrix, represented by the integer 2. \n
|
172
|
+
$Y = \\begin{bmatrix} 0 & -i \\\\ i & 0 \\end{bmatrix}$"""
|
173
|
+
|
158
174
|
Z = 3
|
175
|
+
"""Z (int): Pauli-Z matrix, represented by the integer 3. \n
|
176
|
+
$Z = \\begin{bmatrix} 1 & 0 \\\\ 0 & -1 \\end{bmatrix}$"""
|
159
177
|
|
160
178
|
|
161
179
|
class QSVMFeatureMapEntanglement(IntEnum):
|
@@ -166,6 +184,19 @@ class QSVMFeatureMapEntanglement(IntEnum):
|
|
166
184
|
PAIRWISE = 4
|
167
185
|
|
168
186
|
|
187
|
+
BUILTIN_ENUM_DECLARATIONS = {
|
188
|
+
enum_def.__name__: EnumDeclaration(
|
189
|
+
name=enum_def.__name__,
|
190
|
+
members={enum_val.name: enum_val.value for enum_val in enum_def},
|
191
|
+
)
|
192
|
+
for enum_def in vars().values()
|
193
|
+
if (
|
194
|
+
isinstance(enum_def, type)
|
195
|
+
and issubclass(enum_def, IntEnum)
|
196
|
+
and enum_def is not IntEnum
|
197
|
+
)
|
198
|
+
}
|
199
|
+
|
169
200
|
__all__ = [
|
170
201
|
"Element",
|
171
202
|
"FermionMapping",
|
@@ -0,0 +1,251 @@
|
|
1
|
+
from .amplitude_estimation import *
|
2
|
+
from .arithmetic import *
|
3
|
+
from .benchmarking import *
|
4
|
+
from .chemistry import *
|
5
|
+
from .discrete_sine_cosine_transform import *
|
6
|
+
from .discrete_sine_cosine_transform import _qct_d_operator, _qct_pi_operator
|
7
|
+
from .exponentiation import *
|
8
|
+
from .finance import *
|
9
|
+
from .grover import *
|
10
|
+
from .hea import *
|
11
|
+
from .linear_pauli_rotation import *
|
12
|
+
from .linear_pauli_rotation import _single_pauli
|
13
|
+
from .modular_exponentiation import *
|
14
|
+
from .modular_exponentiation import _check_msb, _ctrl_x
|
15
|
+
from .operators import *
|
16
|
+
from .qaoa_penalty import *
|
17
|
+
from .qft import *
|
18
|
+
from .qpe import *
|
19
|
+
from .qsvm import *
|
20
|
+
from .qsvt import *
|
21
|
+
from .standard_gates import *
|
22
|
+
from .state_preparation import *
|
23
|
+
from .state_preparation import _prepare_uniform_trimmed_state_step
|
24
|
+
from .swap_test import *
|
25
|
+
|
26
|
+
CORE_LIB_DECLS = [
|
27
|
+
func.func_decl
|
28
|
+
for func in (
|
29
|
+
molecule_ucc,
|
30
|
+
molecule_hva,
|
31
|
+
molecule_hartree_fock,
|
32
|
+
fock_hamiltonian_ucc,
|
33
|
+
fock_hamiltonian_hva,
|
34
|
+
fock_hamiltonian_hartree_fock,
|
35
|
+
log_normal_finance,
|
36
|
+
gaussian_finance,
|
37
|
+
pauli_feature_map,
|
38
|
+
bloch_sphere_feature_map,
|
39
|
+
H,
|
40
|
+
X,
|
41
|
+
Y,
|
42
|
+
Z,
|
43
|
+
I,
|
44
|
+
S,
|
45
|
+
T,
|
46
|
+
SDG,
|
47
|
+
TDG,
|
48
|
+
PHASE,
|
49
|
+
RX,
|
50
|
+
RY,
|
51
|
+
RZ,
|
52
|
+
R,
|
53
|
+
RXX,
|
54
|
+
RYY,
|
55
|
+
RZZ,
|
56
|
+
CH,
|
57
|
+
CX,
|
58
|
+
CY,
|
59
|
+
CZ,
|
60
|
+
CRX,
|
61
|
+
CRY,
|
62
|
+
CRZ,
|
63
|
+
CPHASE,
|
64
|
+
SWAP,
|
65
|
+
IDENTITY,
|
66
|
+
prepare_state,
|
67
|
+
prepare_amplitudes,
|
68
|
+
unitary,
|
69
|
+
add,
|
70
|
+
modular_add,
|
71
|
+
integer_xor,
|
72
|
+
U,
|
73
|
+
CCX,
|
74
|
+
allocate,
|
75
|
+
free,
|
76
|
+
randomized_benchmarking,
|
77
|
+
inplace_prepare_state,
|
78
|
+
inplace_prepare_amplitudes,
|
79
|
+
single_pauli_exponent,
|
80
|
+
suzuki_trotter,
|
81
|
+
qdrift,
|
82
|
+
exponentiation_with_depth_constraint,
|
83
|
+
)
|
84
|
+
]
|
85
|
+
|
86
|
+
OPEN_LIB_DECLS = [
|
87
|
+
func.func_decl
|
88
|
+
for func in (
|
89
|
+
qpe_flexible,
|
90
|
+
qpe,
|
91
|
+
_single_pauli,
|
92
|
+
linear_pauli_rotations,
|
93
|
+
amplitude_estimation,
|
94
|
+
phase_oracle,
|
95
|
+
reflect_about_zero,
|
96
|
+
grover_diffuser,
|
97
|
+
grover_operator,
|
98
|
+
grover_search,
|
99
|
+
hadamard_transform,
|
100
|
+
apply_to_all,
|
101
|
+
qft_no_swap,
|
102
|
+
qft_space_add_const,
|
103
|
+
cc_modular_add,
|
104
|
+
c_modular_multiply,
|
105
|
+
multiswap,
|
106
|
+
inplace_c_modular_multiply,
|
107
|
+
modular_exp,
|
108
|
+
qsvt_step,
|
109
|
+
qsvt,
|
110
|
+
projector_controlled_phase,
|
111
|
+
qsvt_inversion,
|
112
|
+
allocate_num,
|
113
|
+
qaoa_mixer_layer,
|
114
|
+
qaoa_cost_layer,
|
115
|
+
qaoa_layer,
|
116
|
+
qaoa_init,
|
117
|
+
qaoa_penalty,
|
118
|
+
full_hea,
|
119
|
+
swap_test,
|
120
|
+
prepare_uniform_trimmed_state,
|
121
|
+
prepare_uniform_interval_state,
|
122
|
+
prepare_ghz_state,
|
123
|
+
prepare_exponential_state,
|
124
|
+
prepare_bell_state,
|
125
|
+
inplace_prepare_int,
|
126
|
+
prepare_int,
|
127
|
+
switch,
|
128
|
+
qct_qst_type1,
|
129
|
+
qct_qst_type2,
|
130
|
+
qct_type2,
|
131
|
+
qst_type2,
|
132
|
+
modular_increment,
|
133
|
+
qft,
|
134
|
+
_ctrl_x,
|
135
|
+
_prepare_uniform_trimmed_state_step,
|
136
|
+
_qct_d_operator,
|
137
|
+
_qct_pi_operator,
|
138
|
+
_check_msb,
|
139
|
+
)
|
140
|
+
]
|
141
|
+
|
142
|
+
STD_QMOD_OPERATORS = [func.func_decl for func in (apply, permute)]
|
143
|
+
|
144
|
+
BUILTIN_FUNCTION_DECLARATIONS = {
|
145
|
+
func_decl.name: func_decl
|
146
|
+
for func_decl in STD_QMOD_OPERATORS + OPEN_LIB_DECLS + CORE_LIB_DECLS
|
147
|
+
}
|
148
|
+
|
149
|
+
__all__ = [
|
150
|
+
"permute",
|
151
|
+
"apply",
|
152
|
+
"molecule_ucc",
|
153
|
+
"molecule_hva",
|
154
|
+
"molecule_hartree_fock",
|
155
|
+
"fock_hamiltonian_ucc",
|
156
|
+
"fock_hamiltonian_hva",
|
157
|
+
"fock_hamiltonian_hartree_fock",
|
158
|
+
"log_normal_finance",
|
159
|
+
"gaussian_finance",
|
160
|
+
"pauli_feature_map",
|
161
|
+
"bloch_sphere_feature_map",
|
162
|
+
"H",
|
163
|
+
"X",
|
164
|
+
"Y",
|
165
|
+
"Z",
|
166
|
+
"I",
|
167
|
+
"S",
|
168
|
+
"T",
|
169
|
+
"SDG",
|
170
|
+
"TDG",
|
171
|
+
"PHASE",
|
172
|
+
"RX",
|
173
|
+
"RY",
|
174
|
+
"RZ",
|
175
|
+
"R",
|
176
|
+
"RXX",
|
177
|
+
"RYY",
|
178
|
+
"RZZ",
|
179
|
+
"CH",
|
180
|
+
"CX",
|
181
|
+
"CY",
|
182
|
+
"CZ",
|
183
|
+
"CRX",
|
184
|
+
"CRY",
|
185
|
+
"CRZ",
|
186
|
+
"CPHASE",
|
187
|
+
"SWAP",
|
188
|
+
"IDENTITY",
|
189
|
+
"prepare_state",
|
190
|
+
"prepare_amplitudes",
|
191
|
+
"unitary",
|
192
|
+
"add",
|
193
|
+
"modular_add",
|
194
|
+
"integer_xor",
|
195
|
+
"U",
|
196
|
+
"CCX",
|
197
|
+
"allocate",
|
198
|
+
"free",
|
199
|
+
"randomized_benchmarking",
|
200
|
+
"inplace_prepare_state",
|
201
|
+
"inplace_prepare_amplitudes",
|
202
|
+
"single_pauli_exponent",
|
203
|
+
"suzuki_trotter",
|
204
|
+
"qdrift",
|
205
|
+
"exponentiation_with_depth_constraint",
|
206
|
+
"qpe_flexible",
|
207
|
+
"qpe",
|
208
|
+
"_single_pauli",
|
209
|
+
"linear_pauli_rotations",
|
210
|
+
"amplitude_estimation",
|
211
|
+
"phase_oracle",
|
212
|
+
"reflect_about_zero",
|
213
|
+
"grover_diffuser",
|
214
|
+
"grover_operator",
|
215
|
+
"grover_search",
|
216
|
+
"hadamard_transform",
|
217
|
+
"apply_to_all",
|
218
|
+
"qft_no_swap",
|
219
|
+
"qft_space_add_const",
|
220
|
+
"cc_modular_add",
|
221
|
+
"c_modular_multiply",
|
222
|
+
"multiswap",
|
223
|
+
"inplace_c_modular_multiply",
|
224
|
+
"modular_exp",
|
225
|
+
"qsvt_step",
|
226
|
+
"qsvt",
|
227
|
+
"projector_controlled_phase",
|
228
|
+
"qsvt_inversion",
|
229
|
+
"allocate_num",
|
230
|
+
"qaoa_mixer_layer",
|
231
|
+
"qaoa_cost_layer",
|
232
|
+
"qaoa_layer",
|
233
|
+
"qaoa_init",
|
234
|
+
"qaoa_penalty",
|
235
|
+
"full_hea",
|
236
|
+
"swap_test",
|
237
|
+
"prepare_uniform_trimmed_state",
|
238
|
+
"prepare_uniform_interval_state",
|
239
|
+
"prepare_ghz_state",
|
240
|
+
"prepare_exponential_state",
|
241
|
+
"prepare_bell_state",
|
242
|
+
"inplace_prepare_int",
|
243
|
+
"prepare_int",
|
244
|
+
"switch",
|
245
|
+
"qct_qst_type1",
|
246
|
+
"qct_qst_type2",
|
247
|
+
"qct_type2",
|
248
|
+
"qst_type2",
|
249
|
+
"modular_increment",
|
250
|
+
"qft",
|
251
|
+
]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
from classiq.qmod.qfunc import qfunc
|
2
|
+
from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
3
|
+
from classiq.qmod.quantum_callable import QCallable
|
4
|
+
|
5
|
+
|
6
|
+
@qfunc(external=True)
|
7
|
+
def amplitude_estimation(
|
8
|
+
oracle: QCallable[QArray[QBit]],
|
9
|
+
space_transform: QCallable[QArray[QBit]],
|
10
|
+
phase: QNum,
|
11
|
+
packed_vars: QArray[QBit],
|
12
|
+
) -> None:
|
13
|
+
"""
|
14
|
+
[Qmod Classiq-library function]
|
15
|
+
Amplitude estimation function is used to estimate the probability of a state being marked by the operand `oracle` as a "good state."
|
16
|
+
|
17
|
+
The algorithm prepares the state in the `packed_vars` register and estimates the probability of this state being marked by the oracle as a "good state."
|
18
|
+
This is done using the Quantum Phase Estimation (QPE) algorithm, where the unitary for QPE is the Grover operator, which is composed of the `oracle` and `space_transform` operators.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
oracle: The oracle operator that marks the "good" state. This operator should flip the sign of the amplitude of the "good" state.
|
22
|
+
space_transform: The space transform operator (which is known also the state preparation operator), which is first applied to prepare the state before the QPE, and then used inside the Grover operator.
|
23
|
+
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)$.
|
24
|
+
packed_vars: The variable that holds the state to be estimated. Assumed to be in the zero state at the beginning of the algorithm.
|
25
|
+
"""
|
26
|
+
pass
|
@@ -0,0 +1,68 @@
|
|
1
|
+
from typing import Literal
|
2
|
+
|
3
|
+
from classiq.qmod.cparam import CInt
|
4
|
+
from classiq.qmod.qfunc import qfunc
|
5
|
+
from classiq.qmod.qmod_parameter import CArray, CReal
|
6
|
+
from classiq.qmod.qmod_variable import Output, QArray, QBit, QNum
|
7
|
+
|
8
|
+
|
9
|
+
@qfunc(external=True)
|
10
|
+
def unitary(
|
11
|
+
elements: CArray[CArray[CReal]],
|
12
|
+
target: QArray[QBit, Literal["log(get_field(elements[0], 'len'), 2)"]],
|
13
|
+
) -> None:
|
14
|
+
"""
|
15
|
+
[Qmod core-library function]
|
16
|
+
|
17
|
+
Apply a unitary matrix on a quantum state.
|
18
|
+
|
19
|
+
Args:
|
20
|
+
elements: A 2d array of complex numbers representing the unitary matrix. This matrix must be unitary.
|
21
|
+
target: The quantum state to apply the unitary on. Should be of corresponding size.
|
22
|
+
|
23
|
+
Links: [Reference Manual](https://docs.classiq.io/qmod/builtins/functions/standard_gates/unitary)
|
24
|
+
"""
|
25
|
+
pass
|
26
|
+
|
27
|
+
|
28
|
+
@qfunc(external=True)
|
29
|
+
def add(
|
30
|
+
left: QArray[QBit],
|
31
|
+
right: QArray[QBit],
|
32
|
+
result: Output[
|
33
|
+
QArray[
|
34
|
+
QBit, Literal["Max(get_field(left, 'len'), get_field(right, 'len')) + 1"]
|
35
|
+
]
|
36
|
+
],
|
37
|
+
) -> None:
|
38
|
+
pass
|
39
|
+
|
40
|
+
|
41
|
+
@qfunc(external=True)
|
42
|
+
def modular_add(left: QArray[QBit], right: QArray[QBit]) -> None:
|
43
|
+
pass
|
44
|
+
|
45
|
+
|
46
|
+
@qfunc(external=True)
|
47
|
+
def integer_xor(left: QArray[QBit], right: QArray[QBit]) -> None:
|
48
|
+
pass
|
49
|
+
|
50
|
+
|
51
|
+
@qfunc(external=True)
|
52
|
+
def modular_increment(a: CInt, x: QNum) -> None:
|
53
|
+
"""
|
54
|
+
Qmod Classiq-library function.
|
55
|
+
|
56
|
+
Adds $a$ to $x$ modulo the range of $x$, assumed that $x$ is a non-negative integer and $a$ is an integer.
|
57
|
+
Mathematically it is described as:
|
58
|
+
|
59
|
+
$$
|
60
|
+
x = (x+a)\\ \\mod \\ 2^{x.size}-1
|
61
|
+
$$
|
62
|
+
|
63
|
+
Args:
|
64
|
+
a: A classical integer to be added to x.
|
65
|
+
x: A quantum number that is assumed to be non-negative integer.
|
66
|
+
|
67
|
+
"""
|
68
|
+
pass
|
@@ -0,0 +1,91 @@
|
|
1
|
+
from typing import Literal
|
2
|
+
|
3
|
+
from classiq.qmod.builtins.structs import (
|
4
|
+
FockHamiltonianProblem,
|
5
|
+
MoleculeProblem,
|
6
|
+
)
|
7
|
+
from classiq.qmod.qfunc import qfunc
|
8
|
+
from classiq.qmod.qmod_parameter import CArray, CInt
|
9
|
+
from classiq.qmod.qmod_variable import QArray, QBit
|
10
|
+
|
11
|
+
|
12
|
+
@qfunc(external=True)
|
13
|
+
def molecule_ucc(
|
14
|
+
molecule_problem: MoleculeProblem,
|
15
|
+
excitations: CArray[CInt],
|
16
|
+
qbv: QArray[
|
17
|
+
QBit,
|
18
|
+
Literal[
|
19
|
+
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
|
20
|
+
],
|
21
|
+
],
|
22
|
+
) -> None:
|
23
|
+
pass
|
24
|
+
|
25
|
+
|
26
|
+
@qfunc(external=True)
|
27
|
+
def molecule_hva(
|
28
|
+
molecule_problem: MoleculeProblem,
|
29
|
+
reps: CInt,
|
30
|
+
qbv: QArray[
|
31
|
+
QBit,
|
32
|
+
Literal[
|
33
|
+
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
|
34
|
+
],
|
35
|
+
],
|
36
|
+
) -> None:
|
37
|
+
pass
|
38
|
+
|
39
|
+
|
40
|
+
@qfunc(external=True)
|
41
|
+
def molecule_hartree_fock(
|
42
|
+
molecule_problem: MoleculeProblem,
|
43
|
+
qbv: QArray[
|
44
|
+
QBit,
|
45
|
+
Literal[
|
46
|
+
"get_field(get_field(molecule_problem_to_hamiltonian(molecule_problem)[0], 'pauli'), 'len')"
|
47
|
+
],
|
48
|
+
],
|
49
|
+
) -> None:
|
50
|
+
pass
|
51
|
+
|
52
|
+
|
53
|
+
@qfunc(external=True)
|
54
|
+
def fock_hamiltonian_ucc(
|
55
|
+
fock_hamiltonian_problem: FockHamiltonianProblem,
|
56
|
+
excitations: CArray[CInt],
|
57
|
+
qbv: QArray[
|
58
|
+
QBit,
|
59
|
+
Literal[
|
60
|
+
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
|
61
|
+
],
|
62
|
+
],
|
63
|
+
) -> None:
|
64
|
+
pass
|
65
|
+
|
66
|
+
|
67
|
+
@qfunc(external=True)
|
68
|
+
def fock_hamiltonian_hva(
|
69
|
+
fock_hamiltonian_problem: FockHamiltonianProblem,
|
70
|
+
reps: CInt,
|
71
|
+
qbv: QArray[
|
72
|
+
QBit,
|
73
|
+
Literal[
|
74
|
+
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
|
75
|
+
],
|
76
|
+
],
|
77
|
+
) -> None:
|
78
|
+
pass
|
79
|
+
|
80
|
+
|
81
|
+
@qfunc(external=True)
|
82
|
+
def fock_hamiltonian_hartree_fock(
|
83
|
+
fock_hamiltonian_problem: FockHamiltonianProblem,
|
84
|
+
qbv: QArray[
|
85
|
+
QBit,
|
86
|
+
Literal[
|
87
|
+
"get_field(get_field(fock_hamiltonian_problem_to_hamiltonian(fock_hamiltonian_problem)[0], 'pauli'), 'len')"
|
88
|
+
],
|
89
|
+
],
|
90
|
+
) -> None:
|
91
|
+
pass
|
@@ -0,0 +1,105 @@
|
|
1
|
+
from classiq.qmod.qfunc import qfunc
|
2
|
+
from classiq.qmod.qmod_variable import QArray, QBit, QNum
|
3
|
+
|
4
|
+
|
5
|
+
@qfunc(external=True)
|
6
|
+
def _qct_d_operator(x: QNum, q: QBit) -> None:
|
7
|
+
pass
|
8
|
+
|
9
|
+
|
10
|
+
@qfunc(external=True)
|
11
|
+
def _qct_pi_operator(x: QArray[QBit], q: QBit) -> None:
|
12
|
+
pass
|
13
|
+
|
14
|
+
|
15
|
+
@qfunc(external=True)
|
16
|
+
def qct_qst_type1(x: QArray[QBit]) -> None:
|
17
|
+
r"""
|
18
|
+
Qmod Classiq-library function.
|
19
|
+
|
20
|
+
Applies the quantum discrete cosine (DCT) and sine (DST)
|
21
|
+
transform of type 1 to the qubit array `x`.
|
22
|
+
Corresponds to the matrix (with $n\equiv$`x.len`):
|
23
|
+
|
24
|
+
$$
|
25
|
+
\left(
|
26
|
+
\begin{array}{ccc|c}
|
27
|
+
{} &{} &{} \\
|
28
|
+
{}&{\rm DCT}^{(1)}(2^{n-1}+1) & {}& 0\\
|
29
|
+
{} &{} &{} \\
|
30
|
+
\hline
|
31
|
+
{} & 0 & {} & i{\rm DST}^{(1)}(2^{n-1}-1)
|
32
|
+
\end{array}
|
33
|
+
\right)
|
34
|
+
$$
|
35
|
+
|
36
|
+
Args:
|
37
|
+
x: The qubit array to apply the transform to.
|
38
|
+
|
39
|
+
Links:
|
40
|
+
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
41
|
+
"""
|
42
|
+
pass
|
43
|
+
|
44
|
+
|
45
|
+
@qfunc(external=True)
|
46
|
+
def qct_qst_type2(x: QArray[QBit], q: QBit) -> None:
|
47
|
+
r"""
|
48
|
+
Qmod Classiq-library function.
|
49
|
+
|
50
|
+
Applies the quantum discrete cosine (DCT) and sine (DST)
|
51
|
+
transform of type 2 to the qubit array `x` concatenated with `q`, with `q` being the MSB.
|
52
|
+
Corresponds to the matrix (with $n\equiv$`x.len`+1):
|
53
|
+
|
54
|
+
$$
|
55
|
+
\left(
|
56
|
+
\begin{array}{c|c}
|
57
|
+
{\rm DCT}^{(2)}(2^{n-1}) & 0\\
|
58
|
+
\hline
|
59
|
+
0 & -{\rm DST}^{(2)}(2^{n-1})
|
60
|
+
\end{array}
|
61
|
+
\right)
|
62
|
+
$$
|
63
|
+
|
64
|
+
Args:
|
65
|
+
x: The LSB part of the qubit array to apply the transform to.
|
66
|
+
q: The MSB of the qubit array to apply the transform to.
|
67
|
+
|
68
|
+
Links:
|
69
|
+
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
70
|
+
"""
|
71
|
+
pass
|
72
|
+
|
73
|
+
|
74
|
+
@qfunc(external=True)
|
75
|
+
def qct_type2(x: QArray[QBit]) -> None:
|
76
|
+
r"""
|
77
|
+
Qmod Classiq-library function.
|
78
|
+
|
79
|
+
Applies the quantum discrete cosine (DCT)
|
80
|
+
transform of type 2, ${\rm DCT}^{(2)}$, to the qubit array `x`.
|
81
|
+
|
82
|
+
Args:
|
83
|
+
x: The qubit array to apply the transform to.
|
84
|
+
|
85
|
+
Links:
|
86
|
+
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
87
|
+
"""
|
88
|
+
pass
|
89
|
+
|
90
|
+
|
91
|
+
@qfunc(external=True)
|
92
|
+
def qst_type2(x: QArray[QBit]) -> None:
|
93
|
+
r"""
|
94
|
+
Qmod Classiq-library function.
|
95
|
+
|
96
|
+
Applies the quantum discrete sine (DST)
|
97
|
+
transform of type 2, ${\rm DST}^{(2)}$, to the qubit array `x`.
|
98
|
+
|
99
|
+
Args:
|
100
|
+
x: The qubit array to apply the transform to.
|
101
|
+
|
102
|
+
Links:
|
103
|
+
- [Quantum Sine and Cosine Transforms](https://docs.classiq.io/latest/reference-manual/qmod/library-reference/open-library-functions/qct_qst/qct_qst/)
|
104
|
+
"""
|
105
|
+
pass
|