mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 23:33:07 +00:00
add a single selector vector into SelectorsInfo to make life easier
This commit is contained in:
parent
301ae79b6f
commit
155a0ce24e
@ -15,8 +15,9 @@ pub(crate) const UNUSED_SELECTOR: usize = u32::MAX as usize;
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize)]
|
||||
pub struct SelectorsInfo {
|
||||
pub(crate) selector_indices: Vec<usize>,
|
||||
pub(crate) groups: Vec<Range<usize>>,
|
||||
pub(crate) selector_indices: Vec<usize>, // which gate is in which selector group
|
||||
pub(crate) groups: Vec<Range<usize>>, // how are the gates allocated to selector columns
|
||||
pub(crate) selector_vector: Vec<usize>, // the gate index for each row (used for third party tooling)
|
||||
}
|
||||
|
||||
impl SelectorsInfo {
|
||||
@ -135,7 +136,8 @@ pub(crate) fn selector_polynomials<F: RichField + Extendable<D>, const D: usize>
|
||||
)],
|
||||
SelectorsInfo {
|
||||
selector_indices: vec![0; num_gates],
|
||||
groups: vec![0..num_gates],
|
||||
groups: vec![0..num_gates],
|
||||
selector_vector: vec![0; n],
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -181,11 +183,21 @@ pub(crate) fn selector_polynomials<F: RichField + Extendable<D>, const D: usize>
|
||||
}
|
||||
}
|
||||
|
||||
// for third party tools, we compute a single selector vector too (union of all selectors)
|
||||
let mut selector_vector: Vec<usize> = vec![usize::MAX; n];
|
||||
for (j, g) in instances.iter().enumerate() {
|
||||
let GateInstance { gate_ref, .. } = g;
|
||||
let i = index(gate_ref.0.id());
|
||||
let gr = group(i);
|
||||
selector_vector[j] = i;
|
||||
}
|
||||
|
||||
(
|
||||
polynomials,
|
||||
SelectorsInfo {
|
||||
selector_indices,
|
||||
groups,
|
||||
selector_vector,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@ -232,6 +232,7 @@ where
|
||||
selectors_info: SelectorsInfo {
|
||||
selector_indices: vec![],
|
||||
groups: vec![],
|
||||
selector_vector: vec![],
|
||||
},
|
||||
quotient_degree_factor: 0,
|
||||
num_gate_constraints: 0,
|
||||
|
||||
@ -713,10 +713,12 @@ pub trait Read {
|
||||
let end = self.read_usize()?;
|
||||
groups.push(Range { start, end });
|
||||
}
|
||||
let selector_vector = self.read_usize_vec()?;
|
||||
|
||||
Ok(SelectorsInfo {
|
||||
selector_indices,
|
||||
groups,
|
||||
selector_vector,
|
||||
})
|
||||
}
|
||||
|
||||
@ -1734,6 +1736,7 @@ pub trait Write {
|
||||
let SelectorsInfo {
|
||||
selector_indices,
|
||||
groups,
|
||||
selector_vector,
|
||||
} = selectors_info;
|
||||
|
||||
self.write_usize_vec(selector_indices.as_slice())?;
|
||||
@ -1742,6 +1745,7 @@ pub trait Write {
|
||||
self.write_usize(group.start)?;
|
||||
self.write_usize(group.end)?;
|
||||
}
|
||||
self.write_usize_vec(selector_vector.as_slice())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user