pub struct BlackBoxMatrixImpl<R, F> {
shape: (usize, usize),
apply_fn: F,
_marker: PhantomData<fn() -> R>,
}Fields§
§shape: (usize, usize)§apply_fn: F§_marker: PhantomData<fn() -> R>Implementations§
Source§impl<R, F> BlackBoxMatrixImpl<R, F>
impl<R, F> BlackBoxMatrixImpl<R, F>
Sourcepub fn new(shape: (usize, usize), apply_fn: F) -> Self
pub fn new(shape: (usize, usize), apply_fn: F) -> Self
Examples found in repository?
crates/competitive/src/math/black_box_mint_matrix.rs (lines 60-66)
53 fn black_box_determinant(&self) -> MInt<M> {
54 assert_eq!(self.shape().0, self.shape().1);
55 let n = self.shape().0;
56 let mut rng = Xorshift::new();
57 let d: Vec<MInt<M>> = (0..n).map(|_| MInt::from(rng.rand64())).collect();
58 let det_d = d.iter().fold(MInt::one(), |s, x| s * x);
59 let ad: BlackBoxMatrixImpl<AddMulOperation<MInt<M>>, _> =
60 BlackBoxMatrixImpl::new(self.shape(), |v: &[MInt<M>]| {
61 let mut w = self.apply(v);
62 for (w, d) in w.iter_mut().zip(&d) {
63 *w *= d;
64 }
65 w
66 });
67 let p = ad.minimal_polynomial();
68 let det_ad = if n % 2 == 0 { p[0] } else { -p[0] };
69 det_ad / det_d
70 }Trait Implementations§
Source§impl<R, F> BlackBoxMatrix<R> for BlackBoxMatrixImpl<R, F>
impl<R, F> BlackBoxMatrix<R> for BlackBoxMatrixImpl<R, F>
Source§impl<R, F> Clone for BlackBoxMatrixImpl<R, F>where
F: Clone,
impl<R, F> Clone for BlackBoxMatrixImpl<R, F>where
F: Clone,
Auto Trait Implementations§
impl<R, F> Freeze for BlackBoxMatrixImpl<R, F>
impl<R, F> RefUnwindSafe for BlackBoxMatrixImpl<R, F>
impl<R, F> Send for BlackBoxMatrixImpl<R, F>
impl<R, F> Sync for BlackBoxMatrixImpl<R, F>
impl<R, F> Unpin for BlackBoxMatrixImpl<R, F>
impl<R, F> UnsafeUnpin for BlackBoxMatrixImpl<R, F>
impl<R, F> UnwindSafe for BlackBoxMatrixImpl<R, F>
Blanket Implementations§
Source§impl<M, B> BlackBoxMIntMatrix<M> for Bwhere
M: MIntDotProduct<Inner = u32> + MIntConvert<u32> + MIntConvert<u64> + MIntConvert<usize> + MIntConvert<isize>,
B: BlackBoxMatrix<AddMulOperation<MInt<M>>>,
impl<M, B> BlackBoxMIntMatrix<M> for Bwhere
M: MIntDotProduct<Inner = u32> + MIntConvert<u32> + MIntConvert<u64> + MIntConvert<usize> + MIntConvert<isize>,
B: BlackBoxMatrix<AddMulOperation<MInt<M>>>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more