Skip to content
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

suggested additions to Polynomial #142

Open
omershlo opened this issue Sep 26, 2021 · 2 comments
Open

suggested additions to Polynomial #142

omershlo opened this issue Sep 26, 2021 · 2 comments

Comments

@omershlo
Copy link
Contributor

I am working with Polynomial. As part of my work I am required to manipulate them in certain ways. Here are a few suggestions for new functions to add to Polynomial (If I will have more ideas as I continue working I will add them here):

  • polynomial multiplication : requires fft
  • generate a Polynomial of some degree N (provided as input) from a partial set of coefficients (the rest are zero) given at a specific locations
  • allow to define a polynomial from a vector of BigInts
@survived
Copy link
Contributor

Great suggestions, @omershlo!

  1. Polynomial multiplication could be easily added. I assume FFT is not difficult to implement.
  2. What if I expose this method:
    impl<E> Polynomial<E> { 
        pub fn coefficients_mut(&mut self) -> &mut [Scalar<E>] { ... }
    }
    Would this allow to achieve what you want? Basically, you can sample a random polynomial Polynomial::sample_exact(), and then you can overwrite its coefficients, eg. : polynomial.coefficients_mut()[3] = Scalar::from(4)
  3. That's a reasonable suggestion. To allow construction from bigints, I would change from_coefficients constructor to be:
    impl<E> Polynomial<E> { 
        pub fn from_coefficients<S>(coefficients: impl IntoIterator<Item = S>) -> Self
        where Scalar<E>: From<S>
        { ... }
    }
    So this method will work with both Vec<Scalar<E>> and Vec<Bigint>. But this changes public API and requires major version bump. For now, it may be sufficient to add constructor from_bigint_coefficients that takes Vec<Bigint>.

@omershlo
Copy link
Contributor Author

omershlo commented Oct 3, 2021

more:

  • return a coefficient in a specific index
  • trim leading zero coefficients
  • compute a % b for a, b polynomials
  • compute polynomial division

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants