Remove unused `Polynomial` operations with internal parallelism

These have been replaced by operations on either `poly::Ast` nodes, or
operations directly on chunks of polynomials within a higher-level
parallelism context.

Addition and scalar multiplication are (currently) still used in various
areas of the prover, so those are left in place.
This commit is contained in:
Jack Grigg 2022-01-19 21:53:17 +00:00
parent b3b783e0f4
commit 2102824599
3 changed files with 6 additions and 137 deletions

View File

@ -37,6 +37,11 @@ and this project adheres to Rust's notion of
### Removed
- `halo2::arithmetic::BatchInvert` (use `ff::BatchInvert` instead).
- `impl Default for halo2::poly::Rotation` (use `Rotation::cur()` instead).
- `halo2::poly`:
- `EvaluationDomain::{add_extended, sub_extended, mul_extended}`
- `Polynomial::one_minus`
- `impl Neg, Sub for Polynomial`
- `impl Mul for Polynomial<_, ExtendedLagrangeCoeff>`
## [0.1.0-beta.1] - 2021-09-24
Initial beta release!

View File

@ -9,7 +9,7 @@ use group::ff::{BatchInvert, Field};
use pasta_curves::arithmetic::FieldExt;
use std::fmt::Debug;
use std::marker::PhantomData;
use std::ops::{Add, Deref, DerefMut, Index, IndexMut, Mul, Neg, RangeFrom, RangeFull, Sub};
use std::ops::{Add, Deref, DerefMut, Index, IndexMut, Mul, RangeFrom, RangeFull};
pub mod commitment;
mod domain;
@ -181,32 +181,6 @@ impl<F: Field> Polynomial<Assigned<F>, LagrangeCoeff> {
}
}
impl<F: Field> Polynomial<F, ExtendedLagrangeCoeff> {
/// Maps every coefficient `c` in `p` to `1 - c`.
pub fn one_minus(mut p: Self) -> Self {
parallelize(&mut p.values, |p, _start| {
for term in p {
*term = F::one() - *term;
}
});
p
}
}
impl<'a, F: Field, B: Basis> Neg for Polynomial<F, B> {
type Output = Polynomial<F, B>;
fn neg(mut self) -> Polynomial<F, B> {
parallelize(&mut self.values, |lhs, _| {
for lhs in lhs.iter_mut() {
*lhs = -*lhs;
}
});
self
}
}
impl<'a, F: Field, B: Basis> Add<&'a Polynomial<F, B>> for Polynomial<F, B> {
type Output = Polynomial<F, B>;
@ -221,39 +195,6 @@ impl<'a, F: Field, B: Basis> Add<&'a Polynomial<F, B>> for Polynomial<F, B> {
}
}
impl<'a, F: Field, B: Basis> Sub<&'a Polynomial<F, B>> for Polynomial<F, B> {
type Output = Polynomial<F, B>;
fn sub(mut self, rhs: &'a Polynomial<F, B>) -> Polynomial<F, B> {
parallelize(&mut self.values, |lhs, start| {
for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) {
*lhs -= *rhs;
}
});
self
}
}
impl<'a, F: Field> Mul<&'a Polynomial<F, ExtendedLagrangeCoeff>>
for Polynomial<F, ExtendedLagrangeCoeff>
{
type Output = Polynomial<F, ExtendedLagrangeCoeff>;
fn mul(
mut self,
rhs: &'a Polynomial<F, ExtendedLagrangeCoeff>,
) -> Polynomial<F, ExtendedLagrangeCoeff> {
parallelize(&mut self.values, |lhs, start| {
for (lhs, rhs) in lhs.iter_mut().zip(rhs.values[start..].iter()) {
*lhs *= *rhs;
}
});
self
}
}
impl<'a, F: Field> Polynomial<F, LagrangeCoeff> {
/// Rotates the values in a Lagrange basis polynomial by `Rotation`
pub fn rotate(&self, rotation: Rotation) -> Polynomial<F, LagrangeCoeff> {

View File

@ -253,83 +253,6 @@ impl<G: Group> EvaluationDomain<G> {
}
}
fn op_extended(
&self,
mut left: Polynomial<G, ExtendedLagrangeCoeff>,
right: &Polynomial<G, ExtendedLagrangeCoeff>,
rotation: Rotation,
op: impl Fn(&mut G, &G) + Send + Sync + 'static,
) -> Polynomial<G, ExtendedLagrangeCoeff>
where
G: Field,
{
// Rotation while in the extended domain is simply exaggerated by how
// much larger the extended domain is compared to the original domain.
let rotation = (1 << (self.extended_k - self.k)) * rotation.0;
parallelize(&mut left.values, |lhs, start| {
let start = ((((start + self.extended_len()) as i32) + rotation) as usize)
% self.extended_len();
for (lhs, rhs) in lhs
.iter_mut()
.zip(right.values[start..].iter().chain(right.values.iter()))
{
op(lhs, rhs);
}
});
left
}
/// Multiply two polynomials in the extended domain, rotating the latter
/// polynomial over the original domain first.
pub fn mul_extended(
&self,
left: Polynomial<G, ExtendedLagrangeCoeff>,
right: &Polynomial<G, ExtendedLagrangeCoeff>,
rotation: Rotation,
) -> Polynomial<G, ExtendedLagrangeCoeff>
where
G: Field,
{
self.op_extended(left, right, rotation, |lhs, rhs| {
*lhs *= *rhs;
})
}
/// Add two polynomials in the extended domain, rotating the latter
/// polynomial over the original domain first.
pub fn add_extended(
&self,
left: Polynomial<G, ExtendedLagrangeCoeff>,
right: &Polynomial<G, ExtendedLagrangeCoeff>,
rotation: Rotation,
) -> Polynomial<G, ExtendedLagrangeCoeff>
where
G: Field,
{
self.op_extended(left, right, rotation, |lhs, rhs| {
*lhs += *rhs;
})
}
/// Subtract a polynomial from another in the extended domain, rotating the
/// former polynomial over the original domain first.
pub fn sub_extended(
&self,
left: Polynomial<G, ExtendedLagrangeCoeff>,
right: &Polynomial<G, ExtendedLagrangeCoeff>,
rotation: Rotation,
) -> Polynomial<G, ExtendedLagrangeCoeff>
where
G: Field,
{
self.op_extended(left, right, rotation, |lhs, rhs| {
*lhs -= *rhs;
})
}
/// Rotate the extended domain polynomial over the original domain.
pub fn rotate_extended(
&self,