__init__(
state: NDArray[complexfloating],
num_qubits: int,
local_dim: int = 2,
) -> None
Initialize a State object which represents a quantum state.
Parameter state: The state vector to initialize the state with.
Precondition: state is a numpy array.
Parameter num_qubits: The number of qubits the state is defined on.
Precondition: num_qubits is a non-negative integer.
Parameter local_dim: The local dimension of the state.
Precondition: local_dim is a positive integer.
Source code in shadowsim/core/state.py
| def __init__(self, state: npt.NDArray[np.complexfloating], num_qubits: int, local_dim: int = 2) -> None:
"""Initialize a State object which represents a quantum state.
Parameter state: The state vector to initialize the state with.
Precondition: state is a numpy array.
Parameter num_qubits: The number of qubits the state is defined on.
Precondition: num_qubits is a non-negative integer.
Parameter local_dim: The local dimension of the state.
Precondition: local_dim is a positive integer.
"""
assert num_qubits >= 0, "num_qubits must be non-negative"
assert isinstance(num_qubits, int), "num_qubits must be an integer"
assert local_dim > 0, "local_dim must be a positive integer"
assert isinstance(local_dim, int), "local_dim must be an integer"
self._num_qubits = num_qubits
self._local_dim = local_dim
self.state = _as_valid_state_vector(state, self._num_qubits, self._local_dim)
|