QuadraticInt

Struct QuadraticInt 

Source
pub struct QuadraticInt<T> { /* private fields */ }
Expand description

Quadratic integer a + bω, where ω is √D or (1+√D)/2, based on QuadraticIntCoeffs

The different between QuadraticInt and QuadraticSurd is that the operations for the latter will be in normal fields of real numbers or complex numbers, while the operations for the former will be in the quadratic field (specifically in the quadratic integer ring ℤ[ω]). Therefore, the arithmetic operations between QuadraticInts can only be performed with equivalent bases (e.g. √18=3√2 is compatible with √2). However for QuadraticSurd, you can mix the number with different bases if they are both pure quadratic numbers, such as √2 * √3 = √6.

Implementations§

Source§

impl<T: QuadraticBase> QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source

pub fn new(a: T, b: T, r: T) -> Self

Create a quadratic integer from a + b√r, where a, b, r are all integers

Source

pub fn from_coeffs(coeffs: QuadraticIntCoeffs<T>, discr: T) -> Self

Create a quadratic integer a + bω, where ω is √D or (1+√D)/2.

§Panics
  • If the discriminant is negative and feature “complex” is not enabled
  • The discriminant is congruent to 0 modulo 4
Source

pub fn conj(self) -> Self

Source

pub fn norm(self) -> T

Source

pub fn is_rational(&self) -> bool

Source

pub fn is_pure(&self) -> bool

Trait Implementations§

Source§

impl<T: Add<Output = T>> Add<T> for QuadraticInt<T>

Source§

type Output = QuadraticInt<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: QuadraticBase> Add for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for QuadraticInt<T>

Source§

fn clone(&self) -> QuadraticInt<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for QuadraticInt<T>

Source§

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

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

impl<T: QuadraticBase> Div<T> for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: QuadraticBase> Div for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: QuadraticBase> Mul<T> for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: QuadraticBase> Mul for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Neg<Output = T>> Neg for QuadraticInt<T>

Source§

type Output = QuadraticInt<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T: QuadraticBase> One for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl<T: QuadraticBase> PartialEq for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: QuadraticBase> Rem<T> for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> Self::Output

Performs the % operation. Read more
Source§

impl<T: QuadraticBase> Rem for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
Source§

impl<T: Sub<Output = T>> Sub<T> for QuadraticInt<T>

Source§

type Output = QuadraticInt<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: QuadraticBase> Sub for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

type Output = QuadraticInt<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: QuadraticBase> Zero for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T: Copy> Copy for QuadraticInt<T>

Source§

impl<T: QuadraticBase> Eq for QuadraticInt<T>
where for<'r> &'r T: RefNum<T>,

Auto Trait Implementations§

§

impl<T> Freeze for QuadraticInt<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for QuadraticInt<T>
where T: RefUnwindSafe,

§

impl<T> Send for QuadraticInt<T>
where T: Send,

§

impl<T> Sync for QuadraticInt<T>
where T: Sync,

§

impl<T> Unpin for QuadraticInt<T>
where T: Unpin,

§

impl<T> UnwindSafe for QuadraticInt<T>
where T: UnwindSafe,

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.
Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,