Skip to main content

IntegerDomain

Struct IntegerDomain 

Source
pub struct IntegerDomain;
Expand description

The integer domain.

§Example

use ocas_domain::{Domain, Integer, IntegerDomain};

let domain = IntegerDomain;
let a = Integer::from(3);
let b = Integer::from(5);
assert_eq!(domain.add(&a, &b), Integer::from(8));

Trait Implementations§

Source§

impl Clone for IntegerDomain

Source§

fn clone(&self) -> IntegerDomain

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for IntegerDomain

Source§

impl Debug for IntegerDomain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Domain for IntegerDomain

Available on non-crate feature gmp only.
Source§

type Element = Integer

The type of elements in the domain.
Source§

fn zero(&self) -> Self::Element

The additive identity.
Source§

fn one(&self) -> Self::Element

The multiplicative identity.
Source§

fn add(&self, a: &Self::Element, b: &Self::Element) -> Self::Element

Add two elements.
Source§

fn sub(&self, a: &Self::Element, b: &Self::Element) -> Self::Element

Subtract b from a.
Source§

fn neg(&self, a: &Self::Element) -> Self::Element

Negate an element.
Source§

fn mul(&self, a: &Self::Element, b: &Self::Element) -> Self::Element

Multiply two elements.
Source§

fn div(&self, a: &Self::Element, b: &Self::Element) -> Option<Self::Element>

Divide a by b. Read more
Source§

fn inv(&self, a: &Self::Element) -> Option<Self::Element>

Return the multiplicative inverse of a. Read more
Source§

fn is_zero(&self, a: &Self::Element) -> bool

Test whether an element is the additive identity.
Source§

fn is_one(&self, a: &Self::Element) -> bool

Test whether an element is the multiplicative identity.
Source§

fn mul_assign(&self, a: &mut Self::Element, b: &Self::Element)

In-place multiply: *a *= b. Read more
Source§

fn sub_mul_assign( &self, a: &mut Self::Element, b: &Self::Element, c: &Self::Element, )

Fused subtract-multiply: *a -= b * c. Read more
Source§

fn pow(&self, a: &Self::Element, n: u64) -> Self::Element

Return a raised to the non-negative integer power n. Read more
Source§

fn cast_u64(&self, n: u64) -> Self::Element

Convert a u64 into an element of the domain. Read more
Source§

impl Eq for IntegerDomain

Source§

impl EuclideanDomain for IntegerDomain

Available on non-crate feature gmp only.
Source§

fn div_rem( &self, a: &Self::Element, b: &Self::Element, ) -> Option<(Self::Element, Self::Element)>

Divide a by b returning (quotient, remainder). Read more
Source§

fn gcd(&self, a: &Self::Element, b: &Self::Element) -> Self::Element

Compute the greatest common divisor of a and b. Read more
Source§

fn extended_gcd( &self, a: &Self::Element, b: &Self::Element, ) -> (Self::Element, Self::Element, Self::Element)

Compute the extended GCD: returns (g, x, y) such that g = gcd(a, b) = a*x + b*y. Read more
Source§

impl PartialEq for IntegerDomain

Source§

fn eq(&self, other: &IntegerDomain) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IntegerDomain

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.