(&self)
| 37 | |
| 38 | impl PlotArg for Polynomial { |
| 39 | fn as_plot(&self) -> crate::Plot { |
| 40 | let mut xs = [0.; 200]; |
| 41 | |
| 42 | let mut add = -100f64; |
| 43 | for x in &mut xs { |
| 44 | *x = add / 100.; |
| 45 | add += 1.; |
| 46 | } |
| 47 | |
| 48 | let mut ys = [0.; 200]; |
| 49 | |
| 50 | let degree = self.coefficients.len() - 1; |
| 51 | |
| 52 | for (i, y) in ys.iter_mut().enumerate() { |
| 53 | for (pow, coefficient) in self.coefficients.iter().enumerate() { |
| 54 | *y += coefficient * xs[i].powi((degree - pow) as i32); |
| 55 | } |
| 56 | } |
| 57 | Plot { |
| 58 | xs: vec![xs.to_vec()], |
| 59 | ys: vec![ys.to_vec()], |
| 60 | line_desc: vec![Default::default()], |
| 61 | axis_desc: Default::default(), |
| 62 | desc: Default::default(), |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | impl PlotArg for (Polynomial, Option<XEnd>) { |
no outgoing calls