Skip to content

Commit

Permalink
mvpoly/monomials: allow to artificially increase the degree
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Dec 18, 2024
1 parent 2d2265c commit 00a6119
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mvpoly/src/monomials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,19 @@ impl<F: PrimeField, const N: usize, const D: usize> From<F> for Sparse<F, N, D>
}
}

impl<F: PrimeField, const N: usize, const D: usize, const M: usize> From<Sparse<F, N, D>>
for Result<Sparse<F, M, D>, String>
impl<F: PrimeField, const N: usize, const D: usize, const M: usize, const D_PRIME: usize>
From<Sparse<F, N, D>> for Result<Sparse<F, M, D_PRIME>, String>
{
fn from(poly: Sparse<F, N, D>) -> Result<Sparse<F, M, D>, String> {
fn from(poly: Sparse<F, N, D>) -> Result<Sparse<F, M, D_PRIME>, String> {
if M < N {
return Err("The number of variables must be greater than N".to_string());
return Err(format!(
"The final number of variables {M} must be greater than {N}"
));
}
if D_PRIME < D {
return Err(format!(
"The final degree {D_PRIME} must be greater than initial degree {D}"
));
}
let mut monomials = HashMap::new();
poly.monomials.iter().for_each(|(exponents, coeff)| {
Expand Down

0 comments on commit 00a6119

Please sign in to comment.