mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 09:13:09 +00:00
PR feedback: num_selectors as fn and sorting comment
This commit is contained in:
parent
e50e668f7e
commit
604715240f
@ -13,7 +13,12 @@ pub(crate) const UNUSED_SELECTOR: usize = u32::MAX as usize;
|
||||
pub(crate) struct SelectorsInfo {
|
||||
pub(crate) selector_indices: Vec<usize>,
|
||||
pub(crate) groups: Vec<Range<usize>>,
|
||||
pub(crate) num_selectors: usize,
|
||||
}
|
||||
|
||||
impl SelectorsInfo {
|
||||
pub fn num_selectors(&self) -> usize {
|
||||
self.groups.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the selector polynomials and related information.
|
||||
@ -51,7 +56,6 @@ pub(crate) fn selector_polynomials<F: RichField + Extendable<D>, const D: usize>
|
||||
SelectorsInfo {
|
||||
selector_indices: vec![0; num_gates],
|
||||
groups: vec![0..num_gates],
|
||||
num_selectors: 1,
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -101,7 +105,6 @@ pub(crate) fn selector_polynomials<F: RichField + Extendable<D>, const D: usize>
|
||||
polynomials,
|
||||
SelectorsInfo {
|
||||
selector_indices,
|
||||
num_selectors: groups.len(),
|
||||
groups,
|
||||
},
|
||||
)
|
||||
|
||||
@ -666,7 +666,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
|
||||
let quotient_degree_factor = self.config.max_quotient_degree_factor;
|
||||
let mut gates = self.gates.iter().cloned().collect::<Vec<_>>();
|
||||
// Gates need to be sorted by their degrees to compute the selector polynomials.
|
||||
// Gates need to be sorted by their degrees (and ID to make the ordering deterministic) to compute the selector polynomials.
|
||||
gates.sort_unstable_by_key(|g| (g.0.degree(), g.0.id()));
|
||||
let (mut constant_vecs, selectors_info) =
|
||||
selector_polynomials(&gates, &self.gate_instances, quotient_degree_factor + 1);
|
||||
|
||||
@ -221,7 +221,7 @@ pub fn evaluate_gate_constraints<
|
||||
i,
|
||||
selector_index,
|
||||
common_data.selectors_info.groups[selector_index].clone(),
|
||||
common_data.selectors_info.num_selectors,
|
||||
common_data.selectors_info.num_selectors(),
|
||||
);
|
||||
for (i, c) in gate_constraints.into_iter().enumerate() {
|
||||
debug_assert!(
|
||||
@ -255,7 +255,7 @@ pub fn evaluate_gate_constraints_base_batch<
|
||||
i,
|
||||
selector_index,
|
||||
common_data.selectors_info.groups[selector_index].clone(),
|
||||
common_data.selectors_info.num_selectors,
|
||||
common_data.selectors_info.num_selectors(),
|
||||
);
|
||||
debug_assert!(
|
||||
gate_constraints_batch.len() <= constraints_batch.len(),
|
||||
@ -291,7 +291,7 @@ pub fn evaluate_gate_constraints_recursively<
|
||||
i,
|
||||
selector_index,
|
||||
common_data.selectors_info.groups[selector_index].clone(),
|
||||
common_data.selectors_info.num_selectors,
|
||||
common_data.selectors_info.num_selectors(),
|
||||
&mut all_gate_constraints,
|
||||
)
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user