1#[derive(thiserror::Error, Debug, PartialEq)]
2pub enum IntegrationError<T> {
4 #[error("Integral is highly oscillatory.")]
5 OscillatoryIntegrand,
6 #[error("Possible singularity near {singularity:?}")]
7 PossibleSingularity { singularity: T },
8 #[error("Reached maximum iterations.")]
9 HitMaxIterations,
10 #[error("The integrator has no solution")]
11 NoSolution,
12 #[error("The integrand is not finite at the probed value")]
13 NonFinite,
14}
15
16impl<T> From<EvaluationError<T>> for IntegrationError<T> {
17 fn from(e: EvaluationError<T>) -> Self {
18 match e {
19 EvaluationError::PossibleSingularity { singularity } => {
20 IntegrationError::PossibleSingularity { singularity }
21 }
22 EvaluationError::NonFinite => IntegrationError::NonFinite,
23 }
24 }
25}
26
27#[derive(thiserror::Error, Debug)]
28pub enum EvaluationError<I> {
29 #[error("Possible singularity near {singularity:?}")]
30 PossibleSingularity { singularity: I },
31 #[error("non-finite integrand")]
32 NonFinite,
33}
34
35impl<R: num_traits::Zero> EvaluationError<R> {
36 pub(crate) fn into_complex(self) -> EvaluationError<num_complex::Complex<R>> {
37 match self {
38 EvaluationError::PossibleSingularity { singularity } => {
39 EvaluationError::PossibleSingularity {
40 singularity: num_complex::Complex::new(singularity, R::zero()),
41 }
42 }
43 EvaluationError::NonFinite => EvaluationError::NonFinite,
44 }
45 }
46}