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