Skip to content

Commit

Permalink
clippy fixes for ark-poly
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush committed Oct 23, 2020
1 parent 50c7a49 commit a511cad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
10 changes: 5 additions & 5 deletions poly/src/domain/mixed_radix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ impl<F: FftField> EvaluationDomain<F> for MixedRadixEvaluationDomain<F> {
if t_size.is_one() {
let mut u = vec![F::zero(); size];
let mut omega_i = one;
for i in 0..size {
for u_i in u.iter_mut().take(size) {
if omega_i == tau {
u[i] = one;
*u_i = one;
break;
}
omega_i *= &self.group_gen;
Expand All @@ -168,12 +168,12 @@ impl<F: FftField> EvaluationDomain<F> for MixedRadixEvaluationDomain<F> {
} else {
use ark_ff::fields::batch_inversion;

let mut l = (t_size - &one) * &self.size_inv;
let mut l = (t_size - one) * self.size_inv;
let mut r = one;
let mut u = vec![F::zero(); size];
let mut ls = vec![F::zero(); size];
for i in 0..size {
u[i] = tau - &r;
u[i] = tau - r;
ls[i] = l;
l *= &self.group_gen;
r *= &self.group_gen;
Expand All @@ -200,7 +200,7 @@ impl<F: FftField> EvaluationDomain<F> for MixedRadixEvaluationDomain<F> {
/// For multiplicative subgroups, this polynomial is `z(X) = X^self.size -
/// 1`.
fn evaluate_vanishing_polynomial(&self, tau: F) -> F {
tau.pow(&[self.size]) - &F::one()
tau.pow(&[self.size]) - F::one()
}

/// Return an iterator over the elements of the domain.
Expand Down
10 changes: 5 additions & 5 deletions poly/src/domain/radix2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ impl<F: FftField> EvaluationDomain<F> for Radix2EvaluationDomain<F> {
if t_size.is_one() {
let mut u = vec![F::zero(); size];
let mut omega_i = one;
for i in 0..size {
for u_i in u.iter_mut().take(size) {
if omega_i == tau {
u[i] = one;
*u_i = one;
break;
}
omega_i *= &self.group_gen;
Expand All @@ -136,12 +136,12 @@ impl<F: FftField> EvaluationDomain<F> for Radix2EvaluationDomain<F> {
} else {
use ark_ff::fields::batch_inversion;

let mut l = (t_size - &one) * &self.size_inv;
let mut l = (t_size - one) * self.size_inv;
let mut r = one;
let mut u = vec![F::zero(); size];
let mut ls = vec![F::zero(); size];
for i in 0..size {
u[i] = tau - &r;
u[i] = tau - r;
ls[i] = l;
l *= &self.group_gen;
r *= &self.group_gen;
Expand All @@ -168,7 +168,7 @@ impl<F: FftField> EvaluationDomain<F> for Radix2EvaluationDomain<F> {
/// For multiplicative subgroups, this polynomial is `z(X) = X^self.size -
/// 1`.
fn evaluate_vanishing_polynomial(&self, tau: F) -> F {
tau.pow(&[self.size]) - &F::one()
tau.pow(&[self.size]) - F::one()
}

/// Return an iterator over the elements of the domain.
Expand Down
5 changes: 5 additions & 0 deletions poly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
rust_2018_idioms
)]
#![forbid(unsafe_code)]
#![allow(
clippy::many_single_char_names,
clippy::suspicious_op_assign_impl,
clippy::suspicious_arithmetic_impl
)]

#[macro_use]
extern crate ark_std;
Expand Down
4 changes: 2 additions & 2 deletions poly/src/polynomial/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ impl<'a, F: Field> DenseOrSparsePolynomial<'a, F> {
// Can unwrap here because we know self is not zero.
let divisor_leading_inv = divisor.leading_coefficient().unwrap().inverse().unwrap();
while !remainder.is_zero() && remainder.degree() >= divisor.degree() {
let cur_q_coeff = *remainder.coeffs.last().unwrap() * &divisor_leading_inv;
let cur_q_coeff = *remainder.coeffs.last().unwrap() * divisor_leading_inv;
let cur_q_degree = remainder.degree() - divisor.degree();
quotient[cur_q_degree] = cur_q_coeff;

for (i, div_coeff) in divisor.iter_with_index() {
remainder[cur_q_degree + i] -= &(cur_q_coeff * &div_coeff);
remainder[cur_q_degree + i] -= &(cur_q_coeff * div_coeff);
}
while let Some(true) = remainder.coeffs.last().map(|c| c.is_zero()) {
remainder.coeffs.pop();
Expand Down
3 changes: 2 additions & 1 deletion poly/src/polynomial/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ impl<F: Field> SparsePolynomial<F> {
}
let mut total = F::zero();
for (i, c) in &self.coeffs {
total += &(*c * &point.pow(&[*i as u64]));
total += &(*c * point.pow(&[*i as u64]));
}
total
}

/// Perform a naive n^2 multiplicatoin of `self` by `other`.
#[allow(clippy::or_fun_call)]
pub fn mul(&self, other: &Self) -> Self {
if self.is_zero() || other.is_zero() {
SparsePolynomial::zero()
Expand Down

0 comments on commit a511cad

Please sign in to comment.