use crate::Rational;
use core::ops::Deref;
use malachite_base::named::Named;
use malachite_base::num::basic::traits::{I, NegativeI, NegativeOne, One, OneHalf, Two, Zero};
pub mod arithmetic;
pub mod comparison;
pub mod conversion;
pub mod exhaustive;
pub mod logic;
#[cfg(feature = "random")]
pub mod random;
#[derive(Clone, Default, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub struct GaussianRational {
pub real: Rational,
pub imaginary: Rational,
}
impl Zero for GaussianRational {
const ZERO: Self = Self {
real: Rational::ZERO,
imaginary: Rational::ZERO,
};
}
impl One for GaussianRational {
const ONE: Self = Self {
real: Rational::ONE,
imaginary: Rational::ZERO,
};
}
impl Two for GaussianRational {
const TWO: Self = Self {
real: Rational::TWO,
imaginary: Rational::ZERO,
};
}
impl OneHalf for GaussianRational {
const ONE_HALF: Self = Self {
real: Rational::ONE_HALF,
imaginary: Rational::ZERO,
};
}
impl NegativeOne for GaussianRational {
const NEGATIVE_ONE: Self = Self {
real: Rational::NEGATIVE_ONE,
imaginary: Rational::ZERO,
};
}
impl I for GaussianRational {
const I: Self = Self {
real: Rational::ZERO,
imaginary: Rational::ONE,
};
}
impl NegativeI for GaussianRational {
const NEGATIVE_I: Self = Self {
real: Rational::ZERO,
imaginary: Rational::NEGATIVE_ONE,
};
}
impl_named!(GaussianRational);
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct ComparableGaussianRational(pub GaussianRational);
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub struct ComparableGaussianRationalRef<'a>(pub &'a GaussianRational);
impl ComparableGaussianRational {
pub const fn as_ref(&self) -> ComparableGaussianRationalRef<'_> {
ComparableGaussianRationalRef(&self.0)
}
}
impl Deref for ComparableGaussianRational {
type Target = GaussianRational;
fn deref(&self) -> &GaussianRational {
&self.0
}
}
impl Deref for ComparableGaussianRationalRef<'_> {
type Target = GaussianRational;
fn deref(&self) -> &GaussianRational {
self.0
}
}