mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-03 19:53:40 +00:00
Add a few comments to the permutation construction code
We mainly point at the design document that describes the algorithm.
This commit is contained in:
parent
1ba246f7d9
commit
62cace289b
1 changed files with 7 additions and 0 deletions
|
|
@ -30,6 +30,9 @@ impl Assembly {
|
|||
columns.push((0..params.n).map(|j| (i, j as usize)).collect());
|
||||
}
|
||||
|
||||
// Before any equality constraints are applied, every cell in the permutation is
|
||||
// in a 1-cycle; therefore mapping and aux are identical, because every cell is
|
||||
// its own distinguished element.
|
||||
Assembly {
|
||||
mapping: columns.clone(),
|
||||
aux: columns,
|
||||
|
|
@ -53,9 +56,12 @@ impl Assembly {
|
|||
return Err(Error::BoundsFailure);
|
||||
}
|
||||
|
||||
// See book/src/design/permutation.md for a description of this algorithm.
|
||||
|
||||
let mut left_cycle = self.aux[left_column][left_row];
|
||||
let mut right_cycle = self.aux[right_column][right_row];
|
||||
|
||||
// If left and right are in the same cycle, do nothing.
|
||||
if left_cycle == right_cycle {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
@ -64,6 +70,7 @@ impl Assembly {
|
|||
std::mem::swap(&mut left_cycle, &mut right_cycle);
|
||||
}
|
||||
|
||||
// Merge the right cycle into the left one.
|
||||
self.sizes[left_cycle.0][left_cycle.1] += self.sizes[right_cycle.0][right_cycle.1];
|
||||
let mut i = right_cycle;
|
||||
loop {
|
||||
|
|
|
|||
Loading…
Reference in a new issue