microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
brlackey/neutral-atom-models

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/pip/qsharp/noisy_simulator/_noisy_simulator.pyi

242lines · modecode

1# Copyright (c) Microsoft Corporation.
2# Licensed under the MIT License.
3
4from typing import Optional, List, Any
5
6class NoisySimulatorError(BaseException):
7 """
8 EXPERIMENTAL:
9
10 An error returned from the Q# noisy simulator.
11 """
12
13 ...
14
15class Operation:
16 """
17 EXPERIMENTAL:
18
19 This struct represents a quantum operation. A quantum operation is a linear
20 transformation that maps a valid density matrix to another valid density matrices.
21 """
22
23 def __init__(self, kraus_operators: Any) -> None:
24 """
25 Construct an operation from a list of Kraus operators.
26 Matrices must be of dimension 2^k x 2^k, where k is an integer.
27
28 :param kraus_operators: List of Kraus operators. Each operator is a 2D matrix stored as
29 a list of lists of complex numbers, or a numpy array.
30 :type kraus_operators: List[List[List[complex]]]
31 :raises NoisySimulatorError: If the Kraus matrices are ill formed.
32 """
33 ...
34
35 def get_effect_matrix(self) -> List[List[complex]]:
36 r"""
37 Returns effect matrix:
38 $$ (\sum_i K_i^{\dagger} K_i) $$
39 where $K_i$ are Kraus operators.
40 """
41 ...
42
43 def get_operation_matrix(self) -> List[List[complex]]:
44 r"""
45 Return matrix representation:
46 $$ \sum_i K_i \otimes K_{i}* $$
47 where $K_i$ are Kraus operators.
48 """
49 ...
50
51 def get_kraus_operators(self) -> List[List[List[complex]]]:
52 """
53 Return list of Kraus operators.
54 """
55 ...
56
57 def get_number_of_qubits(self) -> int:
58 """
59 Return the number of qubits that the operation acts on.
60 """
61
62class Instrument:
63 """
64 EXPERIMENTAL:
65
66 An instrument is the means by which we make measurements on a quantum system.
67 """
68
69 def __init__(self, operations: List[Operation]) -> None:
70 """
71 Constructs an instrument from a list of operations.
72 """
73 ...
74
75class DensityMatrix:
76 """
77 EXPERIMENTAL:
78
79 A square complex matrix of size 2^k x 2^k representing the state
80 of a quantum system. The data is stored in a linear vector for
81 performance reasons.
82 """
83
84 def data(self) -> List[List[complex]]:
85 """
86 Returns a copy of the matrix data.
87 """
88 ...
89
90 def dimension(self) -> int:
91 """
92 Returns the dimension of the matrix. E.g.: if the matrix is
93 5 x 5, it returns 5.
94 """
95 ...
96
97 def number_of_qubits(self) -> int:
98 """
99 Returns the number of qubits in the system.
100 """
101 ...
102
103class DensityMatrixSimulator:
104 """
105 EXPERIMENTAL:
106
107 A quantum circuit simulator using a density matrix.
108
109 If the simulator reaches an invalid state due to a numerical
110 error, it will raise a `SimulatorException`.
111 """
112
113 def __init__(self, number_of_qubits: int, seed: Optional[int]) -> None:
114 """
115 Creates a new `DensityMatrixSimulator`.
116 """
117 ...
118
119 def apply_operation(self, operation: Operation, qubits: List[int]) -> None:
120 """
121 Apply an operation to the given qubit ids.
122 """
123 ...
124
125 def apply_instrument(self, instrument: Instrument, qubits: List[int]) -> None:
126 """
127 Apply non selective evolution to the given qubit ids.
128 """
129 ...
130
131 def sample_instrument(self, instrument: Instrument, qubits: List[int]) -> int:
132 """
133 Performs selective evolution under the given instrument.
134 Returns the index of the observed outcome.
135
136 Use this method to perform measurements on the quantum system.
137 """
138
139 def get_state(self) -> Optional[DensityMatrix]:
140 """
141 Returns the `DensityMatrix` if the simulator is in a valid state,
142 otherwise returns None.
143 """
144 ...
145
146 def set_state(self, state: DensityMatrix) -> None:
147 """
148 Set state of the quantum system to another `DensityMatrix` of the
149 same dimensions.
150 """
151 ...
152
153 def set_trace(self, trace: float) -> None:
154 """
155 Set trace of the quantum system. That is, the probability of
156 finding the quantum system in the current state. The new trace
157 must be a number between 0 and 1.
158 """
159 ...
160
161class StateVector:
162 """
163 EXPERIMENTAL:
164
165 A vector representing a pure state of a quantum system.
166 """
167
168 def data(self) -> List[complex]:
169 """
170 Returns a copy of the vector data.
171 """
172 ...
173
174 def dimension(self) -> int:
175 """
176 Returns the dimension of the vector.
177 """
178 ...
179
180 def number_of_qubits(self) -> int:
181 """
182 Returns the number of qubits in the system.
183 """
184 ...
185
186class StateVectorSimulator:
187 """
188 EXPERIMENTAL:
189
190 A quantum circuit simulator using a density matrix.
191
192 If the simulator reaches an invalid state due to a numerical
193 error, it will raise a `SimulatorException`.
194 """
195
196 def __init__(self, number_of_qubits: int, seed: Optional[int]) -> None:
197 """
198 Creates a new `DensityMatrixSimulator`.
199 """
200 ...
201
202 def apply_operation(self, operation: Operation, qubits: List[int]) -> None:
203 """
204 Apply an operation to the given qubit ids.
205 """
206 ...
207
208 def apply_instrument(self, instrument: Instrument, qubits: List[int]) -> None:
209 """
210 Apply non selective evolution to the given qubit ids.
211 """
212 ...
213
214 def sample_instrument(self, instrument: Instrument, qubits: List[int]) -> int:
215 """
216 Performs selective evolution under the given instrument.
217 Returns the index of the observed outcome.
218
219 Use this method to perform measurements on the quantum system.
220 """
221
222 def get_state(self) -> Optional[StateVector]:
223 """
224 Returns the `StateVector` if the simulator is in a valid state,
225 otherwise returns None.
226 """
227 ...
228
229 def set_state(self, state: StateVector) -> None:
230 """
231 Set state of the quantum system to another `StateVector` of the
232 same dimensions.
233 """
234 ...
235
236 def set_trace(self, trace: float) -> None:
237 """
238 Set trace of the quantum system. That is, the probability of
239 finding the quantum system in the current state. The new trace
240 must be a number between 0 and 1.
241 """
242 ...
243