diff --git a/src/lib.rs b/src/lib.rs index 31abcef..a653b7f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,6 +49,11 @@ impl WeightMatrix { WeightMatrix { c: SquareMatrix::from_row_vec(n, data) } } + pub fn from_fn T>(n: usize, f: F) -> WeightMatrix { + assert!(n > 0); + WeightMatrix { c: SquareMatrix::from_fn(n, f) } + } + #[inline(always)] fn n(&self) -> usize { self.c.n()