qcheff.operators.utils¶
Module Contents¶
Functions¶
Identity operator in sparse format with the same shape as A. |
|
Commutator of two operators. |
|
Tensor product of two operators. |
|
Tensor product of multiple operators. |
|
Identity wrapping for the appropriate operator. |
|
An iterator that enumerates all the state number tuples (quantum numbers of the form (n1, n2, n3, …)) for a system with dimensions given by dims. |
|
Return the index of a quantum state corresponding to state, given a system with dimensions given by dims. |
|
Return a quantum number representation given a state index, for a system of composite structure defined by dims. |
API¶
- eye_like(A)¶
Identity operator in sparse format with the same shape as A.
Parameters
A : array_like Operator
Returns
identity_operator : array_like Identity operator in sparse format with the same shape as A
- commutator(A, B, kind='normal')¶
Commutator of two operators.
Parameters
A : array_like First operator B : array_like Second operator kind : str, optional Kind of commutator. Can be ‘normal’ or ‘anti’ (default is ‘normal’)
Returns
commutator : array_like Commutator of two operators
- tensor2(A, B)¶
Tensor product of two operators.
Parameters
A : array_like First operator B : array_like Second operator
Returns
tensor_product : array_like Tensor product of two operators
- tensor(*args)¶
Tensor product of multiple operators.
Parameters
*args : array_like Operators
Returns
tensor_product : array_like Tensor product of multiple operators
- embed_operator(op, pos: int, system_dims: tuple[int, ...])¶
Identity wrapping for the appropriate operator.
Parameters
op : ndarray The operator to be wrapped. Ideally, it should have dimensions=ntrunc pos : int The position of the operator system_dims : tuple[int, …] The dimensions of the system
Returns
wrapped_operator : array_like The wrapped operator
- state_number_enumerate(dims, excitations=None)¶
An iterator that enumerates all the state number tuples (quantum numbers of the form (n1, n2, n3, …)) for a system with dimensions given by dims.
Example:
>>> for state in state_number_enumerate([2,2]): # doctest: +SKIP >>> print(state) # doctest: +SKIP ( 0 0 ) ( 0 1 ) ( 1 0 ) ( 1 1 )
Parameters
dims : list or array The quantum state dimensions array, as it would appear in a QuTiP Qobj.
excitations : integer, optional Restrict state space to states with excitation numbers below or equal to this value.
Returns
state_number : tuple Successive state number tuples that can be used in loops and other iterations, using standard state enumeration by definition.
- state_number_index(dims, state)¶
Return the index of a quantum state corresponding to state, given a system with dimensions given by dims.
Example:
>>> state_number_index([2, 2, 2], [1, 1, 0]) 6
Parameters
dims : list or array The quantum state dimensions array, as it would appear in a QuTiP Qobj.
state : list State number array.
Returns
idx : int The index of the state given by
statein standard enumeration ordering.
- state_index_number(dims, index)¶
Return a quantum number representation given a state index, for a system of composite structure defined by dims.
Example:
>>> state_index_number([2, 2, 2], 6) [1, 1, 0]
Parameters
dims : list or array The quantum state dimensions array, as it would appear in a Qobj.
index : integer The index of the state in standard enumeration ordering.
Returns
state : tuple The state number tuple corresponding to index
indexin standard enumeration ordering.