-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Polynomial
for MultilinearExtension
#691
Changes from 5 commits
82cc282
30dce56
183a13b
e4690c4
25f68b3
f8e0378
0ab3d75
14eb52a
8c28679
678ad2f
0df1bd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
use crate::{ | ||
evaluations::multivariate::multilinear::swap_bits, DenseMultilinearExtension, | ||
MultilinearExtension, | ||
MultilinearExtension, Polynomial, | ||
}; | ||
use ark_ff::{Field, Zero}; | ||
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; | ||
|
@@ -227,6 +227,18 @@ impl<F: Field> Index<usize> for SparseMultilinearExtension<F> { | |
} | ||
} | ||
|
||
impl<F: Field> Polynomial<F> for SparseMultilinearExtension<F> { | ||
type Point = Vec<F>; | ||
|
||
fn degree(&self) -> usize { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that elsewhere in the crate, we assume that So this should be changed to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I adapted this to represent the total degree. I've also created a separate issue to discuss the exact design and the need for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this method meant to represent a total degree bound, or the actual total degree of the particular instance this is being called on? For instance, the polynomial Returning the actual total degree would be simple in the sparse case, but might require some work in the dense case if the polynomial is stored in evaluation form. Incidentally, this caveat would also have applied to the code as it was before @Pratyush 's comment: we were always returning 1, but in the fringe case of constant polynomials, that did not match the total degree. |
||
1 | ||
} | ||
|
||
fn evaluate(&self, point: &Self::Point) -> F { | ||
MultilinearExtension::<F>::evaluate(self, point).unwrap() | ||
} | ||
} | ||
|
||
impl<F: Field> Add for SparseMultilinearExtension<F> { | ||
type Output = SparseMultilinearExtension<F>; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto