use num_complex::Complex;
#[derive(Debug, thiserror::Error, Clone, PartialEq)]
pub enum Error {
#[error("Invalid number of measurements: {0}")]
InvalidNumberOfMeasurements(usize),
#[error("Control qubit index {0} overlaps with target qubit index {1}")]
OverlappingControlAndTargetQubits(usize, usize),
#[error("Invalid number of qubits: {0}")]
InvalidNumberOfQubits(usize),
#[error("Invalid qubit index: {0} for {1} qubits")]
InvalidQubitIndex(usize, usize),
#[error("State vector is not normalised")]
StateVectorNotNormalised,
#[error("Non-unitary matrix")]
NonUnitaryMatrix,
#[error("Unexpected number of inputs: expected {1}, got {0}")]
InvalidNumberOfInputs(usize, usize),
#[error("Mismatched number of parameters: expected {expected}, got {actual}")]
MismatchedNumberOfParameters { expected: usize, actual: usize },
#[error("An unknown error occurred")]
UnknownError,
#[error("OpenCL error: {0}")]
OpenCLError(String),
#[error("Failed to lock GPU context")]
GpuContextLockError,
#[error("Failed to create circuit from macro: {0}")]
CircuitMacroError(String),
#[error("Invalid input value for operation: {0}")]
InvalidInputValue(usize),
#[error("The state cannot be normalised because it has zero norm.")]
ZeroNorm,
#[error("Invalid Pauli String coefficient: {0}")]
InvalidPauliStringCoefficient(Complex<f64>),
}
#[derive(Debug, thiserror::Error, Clone, PartialEq)]
pub enum CompilerError {
#[error("I/O error: {0}")]
IOError(String),
#[error("An unsupported operation was encountered: {0}")]
UnsupportedOperator(String),
#[error("Invalid operands ({0}) for operator {1}")]
InvalidOperands(String, String),
}
#[cfg(feature = "gpu")]
impl From<ocl::Error> for Error {
fn from(err: ocl::Error) -> Self {
Error::OpenCLError(err.to_string())
}
}