Skip to content

Commit

Permalink
use Vec<u32> as the permutation vector
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbull committed Dec 6, 2024
1 parent 47d2962 commit ed38545
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/tensors/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ impl<F: Field> Matrix<F> {
fn lu_decomposition(
&self,
early_return: bool,
) -> Result<(Self, Self, Vector<Z>), MatrixError<F>> {
) -> Result<(Self, Self, Vec<u32>), MatrixError<F>> {
let mut u = self.clone();
let (l, p) = u.lu_decomposition_in_place(early_return)?;
Ok((l, u, p))
Expand All @@ -1252,13 +1252,13 @@ impl<F: Field> Matrix<F> {
fn lu_decomposition_in_place(
&mut self,
early_return: bool,
) -> Result<(Self, Vector<Z>), MatrixError<F>> {
) -> Result<(Self, Vec<u32>), MatrixError<F>> {
let one = self.field.one();

let (_, steps) = self.gaussian_elimination_ex(self.ncols as u32, early_return, true)?;
let steps = steps.expect("Internal Error: steps must be Some");

let mut pv: Vec<usize> = (0..self.nrows as usize).collect();
let mut pv: Vec<u32> = (0..self.nrows).collect();
for &(i, k, ref multiplier) in &steps {
if *multiplier == one {
pv.swap(i as usize, k as usize);
Expand All @@ -1272,11 +1272,7 @@ impl<F: Field> Matrix<F> {
}
}

let mut p_data = Vec::new();
for el in pv {
p_data.push(Integer::from(el));
}
Ok((l, Vector::new(p_data, Z)))
Ok((l, pv))
}

/// Write the matrix in echelon form.
Expand Down

0 comments on commit ed38545

Please sign in to comment.