Add WeightMatrix::from_fn()
This commit is contained in:
parent
188dc61817
commit
7abc850887
@ -49,6 +49,11 @@ impl<T: WeightNum> WeightMatrix<T> {
|
|||||||
WeightMatrix { c: SquareMatrix::from_row_vec(n, data) }
|
WeightMatrix { c: SquareMatrix::from_row_vec(n, data) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_fn<F: Fn((usize, usize)) -> T>(n: usize, f: F) -> WeightMatrix<T> {
|
||||||
|
assert!(n > 0);
|
||||||
|
WeightMatrix { c: SquareMatrix::from_fn(n, f) }
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn n(&self) -> usize {
|
fn n(&self) -> usize {
|
||||||
self.c.n()
|
self.c.n()
|
||||||
|
Loading…
Reference in New Issue
Block a user