MCPcopy Create free account
hub / github.com/elftausend/graplot / polynomial

Function polynomial

src/polynomial.rs:23–36  ·  view source on GitHub ↗
(xs: &[f64], ys: &[f64])

Source from the content-addressed store, hash-verified

21}
22
23pub fn polynomial(xs: &[f64], ys: &[f64]) -> Polynomial {
24 let degree = xs.len() - 1;
25
26 let mut coeffs = Vec::<f64>::with_capacity(xs.len() * xs.len());
27
28 for x in xs {
29 for pow in (0..=degree).rev() {
30 coeffs.push(x.powi(pow as i32));
31 }
32 }
33 Polynomial {
34 coefficients: solve_lu(xs.len(), &coeffs, ys),
35 }
36}
37
38impl PlotArg for Polynomial {
39 fn as_plot(&self) -> crate::Plot {

Callers 2

newMethod · 0.85
test_poly_1stFunction · 0.85

Calls 1

solve_luFunction · 0.85

Tested by 1

test_poly_1stFunction · 0.68