1
 2
 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
46
47
// Helper traits
use crate::Coeff;
use crate::slice::SeriesSlice;

/// Multiplicative inverse
pub trait MulInverse {
    type Output;

    fn mul_inverse(self) -> Self::Output;
}

/// View a slice of the original object
pub trait AsSlice<'a, T> {
    type Output;

    fn as_slice(&'a self, t: T) -> Self::Output;
}

/// Karatsuba multiplication
pub trait KaratsubaMul<Rhs> {
    type Output;

    /// Calculate `self * rhs` using Karatsuba multiplication.
    ///
    /// `min_size` marks the threshold size below which naive
    /// multiplication should be used.
    fn karatsuba_mul(self, rhs: Rhs, min_size: usize) -> Self::Output;
}

// Logarithm for series starting with var^0
pub(crate) trait LnVarFree {
    type Output;
    fn ln_var_free(self) -> Self::Output;
}

// Spurious traits, needed for rust >= 1.28
// direct implementation used to work in 1.24
pub(crate) trait AddAssignHelper<Var, C: Coeff> {
    fn truncate_cutoff_pow<'a>(&mut self, other: SeriesSlice<'a, Var, C>);
    fn add_overlap<'a>(&mut self, other: SeriesSlice<'a, Var, C>);
    fn num_leading<'a>(&mut self, other: SeriesSlice<'a, Var, C>) -> usize;
}

pub(crate) trait ExpCoeff {
    type Output;
    fn exp_coeff(&self) -> Self::Output;
}