use crate::{error::SemiflowError, float::SemiflowFloat};
#[inline]
pub(crate) fn validate_tau_f64(tau: f64) -> Result<(), SemiflowError> {
if !tau.is_finite() || tau < 0.0 {
return Err(SemiflowError::DomainViolation {
what: "tau must be finite and >= 0",
value: tau,
});
}
Ok(())
}
#[inline]
pub(crate) fn validate_a_x_f64(a_x: f64, x: f64) -> Result<(), SemiflowError> {
if !a_x.is_finite() || a_x < 0.0 {
return Err(SemiflowError::DomainViolation {
what: "a(x) must be finite and >= 0 (strict ellipticity required for sqrt)",
value: x,
});
}
Ok(())
}
#[inline]
pub(crate) fn validate_tau_generic<F: SemiflowFloat>(tau: F) -> Result<(), SemiflowError> {
if !tau.is_finite() || tau < F::zero() {
return Err(SemiflowError::DomainViolation {
what: "tau must be finite and >= 0",
value: tau.to_f64().unwrap_or(f64::NAN),
});
}
Ok(())
}
#[inline]
pub(crate) fn validate_a_x_generic<F: SemiflowFloat>(a_x: F, x: F) -> Result<(), SemiflowError> {
if !a_x.is_finite() || a_x < F::zero() {
return Err(SemiflowError::DomainViolation {
what: "a(x) must be finite and >= 0 (strict ellipticity required for sqrt)",
value: x.to_f64().unwrap_or(f64::NAN),
});
}
Ok(())
}