Skip to main content

stwo_gpu/core/
mod.rs

1use core::ops::{Deref, DerefMut};
2
3use std_shims::Vec;
4pub mod air;
5pub mod channel;
6pub mod circle;
7pub mod constraints;
8pub mod fft;
9pub mod fields;
10mod fraction;
11pub use fraction::Fraction;
12pub mod fri;
13pub mod pcs;
14pub mod poly;
15pub mod proof;
16pub mod proof_of_work;
17pub mod queries;
18#[cfg(all(test, feature = "prover"))]
19pub mod test_utils;
20pub mod utils;
21pub mod vcs;
22pub mod vcs_lifted;
23pub mod verifier;
24
25/// A vector in which each element relates (by index) to a column in the trace.
26pub type ColumnVec<T> = Vec<T>;
27
28/// A vector of [ColumnVec]s. Each [ColumnVec] relates (by index) to a component in the air.
29#[derive(Debug, Clone)]
30pub struct ComponentVec<T>(pub Vec<ColumnVec<T>>);
31
32impl<T> ComponentVec<T> {
33    pub fn flatten(self) -> ColumnVec<T> {
34        self.0.into_iter().flatten().collect()
35    }
36}
37
38impl<T> ComponentVec<ColumnVec<T>> {
39    pub fn flatten_cols(self) -> Vec<T> {
40        self.0.into_iter().flatten().flatten().collect()
41    }
42}
43
44impl<T> Default for ComponentVec<T> {
45    fn default() -> Self {
46        Self(Vec::new())
47    }
48}
49
50impl<T> Deref for ComponentVec<T> {
51    type Target = Vec<ColumnVec<T>>;
52
53    fn deref(&self) -> &Self::Target {
54        &self.0
55    }
56}
57
58impl<T> DerefMut for ComponentVec<T> {
59    fn deref_mut(&mut self) -> &mut Self::Target {
60        &mut self.0
61    }
62}
63
64#[macro_export]
65macro_rules! parallel_iter {
66    ($i: expr) => {{
67        #[cfg(not(feature = "parallel"))]
68        let iter = $i.into_iter();
69
70        #[cfg(feature = "parallel")]
71        let iter = $i.into_par_iter();
72
73        iter
74    }};
75}