cargodog / polynomials

MIT License
4 stars 4 forks source link

[won't fix] High order zeros should be trimmed #11

Closed cargodog closed 4 years ago

cargodog commented 4 years ago

Several operations leave high order zeros in the vector, which should be removed. For example, the following would occur in a subtraction:

let a = Polynomial::from(vec![1, 2, 3]);
let b = Polynomial::from(vec![0, 0, 3]); 
let c = a - b; // c now has an unnecessary 0 at idx 2: [1, 2, 0]
assert_eq!(c[2], 0);

These zeros can stack up as more operations are performed. It would be preferable to trim unnecessary zeros, however this may incur a significant runtime cost, as there is no easy way to detect zeros.

cargodog commented 4 years ago

I'm tagging this as "wontfix", until I've had a chance to consider the performance trade-off.