#![allow(clippy::items_after_statements)]
#![allow(clippy::large_stack_arrays)]
use core::any::TypeId;
use crate::kernel::{Complex, Float};
use crate::simd::{detect_simd_level, SimdLevel};
pub(crate) mod backends;
mod large_sizes;
mod small_sizes;
#[cfg(test)]
mod tests;
pub use large_sizes::*;
pub use small_sizes::*;
#[inline]
pub fn simd_available() -> bool {
let level = detect_simd_level();
matches!(
level,
SimdLevel::Sse2 | SimdLevel::Avx | SimdLevel::Avx2 | SimdLevel::Avx512 | SimdLevel::Neon
)
}
#[inline]
pub fn notw_2_dispatch<T: Float>(x: &mut [Complex<T>]) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_2_simd_f64(x_f64);
return;
}
super::notw_2(x);
}
#[inline]
pub fn notw_4_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_4_simd_f64(x_f64, sign);
return;
}
super::notw_4(x, sign);
}
#[inline]
pub fn notw_8_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_8_simd_f64(x_f64, sign);
return;
}
super::notw_8(x, sign);
}
#[inline]
pub fn notw_16_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_16_simd_f64(x_f64, sign);
return;
}
super::notw_16(x, sign);
}
#[inline]
pub fn notw_32_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_32_simd_f64(x_f64, sign);
return;
}
super::notw_32(x, sign);
}
#[inline]
pub fn notw_64_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_64_simd_f64(x_f64, sign);
return;
}
super::notw_64(x, sign);
}
#[inline]
pub fn notw_128_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_128_simd_f64(x_f64, sign);
return;
}
super::notw_128(x, sign);
}
#[inline]
pub fn notw_256_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_256_simd_f64(x_f64, sign);
return;
}
super::notw_256(x, sign);
}
#[inline]
pub fn notw_512_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_512_simd_f64(x_f64, sign);
return;
}
use crate::dft::problem::Sign;
use crate::dft::solvers::CooleyTukeySolver;
let sign_enum = if sign < 0 {
Sign::Forward
} else {
Sign::Backward
};
CooleyTukeySolver::default().execute_dit_inplace(x, sign_enum);
}
#[inline]
pub fn notw_1024_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_1024_simd_f64(x_f64, sign);
return;
}
use crate::dft::problem::Sign;
use crate::dft::solvers::CooleyTukeySolver;
let sign_enum = if sign < 0 {
Sign::Forward
} else {
Sign::Backward
};
CooleyTukeySolver::default().execute_dit_inplace(x, sign_enum);
}
#[inline]
pub fn notw_4096_dispatch<T: Float>(x: &mut [Complex<T>], sign: i32) {
if TypeId::of::<T>() == TypeId::of::<f64>() {
let x_f64 = unsafe {
core::slice::from_raw_parts_mut(x.as_mut_ptr().cast::<Complex<f64>>(), x.len())
};
notw_4096_simd_f64(x_f64, sign);
return;
}
use crate::dft::problem::Sign;
use crate::dft::solvers::CooleyTukeySolver;
let sign_enum = if sign < 0 {
Sign::Forward
} else {
Sign::Backward
};
CooleyTukeySolver::default().execute_dit_inplace(x, sign_enum);
}