qudoku/polynomials/mod.rs
1mod evaluation;
2mod lagrange;
3mod standard;
4
5pub use evaluation::*;
6pub use lagrange::*;
7pub use standard::*;
8
9pub trait Polynomial<I, O> {
10 /// Evaluate the polynomial on a given input.
11 fn evaluate(&self, input: I) -> O;
12
13 /// Returns the degree of the polynomial, which is usually the number of coefficients
14 /// minus 1. If the polynomial has no coefficients, it has degree zero.
15 fn degree(&self) -> usize;
16
17 /// Returns the number of evaluations needed to interpolate this polynomial,
18 /// which is just the number of coefficients in the polynomial.
19 fn interpolation_threshold(&self) -> usize {
20 self.degree() + 1
21 }
22}