pub fn find_pivots_permutation<T: Iterator<Item = usize>>(
        &mut self,
        permutation: T,
    ) -> Vec<usize> {
        let p = self.p;
        let rows = self.rows();
        let mut pivots = Vec::with_capacity(rows);

        if rows == 0 {
            return pivots;
        }

        let mut pivot: usize = 0;
        for pivot_column in permutation {
            // Search down column for a nonzero entry.
            let mut pivot_row = rows;
            for i in pivot..rows {
                if self[i].entry(pivot_column) != 0 {
                    pivot_row = i;
                    break;
                }
            }
            if pivot_row == rows {
                continue;
            }

            // Record position of pivot.
            pivots.push(pivot_column);

            // Pivot_row contains a row with a pivot in current column.
            // Swap pivot row up.
            self.vectors.swap(pivot, pivot_row);
            // println!("({}) <==> ({}): \n{}", pivot, pivot_row, self);

            // // Divide pivot row by pivot entry
            let c = self[pivot].entry(pivot_column);
            let c_inv = prime::inverse(p, c);
            self[pivot].scale(c_inv);
            // println!("({}) <== {} * ({}): \n{}", pivot, c_inv, pivot, self);

            for i in pivot_row + 1..rows {
                // Safety requires i != pivot, which follows from i > pivot_row >= pivot. They are
                // both less than rows by construction
                unsafe { self.row_op(i, pivot, pivot_column, p) };
            }
            pivot += 1;
        }
        pivots
    }
/// This is very similar to row_reduce, except we only need to get to row echelon form, not
/// *reduced* row echelon form. It also returns the list of pivots instead.
This is very similar to row_reduce, except we only need to get to row echelon form, not
reduced* row echelon form. It also returns the list of pivots instead.
This is very similar to row_reduce except we only need to get to row echelon form not reduced * row echelon form . It also returns the list of pivots instead .
pub fn find_pivots_permutation<T: Iterator<Item = usize>>(
        &mut self,
        permutation: T,
    ) -> Vec<usize> {
        let p = self.p;
        let rows = self.rows();
        let mut pivots = Vec::with_capacity(rows);
        if rows == 0 {
            return pivots;
        }
        let mut pivot: usize = 0;
        for pivot_column in permutation {
            // Search down column for a nonzero entry.
            let mut pivot_row = rows;
            for i in pivot..rows {
                if self[i].entry(pivot_column) != 0 {
                    pivot_row = i;
                    break;
                }
            }
            if pivot_row == rows {
                continue;
            }
            // Record position of pivot.
            pivots.push(pivot_column);
            // Pivot_row contains a row with a pivot in current column.
            // Swap pivot row up.
            self.vectors.swap(pivot, pivot_row);
            // println!("({}) <==> ({}): \n{}", pivot, pivot_row, self);
            // // Divide pivot row by pivot entry
            let c = self[pivot].entry(pivot_column);
            let c_inv = prime::inverse(p, c);
            self[pivot].scale(c_inv);
            // println!("({}) <== {} * ({}): \n{}", pivot, c_inv, pivot, self);
            for i in pivot_row + 1..rows {
                // Safety requires i != pivot, which follows from i > pivot_row >= pivot. They are
                // both less than rows by construction
                unsafe { self.row_op(i, pivot, pivot_column, p) };
            }
            pivot += 1;
        }
        pivots
    }
pub fn find_pivots_permutation < T : Iterator < Item = usize > > ( & mut self , permutation : T , ) -> Vec < usize > { let p = self . p ; let rows = self . rows ( ) ; let mut pivots = Vec :: with_capacity ( rows ) ; if rows == 0 { return pivots ; } let mut pivot : usize = 0 ; for pivot_column in permutation { // Search down column for a nonzero entry. let mut pivot_row = rows ; for i in pivot .. rows { if self [ i ] . entry ( pivot_column ) != 0 { pivot_row = i ; break ; } } if pivot_row == rows { continue ; } // Record position of pivot. pivots . push ( pivot_column ) ; // Pivot_row contains a row with a pivot in current column. // Swap pivot row up. self . vectors . swap ( pivot , pivot_row ) ; // println!("({}) <==> ({}): \n{}", pivot, pivot_row, self); // // Divide pivot row by pivot entry let c = self [ pivot ] . entry ( pivot_column ) ; let c_inv = prime :: inverse ( p , c ) ; self [ pivot ] . scale ( c_inv ) ; // println!("({}) <== {} * ({}): \n{}", pivot, c_inv, pivot, self); for i in pivot_row + 1 .. rows { // Safety requires i != pivot, which follows from i > pivot_row >= pivot. They are // both less than rows by construction unsafe { self . row_op ( i , pivot , pivot_column , p ) } ; } pivot += 1 ; } pivots }
This is very similar to row_reduce, except we only need to get to row echelon form, not
reduced* row echelon form.
This is very similar to row_reduce except we only need to get to row echelon form not reduced * row echelon form .
&mut self
permutation
T
&mut self
permutation
T