fix: Add removal of leading zeros in poly diff
This commit is contained in:
parent
ab755444c6
commit
1a2910b28f
1 changed files with 34 additions and 0 deletions
|
|
@ -311,6 +311,22 @@ impl Polynomial {
|
|||
}
|
||||
}
|
||||
|
||||
while !self.polynomial.is_empty()
|
||||
&& self
|
||||
.polynomial
|
||||
.last()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.iter()
|
||||
.all(|&x| x == 0)
|
||||
{
|
||||
self.polynomial.pop();
|
||||
}
|
||||
|
||||
if self.is_empty() {
|
||||
self = Polynomial::new(vec![FieldElement::new(vec![0; 16])]);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
@ -1226,4 +1242,22 @@ mod tests {
|
|||
|
||||
assert_eq!(json!(result.to_c_array()), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_poly_diff_multi_zero() {
|
||||
let json1 = json!([
|
||||
"AAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"AAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"AAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"AAAAAAAAAAAAAAAAAAAAAA==",
|
||||
"AAAAAAAAAAAAAAAAAAAAAA==",
|
||||
]);
|
||||
let expected = json!(["AAAAAAAAAAAAAAAAAAAAAA==",]);
|
||||
let element1: Polynomial = Polynomial::from_c_array(&json1);
|
||||
eprintln!("Starting poly sqrt");
|
||||
|
||||
let result = element1.diff();
|
||||
|
||||
assert_eq!(json!(result.to_c_array()), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue