Struct Polynomial

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

多项式

Implementations§

Source§

impl<T: Clone> Polynomial<T>

Source

pub fn new(coe: &Vec<T>) -> Self

Source

pub fn get_coe(&self) -> &Vec<T>

Source

pub fn get_coe_mut(&mut self) -> &mut Vec<T>

Source

pub fn multiply_by<U, V>(&self, num: U, degree: usize) -> Polynomial<V>
where T: Mul<U, Output = V>, U: Clone, V: Clone + Zero,

(ax^2+bx-c).multiply_by(d, e) => adx^(2+e)+bdx^(1+e)-cdx^e

Source

pub fn multiply_left_by<U, V>(&self, num: U, degree: usize) -> Polynomial<V>
where U: Clone + Mul<T, Output = V>, V: Clone + Zero,

(ax^2+bx-c).multiply_left_by(d, e) => dax^(2+e)+dbx^(1+e)-dcx^e

Source

pub fn divide_by<U, V>(&self, num: U) -> Polynomial<V>
where T: Div<U, Output = V>, U: Clone, V: Clone,

(ax^2+bx-c).divide_by(d) => a/dx^2+b/dx-c/d

Source

pub fn divide_left_by<U, V>(&self, num: U) -> Polynomial<V>
where T: DivLeft<U, Output = V>, U: Clone, V: Clone,

(ax^2+bx-c).divide_left_by(d) => a\dx^2+b\dx-c\d

Source

pub fn value<U, V>(&self, num: U) -> V
where T: Mul<U, Output = V>, U: Clone + Mul<Output = U> + One, V: Clone + Add<Output = V>,

(ax^2+bx+c).value(n) = an^2+bn+c

Source

pub fn value_left<U, V>(&self, num: U) -> V
where U: Clone + Mul<Output = U> + Mul<T, Output = V> + One, V: Clone + Add<Output = V>,

(ax^2+bx+c).value_left(n) = n^2a+nb+c

Source§

impl<T: Clone + Zero> Polynomial<T>

Source

pub fn adjust(&self) -> Self

(0x^3+2x^2-4).adjust() = 2x^2-4

Source

pub fn similar_adjust(&self, precision: f64) -> Self

((3e-8)x^3+(1e-3)x^2-(2e-8)x+3).similar_adjust(1e-6) = (1e-3)x^2-(2e-8)x+3

Source§

impl<T> Polynomial<T>
where T: Clone + Div<Output = T> + Sub<Output = T> + Mul<Output = T> + Add<Output = T> + Zero + One + PartialEq,

Source

pub fn gcd(&self, other: &Self) -> Self

Source

pub fn gcde(&self, other: &Self) -> (Self, Self, Self)

返回(gcd, x, y)使得 self * x + other * y = self.gcd(other)

Source

pub fn similar_gcd(&self, other: &Self, precision: f64) -> Self

Source

pub fn similar_gcde(&self, other: &Self, precision: f64) -> (Self, Self, Self)

Source§

impl Polynomial<Fraction>

Source

pub fn primitive(&self) -> Polynomial<i128>

有理数多项式的本原化

Source§

impl Polynomial<i8>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<i16>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<i32>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<i64>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<i128>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<isize>

Source

pub fn rational_roots(&self) -> Vec<Fraction>

求所有有理根

Source§

impl Polynomial<f64>

Source

pub fn derived(&self) -> Polynomial<f64>

求导

Source

pub fn integral(&self) -> Polynomial<f64>

积分

Source

pub fn real_roots(&self, x_precision: f64, y_precision: f64) -> Vec<f64>

求所有实数根

Trait Implementations§

Source§

impl<T, U, V> Add<Polynomial<U>> for Polynomial<T>
where T: Clone + Add<U, Output = V> + Zero, U: Clone + Zero, V: Clone,

Source§

type Output = Polynomial<V>

The resulting type after applying the + operator.
Source§

fn add(self, other: Polynomial<U>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Polynomial<T>

Source§

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

Returns a copy 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: Con> Con for Polynomial<T>
where <T as Con>::Output: Clone,

Source§

type Output = Polynomial<<T as Con>::Output>

Source§

fn con(&self) -> Self::Output
where <T as Con>::Output: Clone,

Source§

impl<T: Debug> Debug for Polynomial<T>

Source§

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

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

impl<T: Display> Display for Polynomial<T>

Source§

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

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

impl<T, U, V> Div<Polynomial<U>> for Polynomial<T>
where T: Clone + Div<U, Output = V> + Sub<Output = T> + Zero + PartialEq, U: Clone + Mul<V, Output = T> + Zero, V: Clone + Zero,

Source§

type Output = (Polynomial<V>, Polynomial<T>)

The resulting type after applying the / operator.
Source§

fn div(self, other: Polynomial<U>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T, U, V> DivLeft<Polynomial<U>> for Polynomial<T>
where T: Clone + DivLeft<U, Output = V> + Sub<Output = T> + Zero + PartialEq, U: Clone + Zero, V: Clone + Mul<U, Output = T> + Zero,

Source§

type Output = (Polynomial<V>, Polynomial<T>)

Source§

fn div_left(&self, other: &Polynomial<U>) -> Self::Output

Source§

impl<T: Latex> Latex for Polynomial<T>

Source§

fn latex(&self) -> String

Source§

impl<T, U, V> Mul<Polynomial<U>> for Polynomial<T>
where T: Clone + Mul<U, Output = V>, U: Clone, V: Clone + Add<Output = V>,

Source§

type Output = Polynomial<V>

The resulting type after applying the * operator.
Source§

fn mul(self, other: Polynomial<U>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Neg> Neg for Polynomial<T>
where <T as Neg>::Output: Clone,

Source§

type Output = Polynomial<<T as Neg>::Output>

Source§

fn neg(&self) -> Self::Output
where <T as Neg>::Output: Clone,

Source§

impl<T: Clone + One + Zero + PartialEq> One for Polynomial<T>

Source§

fn get_one(&self) -> Self

Source§

fn eq_one(&self) -> bool

Source§

fn similar_one(&self, precision: f64) -> bool

Source§

impl<T: PartialEq> PartialEq for Polynomial<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: Clone + Mul<Output = T> + Add<Output = T> + One + Zero + PartialEq> Pow for Polynomial<T>

Source§

type Output = Polynomial<T>

Source§

fn pow(&self, power: u32) -> Self::Output

Source§

impl<T, U, V> Rem<Polynomial<U>> for Polynomial<T>
where T: Clone + Div<U, Output = V> + Sub<Output = T> + Zero + PartialEq, U: Clone + Mul<V, Output = T> + Zero, V: Clone + Zero,

Source§

type Output = Polynomial<T>

The resulting type after applying the % operator.
Source§

fn rem(self, other: Polynomial<U>) -> Self::Output

Performs the % operation. Read more
Source§

impl<T: Similar> Similar for Polynomial<T>

Source§

fn similar(&self, other: &Self, precision: f64) -> bool

Source§

impl<T, U, V> Sub<Polynomial<U>> for Polynomial<T>
where T: Clone + Sub<U, Output = V> + Zero, U: Clone + Zero, V: Clone,

Source§

type Output = Polynomial<V>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Polynomial<U>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Clone + Add<Output = T> + Zero> Sum for Polynomial<T>

Source§

fn sum<U>(iter: U) -> Self
where U: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T: Clone + Zero + PartialEq> Zero for Polynomial<T>

Source§

fn get_zero(&self) -> Self

Source§

fn eq_zero(&self) -> bool

Source§

fn similar_zero(&self, precision: f64) -> bool

Source§

impl<T: Eq> Eq for Polynomial<T>

Auto Trait Implementations§

§

impl<T> Freeze for Polynomial<T>

§

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

§

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

§

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

§

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

§

impl<T> UnwindSafe for Polynomial<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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.