pub struct Algebraic { /* private fields */ }Expand description
A real algebraic number. See the module documentation.
Implementations§
Source§impl Algebraic
impl Algebraic
pub fn from_i64(n: i64) -> Algebraic
pub fn from_rational(r: Rational) -> Algebraic
Sourcepub fn from_f64(f: f64) -> Option<Algebraic>
pub fn from_f64(f: f64) -> Option<Algebraic>
The exact value of a finite float. None for NaN and the infinities.
Sourcepub fn root_of(p: &Poly, k: usize) -> Option<Algebraic>
pub fn root_of(p: &Poly, k: usize) -> Option<Algebraic>
The k-th real root of p (counting from 1 in increasing order, each distinct root once).
pub fn degree(&self) -> usize
pub fn minimal_polynomial(&self) -> &Poly
Sourcepub fn root_index(&self) -> usize
pub fn root_index(&self) -> usize
Which real root of the minimal polynomial this is, counting from 1 in increasing order.
pub fn to_rational(&self) -> Option<Rational>
pub fn is_zero(&self) -> bool
pub fn signum(&self) -> i32
Sourcepub fn enclosure(&self, bits: u32) -> (Rational, Rational)
pub fn enclosure(&self, bits: u32) -> (Rational, Rational)
A closed interval [lo, hi] holding the value, at most 2^-bits wide; a rational encloses
itself exactly.
pub fn neg(&self) -> Algebraic
pub fn add(&self, o: &Algebraic) -> Algebraic
pub fn sub(&self, o: &Algebraic) -> Algebraic
pub fn mul(&self, o: &Algebraic) -> Algebraic
pub fn recip(&self) -> Option<Algebraic>
pub fn div(&self, o: &Algebraic) -> Option<Algebraic>
Sourcepub fn sqrt(&self) -> Option<Algebraic>
pub fn sqrt(&self) -> Option<Algebraic>
The nonnegative square root; None for a negative number.
Sourcepub fn nth_root(&self, k: u32) -> Option<Algebraic>
pub fn nth_root(&self, k: u32) -> Option<Algebraic>
The real k-th root: the nonnegative one for even k (None for a negative number), the
unique one for odd k. None for k = 0.
Sourcepub fn real_roots(coeffs: &[Algebraic]) -> Vec<(Algebraic, usize)>
pub fn real_roots(coeffs: &[Algebraic]) -> Vec<(Algebraic, usize)>
The distinct real roots of Σ coeffs[i]·x^i, a polynomial with real algebraic coefficients,
in increasing order, each with its multiplicity; none for a constant.
Every root is a root of the polynomial’s norm over the rationals — the product of its
conjugates under every embedding of its coefficients, a tower of resultants against their
minimal polynomials (crate::elimination::Polynomial::resultant) — so the roots are found among the
real roots of the norm’s irreducible factors, each kept when the polynomial vanishes there
exactly.
pub fn floor(&self) -> BigInt
pub fn ceil(&self) -> BigInt
Trait Implementations§
Source§impl ExactCodec for Algebraic
impl ExactCodec for Algebraic
Source§fn write(&self, out: &mut Vec<u8>)
fn write(&self, out: &mut Vec<u8>)
The minimal polynomial, then which of its real roots, counting from 1.
Source§fn read(buf: &[u8], pos: &mut usize) -> Option<Self>
fn read(buf: &[u8], pos: &mut usize) -> Option<Self>
Refused unless the polynomial is primitive with a positive lead, of degree at most
crate::exact_codec::MAX_WIRE_DEGREE, irreducible, and has that many real roots.
fn to_bytes(&self) -> Vec<u8> ⓘ
Source§fn from_bytes(buf: &[u8]) -> Option<Self>
fn from_bytes(buf: &[u8]) -> Option<Self>
buf canonically encodes, with nothing left over.