fix: Make all polynomials monic in task fn #23
2 changed files with 16 additions and 2 deletions
|
|
@ -112,7 +112,7 @@ pub fn gfpoly_gcd(args: &Value) -> Result<Polynomial> {
|
|||
let poly_a = Polynomial::from_c_array(&args["A"].clone());
|
||||
let poly_b = Polynomial::from_c_array(&args["B"].clone());
|
||||
|
||||
let result = gcd(poly_a, poly_b);
|
||||
let result = gcd(poly_a.monic(), poly_b.monic());
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1267,7 +1267,7 @@ mod tests {
|
|||
|
||||
assert_eq!(json!(result.to_c_array()), expected);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_poly_gcd() {
|
||||
let a = json!([
|
||||
|
|
@ -1304,4 +1304,18 @@ mod tests {
|
|||
|
||||
assert_eq!(json!(result.to_c_array()), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_poly_gcd_zero() {
|
||||
let a = json!(["AAAAAAAAAAAAAAAAAAAAAA==",]);
|
||||
let b = json!(["AAAAAAAAAAAAAAAAAAAAAA=="]);
|
||||
let expected = json!(["AAAAAAAAAAAAAAAAAAAAAA=="]);
|
||||
|
||||
let a: Polynomial = Polynomial::from_c_array(&a);
|
||||
let b: Polynomial = Polynomial::from_c_array(&b);
|
||||
|
||||
let result = gcd(a.monic(), b.monic());
|
||||
|
||||
assert_eq!(json!(result.to_c_array()), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue