diff --git a/sbp/src/euler.rs b/sbp/src/euler.rs index 1181597..a2aea48 100644 --- a/sbp/src/euler.rs +++ b/sbp/src/euler.rs @@ -252,10 +252,7 @@ impl Field { x in x, y in y) { - #[cfg(feature = "f32")] - use std::f32::consts::PI; - #[cfg(not(feature = "f32"))] - use std::f64::consts::PI; + use crate::consts::PI; let dx = (x - vortex_param.x0) - t; let dy = y - vortex_param.y0; diff --git a/sbp/src/lib.rs b/sbp/src/lib.rs index 9438284..9b361fd 100644 --- a/sbp/src/lib.rs +++ b/sbp/src/lib.rs @@ -3,6 +3,13 @@ pub type Float = f32; #[cfg(not(feature = "f32"))] pub type Float = f64; +pub(crate) mod consts { + #[cfg(feature = "f32")] + pub(crate) use std::f32::consts::*; + #[cfg(not(feature = "f32"))] + pub(crate) use std::f64::consts::*; +} + pub mod euler; pub mod grid; pub mod integrate; diff --git a/sbp/src/maxwell.rs b/sbp/src/maxwell.rs index ac46dc3..21e3a06 100644 --- a/sbp/src/maxwell.rs +++ b/sbp/src/maxwell.rs @@ -142,10 +142,7 @@ impl System { } fn gaussian(x: Float, x0: Float, y: Float, y0: Float) -> Float { - #[cfg(feature = "f32")] - use std::f32::consts::PI; - #[cfg(not(feature = "f32"))] - use std::f64::consts::PI; + use crate::consts::PI; let x = x - x0; let y = y - y0; diff --git a/sbp/src/operators/upwind4.rs b/sbp/src/operators/upwind4.rs index 34aea39..83d5d8c 100644 --- a/sbp/src/operators/upwind4.rs +++ b/sbp/src/operators/upwind4.rs @@ -26,10 +26,6 @@ macro_rules! diff_simd_row_7_47 { impl $self { #[inline(never)] fn $name(prev: ArrayView2, mut fut: ArrayViewMut2) { - #[cfg(feature = "f32")] - type SimdIndex = packed_simd::u32x8; - #[cfg(not(feature = "f32"))] - type SimdIndex = packed_simd::u64x8; assert_eq!(prev.shape(), fut.shape()); assert!(prev.len_of(Axis(1)) >= 2 * $BLOCK.len()); assert!(prev.len() >= SimdT::lanes()); @@ -98,7 +94,7 @@ macro_rules! diff_simd_row_7_47 { let last_elems = unsafe { SimdT::from_slice_unaligned_unchecked(&prev[nx - 8..]) } - .shuffle1_dyn(SimdIndex::new(7, 6, 5, 4, 3, 2, 1, 0)); + .shuffle1_dyn([7, 6, 5, 4, 3, 2, 1, 0].into()); if $symmetric { fut[nx - 4] = idx * (block[3] * last_elems).sum(); fut[nx - 3] = idx * (block[2] * last_elems).sum();