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>
impl<T: QuadraticBase> QuadraticInt<T>
Sourcepub fn new(a: T, b: T, r: T) -> Self
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
Sourcepub fn from_coeffs(coeffs: QuadraticIntCoeffs<T>, discr: T) -> Self
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
pub fn conj(self) -> Self
pub fn norm(self) -> T
pub fn is_rational(&self) -> bool
pub fn is_pure(&self) -> bool
Trait Implementations§
Source§impl<T: Add<Output = T>> Add<T> for QuadraticInt<T>
impl<T: Add<Output = T>> Add<T> for QuadraticInt<T>
Source§impl<T: QuadraticBase> Add for QuadraticInt<T>
impl<T: QuadraticBase> Add for QuadraticInt<T>
Source§impl<T: Clone> Clone for QuadraticInt<T>
impl<T: Clone> Clone for QuadraticInt<T>
Source§fn clone(&self) -> QuadraticInt<T>
fn clone(&self) -> QuadraticInt<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more