Undocumented
Function | avg |
Returns average photon number of state for each qumode within the circuit using the number operator. |
Function | counts |
Convert counts dictionary from Fock-basis binary representation into base-10 Fock basis (qubit measurements are left unchanged). Accepts the object returned by jobs.result(), along with the entire circuit. |
Function | cv |
Simulate a circuit with an appended binary search for boson number, and determine the Fock state of a set of qumodes using phase kickback on the qubit. For more information, see Curtis et al., PRA (2021) and Wang et al... |
Function | cv |
Return reduced density matrix over the given Qiskit Qubits. |
Function | flatten |
Undocumented |
Function | fockmap |
Generates matrix corresponding to some specified mapping of Fock states for a single qumode. First feed function empty matrix, then call fmap_matrix however many times needed to fully define intended mapping... |
Function | get |
Calculate the probabilities for each of the result's counts. |
Function | measure |
Use QuantumCircuit.measure_all() to measure all qubits in the X, Y, and Z basis. |
Function | qumode |
Returns average photon number of an individual qumode's state using the number operator. |
Function | simulate |
Convenience function to simulate using the given backend. |
Function | stateread |
Print values for states of qubits and qumodes using the result of a simulation of the statevector, e.g. using stateop, _, _, _ = c2qa.util.simulate(circuit). |
Function | trace |
Return reduced density matrix of the cavities by tracing out the all qubits of the CVCircuit from the given Fock state vector. |
Function | trace |
Return reduced density matrix of the qubits by tracing out the cavities of the CVCircuit from the given Fock state vector. |
Function | _final |
Return the measurement mapping for the circuit. |
Function | _final |
Return the classical bits that active qumode qubits are mapped onto. Bits corresponding to distinct qumodes are grouped together |
Function | _find |
Return the indices of the cavities from the circuit |
Function | _find |
Return the indices of the qubits from the circuit that are not in a QumodeRegister |
Returns average photon number of state for each qumode within the circuit using the number operator.
Parameters | |
circuit:CVCircuit | Circuit definine qumodes present in given state |
state:Statevector or DensityMatrix | full state to operate on |
decimals:int | Determines precision of calculation |
Returns | |
float | Average photon number to specified precision |
CVCircuit
, result: qiskit.result.result.Result
, counts: dict
= None):
(source)
¶
Convert counts dictionary from Fock-basis binary representation into base-10 Fock basis (qubit measurements are left unchanged). Accepts the object returned by jobs.result(), along with the entire circuit.
Parameters | |
circuit:CVCircuit | CVCircuit |
result:qiskit.result.result.Result | dict() of results, as returned by job.result(), for a circuit which used cv_measure() |
counts:dict | Undocumented |
Returns | |
A new counts dict() which lists measurement results for the qubits and qumodes in circuit in little endian order, with Fock-basis qumode measurements reported as a base-10 integer. |
Simulate a circuit with an appended binary search for boson number, and determine the Fock state of a set of qumodes using phase kickback on the qubit. For more information, see Curtis et al., PRA (2021) and Wang et al., PRX (2020).
Returns the Fock state of the qumodes in list_qumodes_to_sample, in qumode register qmr_number.
Return reduced density matrix over the given Qiskit Qubits.
First find the indices of the given Qubits, then call qiskit.quantum_info.partial_trace
Parameters | |
circuit:CVCircuit | circuit with results to trace (to find Qubit index) |
stateStatevector or DensityMatrix | simulation results to trace over |
qubits:list | list of Qiskit Qubit to trace over |
Returns | |
DensityMatrix | partial trace |
Generates matrix corresponding to some specified mapping of Fock states for a single qumode. First feed function empty matrix, then call fmap_matrix however many times needed to fully define intended mapping. Maps ith element in fock_input to ith element in fock_output with amplitude specified by ith element in amplitude. If amplitude is left blank, function assumes amp = 1 for all mappings.
Two use cases 1) int + list datatype combination (length of amp list must match length of either fock_input or fock_output, whichever is longer): >fockmap(matrix, 1, [0, 1]) ->> |0><1| + |1><1|
>fockmap(matrix, [3, 2], 0, [0.5j, 1]) ->> 0.5j|0><3| + |0><2|
2) list datatype >fockmap(matrix, [3, 2], [2, 1], [0.1j, 0.8]) ->> 0.1j|2><3| + 0.8|1><2|
>fockmap(matrix, [1, 1], [2, 4]) ->> |2><1| + |4><1|
Parameters | |
matrix:nested list/np.array | Matrix that you want to change |
fock | Input state(s) for mapping, corresponds to bra |
fock | Output states(s) for mapping, corresponds to ket |
amplitude:int/float/complex/list/ndarray | Amplitudes corresponding to final mapped states |
Returns | |
np.array | Edited matrix |
Calculate the probabilities for each of the result's counts.
Parameters | |
result:qiskit.result.Result | QisKit result to calculate probabilities from |
Returns | |
dict | probablity dictionary of each state |
Use QuantumCircuit.measure_all() to measure all qubits in the X, Y, and Z basis.
Returns state, result, fockcounts tuples each for the X, Y, and Z basis.
Parameters | |
circuit:qiskit.QuantumCircuit | circuit to measure qubits one |
Returns | |
x , y , z state & result tuples | (state, result, fockcounts) tuples for each x,y,z measurements |
CVCircuit
, shots: int
= 1024, return_fockcounts: bool
= True, add_save_statevector: bool
= True, conditional_state_vector: bool
= False, per_shot_state_vector: bool
= False, noise_model=None, noise_passes=None, max_parallel_threads: int
= 0, discretize: bool
= False):
(source)
¶
Convenience function to simulate using the given backend.
Handles calling into QisKit to simulate circuit using defined simulator.
Parameters | |
cvcircuit:CVCircuit | Undocumented |
shots:int , optional | Number of simulation shots. Defaults to 1024. |
returnbool , optional | Set to True if measurement results should be returned. Defaults to False |
addbool , optional | Set to True if a state_vector instruction should be added to the end of the circuit. Defaults to True. |
conditionalbool , optional | Set to True if the saved state vector should be contional (each state value gets its own state vector). Defaults to False. |
perbool , optional | Set to Ture if the simulation should return a separate state vector for every simulation shot. |
noiseNoiseModel , optional | Custom noise model to pass into AerSimulator to use on each simulation shot |
noiselist of LocalNoisePass , optional | Custom noise pass to apply on each gate. |
maxint , opational | Sets the maximum number of CPU cores used by OpenMP for parallelization. If set to 0 the maximum will be set to the number of CPU cores (Default: 0). |
discretize:bool , optional | Set to True if circuit should be discretized to apply noise passes. Defaults to False. |
circuit:CVCircuit | circuit to simulate |
Returns | |
tuple | (state, result, fock_counts) tuple from [optionally discretized] simulations |
Print values for states of qubits and qumodes using the result of a simulation of the statevector, e.g. using stateop, _, _, _ = c2qa.util.simulate(circuit).
Returns the states of the qubits and the Fock states of the qumodes with respective amplitudes.
Return reduced density matrix of the cavities by tracing out the all qubits of the CVCircuit from the given Fock state vector.
Parameters | |
circuit:CVCircuit | circuit with results to trace (to find Qubit index) |
stateStatevector or DensityMatrix | simulation results to trace over |
Returns | |
DensityMatrix | partial trace |
Return reduced density matrix of the qubits by tracing out the cavities of the CVCircuit from the given Fock state vector.
Parameters | |
circuit:CVCircuit | circuit yielding the results to trace over |
stateStatevector | simulation results to trace over |
Returns | |
DensityMatrix | density matrix of the qubits from a partial trace over the cavities |
Return the measurement mapping for the circuit.
Dict keys label classical bits, whereas the values indicate the physical qubits that are measured to produce those bit values.
Parameters | |
circuit:QuantumCircuit | Input Qiskit QuantumCircuit. |
Returns | |
dict | Mapping of classical bits to qubits for final measurements. |
Return the classical bits that active qumode qubits are mapped onto. Bits corresponding to distinct qumodes are grouped together