noise_functions/modifiers/
sqrt.rs1#[cfg(feature = "nightly-simd")]
2use core::simd::{LaneCount, Simd, SupportedLaneCount};
3
4use crate::{math::sqrt, Noise, Sample};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub struct Sqrt<A> {
11 pub noise: A,
12}
13
14impl<N> Noise for Sqrt<N> {}
15
16impl<const DIM: usize, N> Sample<DIM> for Sqrt<N>
17where
18 N: Sample<DIM>,
19{
20 #[inline]
21 fn sample_with_seed(&self, point: [f32; DIM], seed: i32) -> f32 {
22 sqrt(self.noise.sample_with_seed(point, seed))
23 }
24}
25
26#[cfg(feature = "nightly-simd")]
27impl<const DIM: usize, const LANES: usize, N> Sample<DIM, Simd<f32, LANES>> for Sqrt<N>
28where
29 N: Sample<DIM, Simd<f32, LANES>>,
30 LaneCount<LANES>: SupportedLaneCount,
31{
32 #[inline]
33 fn sample_with_seed(&self, point: Simd<f32, LANES>, seed: i32) -> f32 {
34 sqrt(self.noise.sample_with_seed(point, seed))
35 }
36}