use thiserror::Error;
#[derive(Debug, Error, PartialEq)]
pub enum StateError {
#[error("cannot simulate {0} qubits: state vector would be too large (max 20)")]
TooManyQubits(usize),
#[error("qubit index {qubit} is invalid for a {n}-qubit state")]
InvalidQubit {
qubit: usize,
n: usize,
},
#[error("control and target must differ, but both were {0}")]
SameQubits(usize),
#[error(
"unitary must be {expected}x{expected} (2^(n+1) for an n-qubit state), but got {got}x{got}"
)]
UnitarySizeMismatch {
expected: usize,
got: usize,
},
#[error("matrix must be {expected}x{expected}, but got {got}x{got}")]
MatrixSizeMismatch {
expected: usize,
got: usize,
},
#[error("a mixture must contain at least one state")]
EmptyMixture,
#[error("mixture has {states} states but {probs} probabilities")]
MixtureSizeMismatch {
states: usize,
probs: usize,
},
#[error("mixture states must all have {expected} qubits, but found one with {got}")]
QubitCountMismatch {
expected: usize,
got: usize,
},
#[error("mixture probabilities must sum to 1, but summed to {0}")]
ProbabilitiesNotNormalized(f64),
#[error("mixture probabilities must be non-negative")]
NegativeProbability,
#[error("error probability must be in [0, 1], but got {0}")]
InvalidProbability(f64),
}