2024-02-13 11:47:54 -05:00
|
|
|
//! Utility module providing some helper functions.
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "std"))]
|
2022-11-04 16:04:10 -07:00
|
|
|
use alloc::vec::Vec;
|
|
|
|
|
|
2022-03-16 17:37:34 -07:00
|
|
|
use itertools::Itertools;
|
|
|
|
|
use plonky2::field::polynomial::PolynomialValues;
|
2022-06-27 12:24:09 -07:00
|
|
|
use plonky2::field::types::Field;
|
2022-03-16 17:37:34 -07:00
|
|
|
use plonky2::util::transpose;
|
|
|
|
|
|
|
|
|
|
/// A helper function to transpose a row-wise trace and put it in the format that `prove` expects.
|
|
|
|
|
pub fn trace_rows_to_poly_values<F: Field, const COLUMNS: usize>(
|
|
|
|
|
trace_rows: Vec<[F; COLUMNS]>,
|
|
|
|
|
) -> Vec<PolynomialValues<F>> {
|
|
|
|
|
let trace_row_vecs = trace_rows.into_iter().map(|row| row.to_vec()).collect_vec();
|
|
|
|
|
let trace_col_vecs: Vec<Vec<F>> = transpose(&trace_row_vecs);
|
|
|
|
|
trace_col_vecs
|
|
|
|
|
.into_iter()
|
|
|
|
|
.map(|column| PolynomialValues::new(column))
|
|
|
|
|
.collect()
|
|
|
|
|
}
|