Density matrix utility functions for simulator
numqi.sim.dm
numqi.sim.dm.new_base(num_qubit, dtype=np.complex128)
return the base density matrix of the qubit quantum system
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_qubit
|
int
|
the number of qubits |
required |
dtype
|
dtype
|
the data type of the base state |
complex128
|
Returns:
Name | Type | Description |
---|---|---|
ret |
ndarray
|
the base state, |
numqi.sim.dm.apply_gate(dm, op, index)
apply a gate to the density matrix
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dm
|
ndarray
|
the density matrix, |
required |
op
|
ndarray
|
the gate, |
required |
index
|
int | tuple[int]
|
the qubit index to apply the gate, |
required |
Returns:
Name | Type | Description |
---|---|---|
ret |
ndarray
|
the density matrix after applying the gate |
numqi.sim.dm.operator_expectation(dm0, op, index)
calculate the expectation value of an operator
TODO multiple operators
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dm0
|
ndarray
|
the density matrix, |
required |
op
|
ndarray
|
the operator, |
required |
index
|
int | tuple[int]
|
the qubit index to apply the operator |
required |
Returns:
Name | Type | Description |
---|---|---|
ret |
ndarray
|
the expectation value |