Skip to main content

EchelonRow

Struct EchelonRow 

Source
struct EchelonRow<M>
where M: MIntDotProduct,
{ pivot: usize, inv: MInt<M>, row: Vec<MInt<M>>, }

Fields§

§pivot: usize§inv: MInt<M>§row: Vec<MInt<M>>

Implementations§

Source§

impl<M> EchelonRow<M>
where M: MIntDotProduct,

Source

fn reduce(&self, row: &mut [MInt<M>])

Examples found in repository?
crates/competitive/src/math/mint_matrix.rs (line 184)
168fn generate_frobenius_block<M>(
169    a: &Matrix<AddMulOperation<MInt<M>>>,
170    mut v: Vec<MInt<M>>,
171    rows: &mut Vec<EchelonRow<M>>,
172    t: &mut Vec<Vec<MInt<M>>>,
173) -> Polynomial<M>
174where
175    M: MIntDotProduct,
176{
177    let n = a.shape.0;
178    loop {
179        let mut row = vec![MInt::zero(); n + rows.len() + 1];
180        let (x, c) = row.split_at_mut(n);
181        x.copy_from_slice(&v);
182        c[rows.len()] = MInt::one();
183        for r in rows.iter() {
184            r.reduce(&mut row);
185        }
186        if let Some(pivot) = row[..n].iter().position(|x| !x.is_zero()) {
187            t.push(v);
188            let u = t.last().unwrap();
189            v = a.data.iter().map(|row| MInt::dot_product(u, row)).collect();
190            rows.push(EchelonRow {
191                pivot,
192                inv: row[pivot].inv(),
193                row,
194            });
195        } else {
196            let mut p = row.split_off(n);
197            while p.last().is_some_and(|x| x.is_zero()) {
198                p.pop();
199            }
200            return Polynomial(p);
201        }
202    }
203}

Auto Trait Implementations§

§

impl<M> Freeze for EchelonRow<M>
where MInt<M>: Freeze, Vec<MInt<M>>: Freeze,

§

impl<M> RefUnwindSafe for EchelonRow<M>

§

impl<M> Send for EchelonRow<M>
where MInt<M>: Send, Vec<MInt<M>>: Send,

§

impl<M> Sync for EchelonRow<M>
where MInt<M>: Sync, Vec<MInt<M>>: Sync,

§

impl<M> Unpin for EchelonRow<M>
where MInt<M>: Unpin, Vec<MInt<M>>: Unpin,

§

impl<M> UnsafeUnpin for EchelonRow<M>

§

impl<M> UnwindSafe for EchelonRow<M>
where MInt<M>: UnwindSafe, Vec<MInt<M>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToArrayVecScalar for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.