Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasgoergens committed Jul 14, 2023
1 parent 110237b commit ce292eb
Show file tree
Hide file tree
Showing 54 changed files with 130 additions and 70 deletions.
4 changes: 3 additions & 1 deletion air/src/air.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::ops::{Add, Mul, Sub};

use p3_field::{AbstractExtensionField, AbstractField, AbstractionOf, ExtensionField, Field};
use p3_matrix::dense::RowMajorMatrix;
use p3_matrix::MatrixRows;
Expand Down Expand Up @@ -209,9 +210,10 @@ impl<'a, AB: AirBuilder> AirBuilder for FilteredAirBuilder<'a, AB> {

#[cfg(test)]
mod tests {
use crate::{Air, AirBuilder};
use p3_matrix::MatrixRows;

use crate::{Air, AirBuilder};

struct FibonacciAir;

impl<AB: AirBuilder> Air<AB> for FibonacciAir {
Expand Down
1 change: 1 addition & 0 deletions air/src/virtual_column.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::vec;
use alloc::vec::Vec;
use core::ops::Mul;

use p3_field::{AbstractField, Field};

/// An affine function over columns in a PAIR.
Expand Down
3 changes: 2 additions & 1 deletion brakedown/benches/encode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::any::type_name;

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use p3_brakedown::fast_registry;
use p3_code::CodeOrFamily;
Expand All @@ -6,7 +8,6 @@ use p3_matrix::dense::RowMajorMatrix;
use p3_mersenne_31::Mersenne31;
use rand::distributions::{Distribution, Standard};
use rand::thread_rng;
use std::any::type_name;

const BATCH_SIZE: usize = 1 << 12;

Expand Down
1 change: 1 addition & 0 deletions brakedown/src/brakedown_code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::boxed::Box;

use p3_code::{
Code, CodeOrFamily, LinearCode, SystematicCode, SystematicCodeOrFamily, SystematicLinearCode,
};
Expand Down
3 changes: 1 addition & 2 deletions brakedown/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ macro_rules! brakedown_to_rs {
};
}

pub(crate) use brakedown;
pub(crate) use brakedown_to_rs;
pub(crate) use {brakedown, brakedown_to_rs};
6 changes: 4 additions & 2 deletions brakedown/src/standard_fast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::macros::{brakedown, brakedown_to_rs};
use crate::BrakedownCode;
use alloc::boxed::Box;
use alloc::vec;

use p3_code::{LinearCodeFamily, SLCodeRegistry};
use p3_field::Field;
use p3_matrix::sparse::CsrMatrix;
Expand All @@ -10,6 +9,9 @@ use rand::distributions::{Distribution, Standard};
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;

use crate::macros::{brakedown, brakedown_to_rs};
use crate::BrakedownCode;

pub fn fast_registry<F, In>() -> impl LinearCodeFamily<F, In>
where
F: Field,
Expand Down
1 change: 1 addition & 0 deletions challenger/src/duplex_challenger.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use alloc::vec;
use alloc::vec::Vec;
use core::marker::PhantomData;

use p3_field::Field;
use p3_symmetric::permutation::ArrayPermutation;

Expand Down
4 changes: 3 additions & 1 deletion challenger/src/hash_challenger.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::Challenger;
use alloc::vec;
use alloc::vec::Vec;
use core::marker::PhantomData;

use p3_field::Field;
use p3_symmetric::hasher::CryptographicHasher;

use crate::Challenger;

#[derive(Clone)]
pub struct HashChallenger<F: Field, H: CryptographicHasher<F, [F; OUT_LEN]>, const OUT_LEN: usize> {
input_buffer: Vec<F>,
Expand Down
4 changes: 2 additions & 2 deletions challenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ extern crate alloc;
mod duplex_challenger;
mod hash_challenger;

use alloc::vec::Vec;

pub use duplex_challenger::*;
pub use hash_challenger::*;

use alloc::vec::Vec;
use p3_field::{AbstractExtensionField, Field};

/// Observes prover messages during an IOP, and generates Fiat-Shamir challenges in response.
Expand Down
5 changes: 3 additions & 2 deletions code/src/identity.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use p3_field::Field;
use p3_matrix::MatrixRows;

use crate::{
Code, CodeOrFamily, LinearCode, SystematicCode, SystematicCodeOrFamily, SystematicLinearCode,
};
use p3_field::Field;
use p3_matrix::MatrixRows;

/// The trivial code whose encoder is the identity function.
pub struct IdentityCode {
Expand Down
10 changes: 6 additions & 4 deletions code/src/registry.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::{
CodeFamily, CodeOrFamily, LinearCodeFamily, SystematicCodeFamily, SystematicCodeOrFamily,
SystematicLinearCode,
};
use alloc::boxed::Box;
use alloc::vec::Vec;

use p3_field::Field;
use p3_matrix::{Matrix, MatrixRows};

use crate::{
CodeFamily, CodeOrFamily, LinearCodeFamily, SystematicCodeFamily, SystematicCodeOrFamily,
SystematicLinearCode,
};

/// A registry of systematic, linear codes for various message sizes.
pub struct SLCodeRegistry<F: Field, In: Matrix<F>, Out: Matrix<F>> {
/// Ordered by message length, ascending.
Expand Down
3 changes: 2 additions & 1 deletion code/src/systematic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::{Code, CodeFamily, CodeOrFamily, LinearCode};
use p3_field::Field;
use p3_matrix::MatrixRows;

use crate::{Code, CodeFamily, CodeOrFamily, LinearCode};

/// A systematic code, or a family thereof.
// TODO: Remove? Not really used.
pub trait SystematicCodeOrFamily<F: Field, In: for<'a> MatrixRows<'a, F>>:
Expand Down
6 changes: 4 additions & 2 deletions commit/src/adapters/multi_from_uni_pcs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::pcs::{UnivariatePCS, PCS};
use crate::MultivariatePCS;
use alloc::vec::Vec;
use core::marker::PhantomData;

use p3_challenger::Challenger;
use p3_field::{ExtensionField, Field};
use p3_matrix::MatrixRows;

use crate::pcs::{UnivariatePCS, PCS};
use crate::MultivariatePCS;

pub struct MultiFromUniPCS<F, In, U>
where
F: Field,
Expand Down
4 changes: 3 additions & 1 deletion commit/src/adapters/uni_from_multi_pcs.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use crate::pcs::MultivariatePCS;
use core::marker::PhantomData;

use p3_field::Field;
use p3_matrix::MatrixRows;

use crate::pcs::MultivariatePCS;

pub struct UniFromMultiPCS<F, In, M>
where
F: Field,
Expand Down
1 change: 1 addition & 0 deletions commit/src/mmcs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::vec::Vec;

use p3_matrix::MatrixRows;

/// A "Mixed Matrix Commitment Scheme" (MMCS) is a bit like a vector commitment scheme, but it
Expand Down
4 changes: 2 additions & 2 deletions commit/src/pcs.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//! Traits for polynomial commitment schemes.

use alloc::vec;
use p3_field::{ExtensionField, Field};

use alloc::vec::Vec;

use p3_challenger::Challenger;
use p3_field::{ExtensionField, Field};
use p3_matrix::MatrixRows;

/// A (not necessarily hiding) polynomial commitment scheme, for committing to (batches of)
Expand Down
3 changes: 2 additions & 1 deletion field/src/batch_inverse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use crate::field::Field;
use alloc::vec;
use alloc::vec::Vec;

use crate::field::Field;

/// Batch multiplicative inverses with Montgomery's trick
/// This is Montgomery's trick. At a high level, we invert the product of the given field
/// elements, then derive the individual inverses from that via multiplication.
Expand Down
3 changes: 2 additions & 1 deletion field/src/field.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::packed::PackedField;
use core::fmt::{Debug, Display};
use core::hash::Hash;
use core::iter::{Product, Sum};
Expand All @@ -7,6 +6,8 @@ use core::slice;

use p3_util::log2_ceil_u64;

use crate::packed::PackedField;

/// A generalization of `Field` which permits things like
/// - an actual field element
/// - a symbolic expression which would evaluate to a field element
Expand Down
3 changes: 2 additions & 1 deletion field/src/symbolic.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::field::{AbstractField, AbstractionOf, Field};
use alloc::rc::Rc;
use core::fmt::Debug;
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};

use crate::field::{AbstractField, AbstractionOf, Field};

#[derive(Clone, Debug)]
pub enum SymbolicField<F: Field, Var> {
Variable(Var),
Expand Down
8 changes: 5 additions & 3 deletions fri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

extern crate alloc;

use crate::proof::FriProof;
use crate::prover::prove;
use crate::verifier::verify;
use core::marker::PhantomData;

use p3_challenger::Challenger;
use p3_commit::{DirectMMCS, MMCS};
use p3_field::{ExtensionField, Field};
use p3_ldt::{LDTBasedPCS, LDT};

use crate::proof::FriProof;
use crate::prover::prove;
use crate::verifier::verify;

mod config;
mod proof;
mod prover;
Expand Down
1 change: 1 addition & 0 deletions fri/src/proof.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloc::vec::Vec;

use p3_commit::{DirectMMCS, MMCS};
use p3_field::{ExtensionField, Field};

Expand Down
7 changes: 4 additions & 3 deletions fri/src/prover.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use crate::{FriConfig, FriProof};
use alloc::vec;
use alloc::vec::Vec;
use core::cmp::Reverse;

use itertools::Itertools;
use p3_challenger::Challenger;
use p3_commit::{DirectMMCS, MMCS};
use p3_field::{AbstractField, ExtensionField, Field};
use p3_matrix::{Matrix, MatrixRows};
use p3_maybe_rayon::MaybeIntoParIter;
use p3_maybe_rayon::ParallelIterator;
use p3_maybe_rayon::{MaybeIntoParIter, ParallelIterator};

use crate::{FriConfig, FriProof};

pub(crate) fn prove<F, Challenge, M, MC, Chal>(
codewords: &[M::ProverData],
Expand Down
3 changes: 2 additions & 1 deletion fri/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::FriProof;
use p3_challenger::Challenger;
use p3_commit::{DirectMMCS, MMCS};
use p3_field::{ExtensionField, Field};

use crate::FriProof;

pub(crate) fn verify<F, EF, M, MC, Chal>(
_proof: &FriProof<F, EF, M, MC>,
_challenger: &mut Chal,
Expand Down
1 change: 1 addition & 0 deletions goldilocks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use core::fmt::{Debug, Display, Formatter};
use core::hash::{Hash, Hasher};
use core::iter::{Product, Sum};
use core::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};

use p3_field::{AbstractField, Field, PrimeField, PrimeField64, TwoAdicField};
use p3_util::{assume, branch_hint};
use rand::distributions::{Distribution, Standard};
Expand Down
1 change: 1 addition & 0 deletions keccak/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
extern crate alloc;

use alloc::vec::Vec;

use p3_symmetric::hasher::CryptographicHasher;
use p3_symmetric::permutation::{ArrayPermutation, CryptographicPermutation};
use tiny_keccak::{keccakf, Hasher, Keccak};
Expand Down
6 changes: 4 additions & 2 deletions lde/src/naive.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use crate::{TwoAdicCosetLDE, TwoAdicLDE, TwoAdicSubgroupLDE, UndefinedLDE};
use alloc::vec::Vec;

use p3_field::{
batch_multiplicative_inverse, cyclic_subgroup_coset_known_order, cyclic_subgroup_known_order,
ExtensionField, Field, TwoAdicField,
};
use p3_field::{ExtensionField, Field, TwoAdicField};
use p3_matrix::dense::RowMajorMatrix;
use p3_matrix::stack::VerticalPair;
use p3_matrix::{Matrix, MatrixRows};
use p3_util::log2_strict_usize;

use crate::{TwoAdicCosetLDE, TwoAdicLDE, TwoAdicSubgroupLDE, UndefinedLDE};

/// A naive quadratic-time implementation of `LDE`, intended for testing.
pub struct NaiveUndefinedLDE;

Expand Down
4 changes: 2 additions & 2 deletions ldt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ extern crate alloc;

use alloc::vec::Vec;
use core::marker::PhantomData;

use p3_challenger::Challenger;
use p3_commit::{DirectMMCS, MMCS};
use p3_commit::{UnivariatePCS, PCS};
use p3_commit::{DirectMMCS, UnivariatePCS, MMCS, PCS};
use p3_field::{AbstractExtensionField, ExtensionField, Field, TwoAdicField};
use p3_lde::TwoAdicLDE;
use p3_matrix::dense::RowMajorMatrix;
Expand Down
4 changes: 3 additions & 1 deletion matrix/src/dense.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use crate::{Matrix, MatrixGet, MatrixRows};
use alloc::vec::Vec;

use p3_field::Field;
use rand::distributions::{Distribution, Standard};
use rand::Rng;

use crate::{Matrix, MatrixGet, MatrixRows};

/// A dense matrix stored in row-major form.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RowMajorMatrix<T> {
Expand Down
3 changes: 2 additions & 1 deletion matrix/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

extern crate alloc;

use crate::dense::RowMajorMatrix;
use alloc::boxed::Box;

use crate::dense::RowMajorMatrix;

pub mod dense;
pub mod mul;
pub mod sparse;
Expand Down
8 changes: 5 additions & 3 deletions matrix/src/mul.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::dense::RowMajorMatrix;
use crate::sparse::CsrMatrix;
use crate::{Matrix, MatrixRows};
use alloc::vec;

use p3_field::Field;
use p3_maybe_rayon::{MaybeIntoParIter, ParallelIterator};

use crate::dense::RowMajorMatrix;
use crate::sparse::CsrMatrix;
use crate::{Matrix, MatrixRows};

/// Compute `C = A * B`, where `A` in a CSR matrix and `B` is a dense matrix.
///
/// # Panics
Expand Down
4 changes: 3 additions & 1 deletion matrix/src/sparse.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::Matrix;
use alloc::vec::Vec;
use core::iter;
use core::ops::Range;

use rand::distributions::{Distribution, Standard};
use rand::Rng;

use crate::Matrix;

/// A sparse matrix stored in the compressed sparse row format.
pub struct CsrMatrix<T> {
width: usize,
Expand Down
3 changes: 2 additions & 1 deletion matrix/src/stack.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{Matrix, MatrixRows};
use core::marker::PhantomData;

use crate::{Matrix, MatrixRows};

/// A combination of two matrices, stacked together vertically.
pub struct VerticalPair<T, First: Matrix<T>, Second: Matrix<T>> {
first: First,
Expand Down
Loading

0 comments on commit ce292eb

Please sign in to comment.