Struct ohsl::polynomial::Polynomial

source ·
pub struct Polynomial<T> { /* private fields */ }

Implementations§

source§

impl<T: Copy + Clone + Number + Signed + Debug> Polynomial<T>

source

pub fn polydiv( &self, v: &Polynomial<T> ) -> Result<(Polynomial<T>, Polynomial<T>), &'static str>

Divide the polynomial by another polynomial to get a quotient and remainder

Examples found in repository?
examples/polynomial.rs (line 32)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source§

impl<T> Polynomial<T>

source

pub const fn empty() -> Self

Create a new polynomial of unspecified size

source

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

Create a new polynomial

Examples found in repository?
examples/polynomial.rs (line 7)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

pub fn quadratic(a: T, b: T, c: T) -> Self

Create a new quadratic polynomial of the form ax^2 + bx + c

source

pub fn cubic(a: T, b: T, c: T, d: T) -> Self

Create a new cubic polynomial of the form ax^3 + bx^2 + cx + d

Examples found in repository?
examples/polynomial.rs (line 25)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

pub fn size(&self) -> usize

Return the size of the polynomial

source

pub fn degree(&self) -> Result<usize, &'static str>

Return the degree of the polynomial or an error if < 1.

Examples found in repository?
examples/polynomial.rs (line 12)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

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

Return the coefficients of the polynomial as a mutable reference

source

pub fn eval(&self, x: T) -> Twhere T: Copy + Mul<Output = T> + Add<Output = T>,

Evaluate the polynomial at a given point

Examples found in repository?
examples/polynomial.rs (line 15)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

pub fn is_zero(&self) -> boolwhere T: Zero + PartialEq,

Check if all the coefficients are zero

source

pub fn trim(&mut self)where T: Zero + PartialEq,

Remove leading zeros from the polynomial

source§

impl<T: Clone + Copy + Zero + Mul<Output = T> + Add<Output = T>> Polynomial<T>

source

pub fn derivative(&self) -> Polynomial<T>

Return the derivative of the polynomial

Examples found in repository?
examples/polynomial.rs (line 39)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

pub fn derivative_n(&self, n: usize) -> Polynomial<T>

Return the nth derivative of the polynomial

Examples found in repository?
examples/polynomial.rs (line 40)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source

pub fn derivative_at(&self, x: T, n: usize) -> T

Return the nth derivative of the polynomial at a given point

Examples found in repository?
examples/polynomial.rs (line 41)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source§

impl Polynomial<f64>

source

pub fn roots(&self, refine: bool) -> Vector<Cmplx>

Find all the roots of the polynomial with f64 coefficients refine = true will refine the roots using Laguerre’s method

Examples found in repository?
examples/polynomial.rs (line 19)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fn main() {
    println!("----- Polynomials -----");

    // Create a new polynomial
    let p = Polynomial::<f64>::new( vec![ 1.0, 2.0, 3.0 ] );
    println!( "  * p(x) = {}", p );
    println!( "  * p[0] = {}", p[0] );
    println!( "  * p[1] = {}", p[1] );
    println!( "  * p[2] = {}", p[2] );
    println!( "  * p is of degree {}", p.degree().unwrap() );
    
    // Evaluate the polynomial at a given point
    println!( "  * p(0.5) = {}", p.eval( 0.5 ) );
    println!( "  * p(1.0) = {}", p.eval( 1.0 ) );

    // Determine the roots of the polynomial
    let roots = p.roots( true );
    println!( "  * p(x) = {} = 0 has {} roots", p, roots.size() );
    println!( "    * x0 = {:.6} {:.6} i", roots[0].real, roots[0].imag );
    println!( "    * x1 = {:.6} +{:.6} i", roots[1].real, roots[1].imag );
    
    // Arithmetic
    let q = Polynomial::cubic( 3.0, 5.0, 4.0, 0.0 );
    println!( "  * q(x) = {}", q );
    println!( "  * p(x) + q(x) = {}", p.clone() + q.clone() );
    println!( "  * p(x) - q(x) = {}", p.clone() - q.clone() );
    println!( "  * -p(x) = {}", -p.clone() );
    println!( "  * p(x) * q(x) = {}", p.clone() * q.clone() );
    println!( "  * p(x) * 3  = {}", p.clone() * 3.0 );
    let result = q.polydiv( &p );
    match result {
        Ok( ( q, r ) ) => println!( "  * q(x) / p(x) = {} remainder {}", q, r ),
        Err( e ) => println!( "  * q(x) / p(x) = {}", e )
    }
    
    // Derivatives
    println!( "  * p'(x) = {}", p.derivative() );
    println!( "  * p''(x) = {}", p.derivative_n( 2 ) );
    println!( "  * p'(0.5) = {}", p.derivative_at( 0.5, 1 ) );
    println!( "  * p''(0.5) = {}", p.derivative_at( 0.5, 2 ) );

    println!( "--- FINISHED ---" );
}
source§

impl Polynomial<Cmplx>

source

pub fn roots(&self, refine: bool) -> Vector<Cmplx>

Find all the roots of the polynomial with Complex coefficients refine = true will refine the roots using Laguerre’s method

Trait Implementations§

source§

impl<T: Copy + Clone + Number> Add for Polynomial<T>

source§

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

Add two polynomials together ( binary + )

§

type Output = Polynomial<T>

The resulting type after applying the + operator.
source§

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

source§

fn clone(&self) -> Self

Clone the polynomial

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

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

source§

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

Format the debug output of the polynomial

source§

impl<T: Display + Zero + PartialOrd + Signed> Display for Polynomial<T>

source§

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

Format the output of the polynomial

source§

impl<T> Index<usize> for Polynomial<T>

source§

fn index<'a>(&'a self, index: usize) -> &'a T

Indexing operator [] (read only)

§

type Output = T

The returned type after indexing.
source§

impl<T> IndexMut<usize> for Polynomial<T>

source§

fn index_mut(&mut self, index: usize) -> &mut T

Indexing operator [] (read/write)

source§

impl<T: Copy + Clone + Number> Mul<T> for Polynomial<T>

source§

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

Multiply a polynomial by a scalar ( binary * )

§

type Output = Polynomial<T>

The resulting type after applying the * operator.
source§

impl<T: Copy + Clone + Number> Mul for Polynomial<T>

source§

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

Multiply two polynomials together ( binary * )

§

type Output = Polynomial<T>

The resulting type after applying the * operator.
source§

impl<T: Clone + Signed> Neg for Polynomial<T>

source§

fn neg(self) -> Self::Output

Return the unary negation ( unary - )

§

type Output = Polynomial<T>

The resulting type after applying the - operator.
source§

impl<T: Copy + Clone + Number + Signed> Sub for Polynomial<T>

source§

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

Subtract one polynomial from another ( binary - )

§

type Output = Polynomial<T>

The resulting type after applying the - operator.

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V