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
use necsim_core::{
    cogs::{Habitat, MathsCore, SpeciationProbability},
    landscape::Location,
};
use necsim_core_bond::ClosedUnitF64;

#[derive(Clone, Debug)]
#[cfg_attr(feature = "cuda", derive(rust_cuda::lend::LendRustToCuda))]
#[allow(clippy::module_name_repetitions)]
pub struct UniformSpeciationProbability {
    speciation_probability: ClosedUnitF64,
}

impl UniformSpeciationProbability {
    #[must_use]
    pub fn new(speciation_probability: ClosedUnitF64) -> Self {
        Self {
            speciation_probability,
        }
    }
}

#[contract_trait]
impl<M: MathsCore, H: Habitat<M>> SpeciationProbability<M, H> for UniformSpeciationProbability {
    #[must_use]
    #[inline]
    fn get_speciation_probability_at_location(
        &self,
        _location: &Location,
        _habitat: &H,
    ) -> ClosedUnitF64 {
        self.speciation_probability
    }
}