| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| use num_complex::Complex64; |
| use std::f64::consts::PI; |
|
|
| pub mod hamiltonian; |
| pub mod vqe; |
| pub mod qaoa; |
| pub mod hamiltonian_sim; |
| pub mod amplitude_est; |
| pub mod walks; |
| pub mod shor; |
|
|
| pub use hamiltonian::*; |
| pub use vqe::*; |
| pub use qaoa::*; |
| pub use hamiltonian_sim::*; |
| pub use amplitude_est::*; |
| pub use walks::*; |
| pub use shor::*; |
|
|
| |
| pub type AlgorithmResult<T> = Result<T, AlgorithmError>; |
|
|
| |
| #[derive(Debug, Clone)] |
| pub enum AlgorithmError { |
| |
| InvalidParameters(String), |
|
|
| |
| ConvergenceFailed(String), |
|
|
| |
| InvalidState(String), |
|
|
| |
| NumericalError(String), |
|
|
| |
| InvalidGraph(String), |
|
|
| |
| MathematicalError(String), |
| } |
|
|
| impl std::fmt::Display for AlgorithmError { |
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| match self { |
| AlgorithmError::InvalidParameters(msg) => write!(f, "Invalid parameters: {}", msg), |
| AlgorithmError::ConvergenceFailed(msg) => write!(f, "Convergence failed: {}", msg), |
| AlgorithmError::InvalidState(msg) => write!(f, "Invalid state: {}", msg), |
| AlgorithmError::NumericalError(msg) => write!(f, "Numerical error: {}", msg), |
| AlgorithmError::InvalidGraph(msg) => write!(f, "Invalid graph: {}", msg), |
| AlgorithmError::MathematicalError(msg) => write!(f, "Mathematical error: {}", msg), |
| } |
| } |
| } |
|
|
| impl std::error::Error for AlgorithmError {} |
|
|
| |
|
|