quairkit.core.state.state

Common functions for the State class.

quairkit.core.state.state.to_state(data, system_dim=2, eps=0.0001, backend=None, prob=None)

The function to generate a specified state instance.

Parameters:
data : Tensor | ndarray | State | List[OperatorInfoType] | None

a representation of the quantum state in allowable backend, or an instance of the State class.

system_dim : int | List[int]

(list of) dimension(s) of the systems, can be a list of integers or an integer. For example, system_dim = 2 means the systems are qubits (default setup); system_dim = [2, 3] means the first system is a qubit and the second is a qutrit.

eps : float | None

The tolerance for checking the validity of the input state. Can be adjusted to None to disable the check.

backend : str | None

The name of the backend to use. If not specified, the default backend will be used.

prob : List[Tensor] | None

The (list of) probability distribution of the state. The length of the list denotes the number of distributions.

Returns:

The generated quantum state.

Return type:

DefaultSimulator | State

quairkit.core.state.state.tensor_state(state_1st, *args)

calculate tensor product (kronecker product) between at least two state. This function automatically returns State instance

Parameters:
state_1st : StateSimulator

the first state

args : StateSimulator

other states

Returns:

tensor product state of input states

Return type:

StateSimulator

Note

Need to be careful with the backend of states; Support broadcasting for batch states. Use quairkit.linalg.nkron if the input datatype is torch.Tensor or numpy.ndarray.