use axiolid_guarantees::Sign;
use crate::dyadic::Dyadic;
pub trait Arith: Clone {
fn from_f64(value: f64) -> Self;
fn from_dyadic(value: &Dyadic) -> Self;
#[must_use]
fn add(&self, other: &Self) -> Self;
#[must_use]
fn sub(&self, other: &Self) -> Self;
#[must_use]
fn mul(&self, other: &Self) -> Self;
#[must_use]
fn neg(&self) -> Self;
fn sign(&self) -> Option<Sign>;
fn sqrt_enclosure(&self) -> Option<Self> {
None
}
#[must_use]
fn square(&self) -> Self {
self.mul(self)
}
}
#[must_use]
pub(crate) fn sign_product(left: Sign, right: Sign) -> Sign {
match right {
Sign::Positive => left,
Sign::Negative => left.flip(),
_ => Sign::Zero,
}
}