Skip to content

Commit

Permalink
poseidon-parameters: remove MatrixOperations::rows and last Vecs
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Apr 1, 2024
1 parent e6633bd commit a7810be
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 56 deletions.
25 changes: 0 additions & 25 deletions poseidon-parameters/src/arc_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ impl<const N_ROWS: usize, const N_COLS: usize, const N_ELEMENTS: usize> MatrixOp
self.0.set_element(i, j, val)
}

fn rows(&self) -> &[&[Fq]] {
self.0.rows()
}

fn n_rows(&self) -> usize {
self.0.n_rows()
}
Expand All @@ -57,23 +53,6 @@ impl<const N_ROWS: usize, const N_COLS: usize, const N_ELEMENTS: usize> MatrixOp
}
}

// impl From<ArcMatrix> for Vec<Vec<Fq, MAX_DIMENSION>, MAX_DIMENSION> {
// fn from(arc: ArcMatrix) -> Self {
// let mut rows = Vec::<Vec<Fq, MAX_DIMENSION>, MAX_DIMENSION>::new();
// let m = &arc.0;

// for i in 0..arc.n_rows() {
// let mut row = Vec::new();
// for j in 0..arc.n_cols() {
// row.push(m.get_element(i, j))
// .expect("capacity should not be exceeded");
// }
// rows.push(row).expect("capacity should not be exceeded");
// }
// rows
// }
// }

/// Represents an optimized matrix of round constants.
///
/// This modifies the partial rounds in the middle of the permutation,
Expand Down Expand Up @@ -115,10 +94,6 @@ impl<const N_ROWS: usize, const N_COLS: usize, const N_ELEMENTS: usize> MatrixOp
self.0.set_element(i, j, val)
}

fn rows(&self) -> &[&[Fq]] {
self.0.rows()
}

fn n_rows(&self) -> usize {
self.0.n_rows()
}
Expand Down
12 changes: 2 additions & 10 deletions poseidon-parameters/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ impl<const N_ROWS: usize, const N_COLS: usize, const N_ELEMENTS: usize> MatrixOp
self.elements[i * N_COLS + j] = val
}

fn rows(&self) -> &[&[Fq]] {
// self.elements.chunks(self.n_cols()).collect()
todo!()
}

fn n_rows(&self) -> usize {
N_ROWS
}
Expand All @@ -93,7 +88,8 @@ impl<const N_ROWS: usize, const N_COLS: usize, const N_ELEMENTS: usize> MatrixOp
}
}

/// Multiply two matrices
#[allow(dead_code)]
/// Multiply two `Matrix`
pub fn mat_mul<
const LHS_N_ROWS: usize,
const LHS_N_COLS: usize,
Expand Down Expand Up @@ -182,10 +178,6 @@ impl<const N_ROWS: usize, const N_ELEMENTS: usize> MatrixOperations
self.0.set_element(i, j, val)
}

fn rows(&self) -> &[&[Fq]] {
todo!()
}

fn n_rows(&self) -> usize {
N_ROWS
}
Expand Down
2 changes: 0 additions & 2 deletions poseidon-parameters/src/matrix_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub trait MatrixOperations {
/// Set element[i,j]
fn set_element(&mut self, i: usize, j: usize, val: Fq);
/// Get rows
fn rows(&self) -> &[&[Fq]];
/// Get rows in chunks
fn iter_rows(&self) -> Chunks<Fq> {
self.elements().chunks(self.n_cols())
}
Expand Down
19 changes: 0 additions & 19 deletions poseidon-parameters/src/mds_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ impl<
self.0.set_element(i, j, val)
}

fn rows(&self) -> &[&[Fq]] {
self.0.rows()
}

fn n_rows(&self) -> usize {
self.0.n_rows()
}
Expand Down Expand Up @@ -129,21 +125,6 @@ impl<
}
}

// impl From<MdsMatrix> for Vec<Vec<Fq, MAX_DIMENSION>, MAX_DIMENSION> {
// fn from(val: MdsMatrix) -> Self {
// let mut rows = Vec::<Vec<Fq, MAX_DIMENSION>, MAX_DIMENSION>::new();
// for i in 0..val.0.n_rows() {
// let mut row = Vec::new();
// for j in 0..val.0.n_rows() {
// row.push(val.0 .0.get_element(i, j))
// .expect("capacity should not be exceeded");
// }
// rows.push(row).expect("capacity should not be exceeded");
// }
// rows
// }
// }

/// Represents an optimized MDS (maximum distance separable) matrix.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct OptimizedMdsMatrices<
Expand Down

0 comments on commit a7810be

Please sign in to comment.