1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use crate::{
    complex::{Complex, Moebius, Quaternion},
    distr::*,
    matrix::Matrix,
    vector::Vector,
};
use core::ops::Neg;
use num_traits::{Float, Num};
use rand_::{distributions::Distribution, Rng};

impl<T> Distribution<Complex<T>> for Normal
where
    Normal: Distribution<Vector<T, 2>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Complex<T> {
        rng.sample(self).into()
    }
}

impl<T: Float> Distribution<Complex<T>> for NonZero
where
    NonZero: Distribution<Vector<T, 2>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Complex<T> {
        rng.sample(Self).into()
    }
}

impl<T: Float> Distribution<Complex<T>> for Unit
where
    Unit: Distribution<Vector<T, 2>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Complex<T> {
        rng.sample(Self).into()
    }
}

impl<T> Distribution<Quaternion<T>> for Normal
where
    Normal: Distribution<Vector<T, 4>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Quaternion<T> {
        rng.sample(self).into()
    }
}

impl<T: Float> Distribution<Quaternion<T>> for NonZero
where
    NonZero: Distribution<Vector<T, 4>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Quaternion<T> {
        rng.sample(Self).into()
    }
}

impl<T: Float> Distribution<Quaternion<T>> for Unit
where
    Unit: Distribution<Vector<T, 4>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Quaternion<T> {
        rng.sample(Self).into()
    }
}

impl<T: Neg<Output = T> + Num + Copy> Distribution<Moebius<T>> for Invertible
where
    Invertible: Distribution<Matrix<T, 2, 2>>,
{
    fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Moebius<T> {
        rng.sample(Invertible).into()
    }
}