From 27bf71344390b96d00a7dc162e287114ce831119 Mon Sep 17 00:00:00 2001 From: Daniel Lubarov Date: Wed, 24 Jan 2024 08:36:51 -0800 Subject: [PATCH] Renames --- cpu/src/lib.rs | 18 +++++++++--------- memory/src/lib.rs | 26 +++++++++++++------------- output/src/lib.rs | 6 +++--- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/cpu/src/lib.rs b/cpu/src/lib.rs index 3d926e79..b26ec69e 100644 --- a/cpu/src/lib.rs +++ b/cpu/src/lib.rs @@ -259,19 +259,19 @@ impl CpuChip { fn compute_word_diffs(rows: &mut Vec<[F; NUM_CPU_COLS]>) { // Compute `diff` let mut diff = vec![F::zero(); rows.len()]; - for n in 0..rows.len() { + for i in 0..rows.len() { let word_1 = CPU_COL_MAP.mem_channels[0] .value .into_iter() - .map(|i| rows[n][i]) + .map(|i| rows[i][i]) .collect::>(); let word_2 = CPU_COL_MAP.mem_channels[1] .value .into_iter() - .map(|i| rows[n][i]) + .map(|i| rows[i][i]) .collect::>(); for (a, b) in word_1.into_iter().zip(word_2) { - diff[n] += (a - b).square(); + diff[i] += (a - b).square(); } } @@ -279,11 +279,11 @@ impl CpuChip { let diff_inv = batch_multiplicative_inverse_allowing_zero(diff.clone()); // Set trace values - for n in 0..rows.len() { - rows[n][CPU_COL_MAP.diff] = diff[n]; - rows[n][CPU_COL_MAP.diff_inv] = diff_inv[n]; - if diff[n] != F::zero() { - rows[n][CPU_COL_MAP.not_equal] = F::one(); + for i in 0..rows.len() { + rows[i][CPU_COL_MAP.diff] = diff[i]; + rows[i][CPU_COL_MAP.diff_inv] = diff_inv[i]; + if diff[i] != F::zero() { + rows[i][CPU_COL_MAP.not_equal] = F::one(); } } } diff --git a/memory/src/lib.rs b/memory/src/lib.rs index ea0cf345..320fe401 100644 --- a/memory/src/lib.rs +++ b/memory/src/lib.rs @@ -290,17 +290,17 @@ impl MemoryChip { // Compute `diff` and `counter_mult` let mut diff = vec![F::zero(); rows.len()]; let mut mult = vec![F::zero(); rows.len()]; - for n in 0..(rows.len() - 1) { - let addr = ops[n].1.get_address(); - let addr_next = ops[n + 1].1.get_address(); + for i in 0..(rows.len() - 1) { + let addr = ops[i].1.get_address(); + let addr_next = ops[i + 1].1.get_address(); let value = if addr_next != addr { addr_next - addr } else { - let clk = ops[n].0; - let clk_next = ops[n + 1].0; + let clk = ops[i].0; + let clk_next = ops[i + 1].0; clk_next - clk }; - diff[n] = F::from_canonical_u32(value); + diff[i] = F::from_canonical_u32(value); mult[value as usize] += F::one(); } @@ -308,15 +308,15 @@ impl MemoryChip { let diff_inv = batch_multiplicative_inverse_allowing_zero(diff.clone()); // Set trace values - for n in 0..(rows.len() - 1) { - rows[n][MEM_COL_MAP.diff] = diff[n]; - rows[n][MEM_COL_MAP.diff_inv] = diff_inv[n]; - rows[n][MEM_COL_MAP.counter_mult] = mult[n]; + for i in 0..(rows.len() - 1) { + rows[i][MEM_COL_MAP.diff] = diff[i]; + rows[i][MEM_COL_MAP.diff_inv] = diff_inv[i]; + rows[i][MEM_COL_MAP.counter_mult] = mult[i]; - let addr = ops[n].1.get_address(); - let addr_next = ops[n + 1].1.get_address(); + let addr = ops[i].1.get_address(); + let addr_next = ops[i + 1].1.get_address(); if addr_next - addr != 0 { - rows[n][MEM_COL_MAP.addr_not_equal] = F::one(); + rows[i][MEM_COL_MAP.addr_not_equal] = F::one(); } } diff --git a/output/src/lib.rs b/output/src/lib.rs index b4104745..c11908e0 100644 --- a/output/src/lib.rs +++ b/output/src/lib.rs @@ -47,16 +47,16 @@ where let clk_diff = clk_2 - clk_1; let num_rows = (clk_diff / table_len) as usize + 1; let mut rows = Vec::with_capacity(num_rows); - for n in 0..num_rows { + for i in 0..num_rows { let mut row = [SC::Val::zero(); NUM_OUTPUT_COLS]; let cols: &mut OutputCols = unsafe { transmute(&mut row) }; - if n == 0 { + if i == 0 { cols.is_real = SC::Val::one(); cols.clk = SC::Val::from_canonical_u32(clk_1); cols.value = SC::Val::from_canonical_u8(val_1); } else { // Dummy output to satisfy range check - cols.clk = SC::Val::from_canonical_u32(clk_1 + table_len * (n + 1) as u32); + cols.clk = SC::Val::from_canonical_u32(clk_1 + table_len * (i + 1) as u32); } rows.push(row); }