use tenferro_tensor::DType;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum FftNorm {
#[default]
Backward,
Forward,
Ortho,
}
impl FftNorm {
#[cfg(feature = "autodiff")]
pub(crate) fn c2c_adjoint(self) -> Self {
match self {
Self::Backward => Self::Forward,
Self::Forward => Self::Backward,
Self::Ortho => Self::Ortho,
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum FftOperation {
C2cForward,
C2cInverse,
R2cFull,
R2cOnesided,
C2r,
}
impl FftOperation {
pub(crate) const fn is_c2c(self) -> bool {
matches!(self, Self::C2cForward | Self::C2cInverse)
}
pub(crate) const fn is_forward(self) -> bool {
matches!(self, Self::C2cForward | Self::R2cFull | Self::R2cOnesided)
}
pub(crate) const fn is_onesided(self) -> bool {
matches!(self, Self::R2cOnesided)
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct FftPlanSpec {
operation: FftOperation,
normalized_axis: usize,
requested_len: Option<usize>,
norm: FftNorm,
input_dtype: DType,
input_shape: Vec<usize>,
requires_compact_column_major: bool,
}
impl FftPlanSpec {
pub(crate) fn new(
operation: FftOperation,
normalized_axis: usize,
requested_len: Option<usize>,
norm: FftNorm,
input_dtype: DType,
input_shape: Vec<usize>,
) -> Self {
Self {
operation,
normalized_axis,
requested_len,
norm,
input_dtype,
input_shape,
requires_compact_column_major: true,
}
}
pub const fn operation(&self) -> FftOperation {
self.operation
}
pub const fn normalized_axis(&self) -> usize {
self.normalized_axis
}
pub const fn requested_len(&self) -> Option<usize> {
self.requested_len
}
pub const fn norm(&self) -> FftNorm {
self.norm
}
pub const fn input_dtype(&self) -> DType {
self.input_dtype
}
pub fn input_shape(&self) -> &[usize] {
&self.input_shape
}
pub const fn requires_compact_column_major(&self) -> bool {
self.requires_compact_column_major
}
}