concision_core/params/impls/
impl_init.rs

1/*
2    appellation: impl_init <module>
3    authors: @FL03
4*/
5use crate::params::ParamsBase;
6
7use ndarray::{Dimension, RawData, ScalarOperand};
8use num_traits::{Float, FromPrimitive};
9
10impl<A, S, D> ParamsBase<S, D>
11where
12    A: Float + FromPrimitive + ScalarOperand,
13    D: Dimension,
14    S: RawData<Elem = A>,
15{
16    #[cfg(feature = "rand")]
17    pub fn init_rand<G, Dst, Sh>(shape: Sh, distr: G) -> Self
18    where
19        D: ndarray::RemoveAxis,
20        S: ndarray::DataOwned,
21        Sh: ndarray::ShapeBuilder<Dim = D>,
22        Dst: Clone + rand_distr::Distribution<A>,
23        G: Fn(&Sh) -> Dst,
24    {
25        use crate::init::Initialize;
26        let dist = distr(&shape);
27        Self::rand(shape, dist)
28    }
29}