(&self)
| 327 | Expression { terms } |
| 328 | } |
| 329 | pub fn degree(&self) -> usize { |
| 330 | let mut has_linear = false; |
| 331 | for term in self.iter() { |
| 332 | match term.vars { |
| 333 | VarSpec::Const => {} |
| 334 | VarSpec::Linear(_) => has_linear = true, |
| 335 | VarSpec::Quad(_, _) => return 2, |
| 336 | VarSpec::Custom { .. } => return 2, |
| 337 | VarSpec::RandomLinear(_) => panic!("unexpected situation: RandomLinear"), |
| 338 | } |
| 339 | } |
| 340 | if has_linear { |
| 341 | 1 |
| 342 | } else { |
| 343 | 0 |
| 344 | } |
| 345 | } |
| 346 | pub fn count_of_degrees(&self) -> [usize; 3] { |
| 347 | let mut res = [0; 3]; |
| 348 | for term in self.iter() { |
no test coverage detected