state#
Quantum states
Classes
|
A quantum state of n qubits distributed between w nodes. |
|
A matrix product state (MPS) for quantum systems. |
|
A quantum state of n qubits, including both pure states and density matrices. |
- class DistributedQubitState(nqubit: int)[source]#
Bases:
ModuleA quantum state of n qubits distributed between w nodes.
- Parameters:
nqubit (int) – The number of qubits in the state.
- class MatrixProductState(nsite: int = 1, state: str | list[Tensor] | list[int] = 'zeros', chi: int | None = None, qudit: int = 2, normalize: bool = True)[source]#
Bases:
ModuleA matrix product state (MPS) for quantum systems.
A matrix product state is a way of representing a quantum state as a product of local tensors. Each tensor has one physical index and one or two bond indices. The physical index corresponds to the local Hilbert space dimension of the qudit, while the bond indices correspond to the entanglement between qudits.
- Parameters:
nsite (int) – The number of sites of the MPS. Default: 1
state (str | list[Tensor] | list[int]) – The representation of the MPS. If
'zeros'or'vac', the MPS is initialized to the all-zero state. If a list of tensors, the MPS is initialized to the given tensors. The tensors must have the correct shape and dtype. If a list of integers, the MPS is initialized to the corresponding basis state. Default:'zeros'chi (int | None) – The maximum bond dimension of the MPS. Default: None (which means 10 *
nsite)qudit (int) – The local Hilbert space dimension of each qudit. Default: 2
normalize (bool) – Whether to normalize the MPS after each operation. Default:
True
- apply_mpo(mpo: list[Tensor], sites: list[int]) None[source]#
Use TEBD algorithm to contract tensors (contract local states with local operators), i.e.,
>>> a >>> | >>> i-----O-----j a >>> | -> | >>> b ik---X---jl >>> | >>> k-----T-----l
- center_orthogonalization(c: int, dc: int = -1, normalize: bool = False) None[source]#
Get the center-orthogonalization form of the MPS with center
c.
- check_center_orthogonality(prt: bool = False) list[Tensor][source]#
Check if the MPS is in center-orthogonal form.
- inner(tensors: list[Tensor] | MatrixProductState, form: str = 'norm') Tensor | list[Tensor][source]#
Get the inner product with another matrix product state.
- orthogonalize_left2right(site: int, dc: int = -1, normalize: bool = False) None[source]#
Orthogonalize the tensor at
siteand update the next one atsite+ 1.It uses the QR decomposition or SVD, i.e., \(T = UR\) for the QR decomposition and \(T = USV^{\dagger} = UR\) for SVD. The tensor at
siteis replaced by \(U\). The tensor atsite+ 1 is updated by \(R\).- Parameters:
site (int) – The site of tensor to be orthogonalized.
dc (int) – Keep the first
dcsingular values after truncation. Default: -1 (which means no truncation)normalize (bool) – Whether to normalize the tensor \(R\). Default:
False
- orthogonalize_n1_n2(n1: int, n2: int, dc: int, normalize: bool) None[source]#
Orthogonalize the MPS from site
n1to siten2.
- orthogonalize_right2left(site: int, dc: int = -1, normalize: bool = False) None[source]#
Orthogonalize the tensor at
siteand update the next one atsite- 1.It uses the QR decomposition or SVD, i.e., \(T^{\dagger} = QR\) for the QR decomposition, which gives \(T = R^{\dagger}Q^{\dagger} = LV^{\dagger}\), and \(T = USV^{\dagger} = LV^{\dagger}\) for SVD. The tensor at
siteis replaced by \(V^{\dagger}\). The tensor atsite- 1 is updated by \(L\).- Parameters:
site (int) – The site of tensor to be orthogonalized.
dc (int) – Keep the first
dcsingular values after truncation. Default: -1 (which means no truncation)normalize (bool) – Whether to normalize the tensor \(L\). Default:
False
- set_tensors(state: str | list[Tensor] | list[int]) None[source]#
Set the tensors of the matrix product state.
- property tensors: list[Tensor]#
Get the tensors of the matrix product state.
Note
This output is provided for reading only. Please modify the tensors through buffers.
- class QubitState(nqubit: int = 1, state: Any = 'zeros', den_mat: bool = False)[source]#
Bases:
ModuleA quantum state of n qubits, including both pure states and density matrices.
- Parameters:
nqubit (int) – The number of qubits in the state. Default: 1
state (Any) – The representation of the state. It can be one of the following strings:
'zeros','equal','entangle','GHZ', or'ghz'. Alternatively, it can be a tensor that represents a custom state vector or density matrix. Default:'zeros'den_mat (bool) – Whether the state is a density matrix or not. Default:
False