malachite-nz 0.13.0

The bignum types Natural and Integer, with efficient algorithms partially derived from GMP and FLINT.
Documentation
// Copyright © 2026 Mikhail Hogrefe
//
// This file is part of Malachite.
//
// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.

/// Implementations of [`Ord`] and [`PartialOrd`] for
/// [`ComparableGaussianInteger`](crate::gaussian_integer::ComparableGaussianInteger) and
/// [`ComparableGaussianIntegerRef`](crate::gaussian_integer::ComparableGaussianIntegerRef),
/// ordering [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)s lexicographically: first
/// by real part, then by imaginary part.
pub mod cmp;
/// Implementations of [`OrdAbs`](malachite_base::num::comparison::traits::OrdAbs) and
/// [`PartialOrdAbs`](malachite_base::num::comparison::traits::PartialOrdAbs) for
/// [`GaussianInteger`](crate::gaussian_integer::GaussianInteger), comparing absolute values
/// (distances from the origin).
pub mod cmp_abs;
/// Implementations of [`PartialOrdAbs`](malachite_base::num::comparison::traits::PartialOrdAbs) for
/// comparing the absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)
/// and an [`Integer`](crate::integer::Integer).
pub mod cmp_abs_integer;
/// Implementations of [`PartialOrdAbs`](malachite_base::num::comparison::traits::PartialOrdAbs) for
/// comparing the absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)
/// and a [`Natural`](crate::natural::Natural).
pub mod cmp_abs_natural;
/// Implementations of [`PartialOrdAbs`](malachite_base::num::comparison::traits::PartialOrdAbs) for
/// comparing the absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)
/// and a primitive float.
///
/// # partial_cmp_abs
/// ```
/// use malachite_base::num::basic::traits::NegativeInfinity;
/// use malachite_base::num::comparison::traits::PartialOrdAbs;
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// // |3+4i| = 5
/// let x = GaussianInteger::from_str("3+4i").unwrap();
/// assert!(x.gt_abs(&-4.5f32));
/// assert!(x.lt_abs(&5.5f32));
/// assert!(x.lt_abs(&f32::NEGATIVE_INFINITY));
/// assert_eq!(x.partial_cmp_abs(&f32::NAN), None);
///
/// assert!((-4.5f32).lt_abs(&x));
/// assert!(5.5f32.gt_abs(&x));
/// assert!(f32::NEGATIVE_INFINITY.gt_abs(&x));
/// ```
pub mod cmp_abs_primitive_float;
/// Implementations of [`PartialOrdAbs`](malachite_base::num::comparison::traits::PartialOrdAbs) for
/// comparing the absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)
/// and a primitive integer.
///
/// # partial_cmp_abs
/// ```
/// use malachite_base::num::comparison::traits::PartialOrdAbs;
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// // |3+4i| = 5
/// let x = GaussianInteger::from_str("3+4i").unwrap();
/// assert!(x.gt_abs(&4u32));
/// assert!(x.ge_abs(&5u32));
/// assert!(x.le_abs(&5u32));
/// assert!(x.lt_abs(&6u32));
/// assert!(x.gt_abs(&-4i32));
/// assert!(x.lt_abs(&-6i32));
///
/// assert!(4u32.lt_abs(&x));
/// assert!(6u32.gt_abs(&x));
/// assert!((-4i32).lt_abs(&x));
/// assert!((-6i32).gt_abs(&x));
/// ```
pub mod cmp_abs_primitive_int;
/// An implementation of [`EqAbs`](malachite_base::num::comparison::traits::EqAbs) for
/// [`GaussianInteger`](crate::gaussian_integer::GaussianInteger), comparing absolute values
/// (distances from the origin) for equality.
pub mod eq_abs;
/// Implementations of [`EqAbs`](malachite_base::num::comparison::traits::EqAbs) for comparing the
/// absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger) and an
/// [`Integer`](crate::integer::Integer) for equality.
pub mod eq_abs_integer;
/// Implementations of [`EqAbs`](malachite_base::num::comparison::traits::EqAbs) for comparing the
/// absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger) and a
/// [`Natural`](crate::natural::Natural) for equality.
pub mod eq_abs_natural;
/// Implementations of [`EqAbs`](malachite_base::num::comparison::traits::EqAbs) for comparing the
/// absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger) and a
/// primitive float for equality.
///
/// # eq_abs
/// ```
/// use malachite_base::num::comparison::traits::EqAbs;
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// // |3+4i| = 5
/// let x = GaussianInteger::from_str("3+4i").unwrap();
/// assert!(x.eq_abs(&-5.0f32));
/// assert_eq!(x.eq_abs(&4.0f32), false);
/// assert_eq!(x.eq_abs(&f32::NAN), false);
///
/// assert!((-5.0f32).eq_abs(&x));
/// assert_eq!(4.0f32.eq_abs(&x), false);
/// ```
pub mod eq_abs_primitive_float;
/// Implementations of [`EqAbs`](malachite_base::num::comparison::traits::EqAbs) for comparing the
/// absolute values of a [`GaussianInteger`](crate::gaussian_integer::GaussianInteger) and a
/// primitive integer for equality.
///
/// # eq_abs
/// ```
/// use malachite_base::num::comparison::traits::EqAbs;
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// // |3+4i| = 5
/// let x = GaussianInteger::from_str("3+4i").unwrap();
/// assert!(x.eq_abs(&5u32));
/// assert_eq!(x.eq_abs(&4u32), false);
/// assert!(x.eq_abs(&-5i32));
///
/// assert!(5u32.eq_abs(&x));
/// assert!((-5i32).eq_abs(&x));
/// assert_eq!(4u32.eq_abs(&x), false);
/// ```
pub mod eq_abs_primitive_int;
/// Equality of [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)s and
/// [`Integer`](crate::integer::Integer)s.
pub mod partial_eq_integer;
/// Equality of [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)s and
/// [`Natural`](crate::natural::Natural)s.
pub mod partial_eq_natural;
/// Equality of [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)s and primitive floats.
///
/// # partial_eq
/// ```
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// assert!(GaussianInteger::from(123) == 123.0f32);
/// assert!(GaussianInteger::from(123) != -5.0f32);
/// assert!(GaussianInteger::from_str("123+i").unwrap() != 123.0f32);
///
/// assert!(123.0f32 == GaussianInteger::from(123));
/// assert!(-5.0f32 != GaussianInteger::from(123));
/// ```
pub mod partial_eq_primitive_float;
/// Equality of [`GaussianInteger`](crate::gaussian_integer::GaussianInteger)s and primitive
/// integers.
///
/// # partial_eq
/// ```
/// use malachite_nz::gaussian_integer::GaussianInteger;
/// use std::str::FromStr;
///
/// assert!(GaussianInteger::from(123) == 123u64);
/// assert!(GaussianInteger::from(-123) != 123u64);
/// assert!(GaussianInteger::from_str("123+i").unwrap() != 123u64);
///
/// assert!(123u64 == GaussianInteger::from(123));
/// assert!(123u64 != GaussianInteger::from(-123));
///
/// assert!(-123i64 == GaussianInteger::from(-123));
/// assert!(23i64 != GaussianInteger::from(123));
/// ```
pub mod partial_eq_primitive_int;