Skip to main content

TensorFftExt

Trait TensorFftExt 

Source
pub trait TensorFftExt {
    // Required methods
    fn fft(
        &self,
        n: Option<usize>,
        axis: isize,
        norm: FftNorm,
        session: &mut dyn BackendSession,
    ) -> Result<Tensor>;
    fn ifft(
        &self,
        n: Option<usize>,
        axis: isize,
        norm: FftNorm,
        session: &mut dyn BackendSession,
    ) -> Result<Tensor>;
    fn rfft(
        &self,
        n: Option<usize>,
        axis: isize,
        norm: FftNorm,
        session: &mut dyn BackendSession,
    ) -> Result<Tensor>;
    fn irfft(
        &self,
        n: Option<usize>,
        axis: isize,
        norm: FftNorm,
        session: &mut dyn BackendSession,
    ) -> Result<Tensor>;
}
Expand description

Backend-explicit FFT methods for concrete Tensor values.

This is the non-AD immediate execution surface. It uses unsuffixed method names because the receiver is an owned compact tensor value. Use TensorReadFftExt when the input is a borrowed view or other TensorRead value.

Direct calls intentionally use a call-local one-shot FFT plan cache. Use FftExecutor for repeated concrete calls with stable transform lengths, or traced/runtime execution when the runtime should own the extension cache.

§Examples

use num_complex::Complex64;
use tenferro_cpu::CpuBackend;
use tenferro_fft::{FftNorm, TensorFftExt};
use tenferro_tensor::{BackendSessionHost, Tensor};

let input = Tensor::from_vec_col_major(vec![4], vec![1.0_f64, 2.0, 3.0, 4.0])?;
let mut backend = CpuBackend::new();

let spectrum = backend
    .with_backend_session(|session| input.fft(None, -1, FftNorm::Backward, session))?;
assert_eq!(spectrum.shape(), &[4]);
assert_eq!(spectrum.as_slice::<Complex64>()?[0], Complex64::new(10.0, 0.0));

Required Methods§

Source

fn fft( &self, n: Option<usize>, axis: isize, norm: FftNorm, session: &mut dyn BackendSession, ) -> Result<Tensor>

Execute a one-dimensional FFT along axis.

§Errors

Returns Error::Validation with AxisOutOfBounds or InvalidArgument for axis/n, Error::Extension with ErrorKind::Unsupported for an integer or boolean input, a typed capability error when the session does not expose an FFT execution capability, or a typed backend source for execution.

Source

fn ifft( &self, n: Option<usize>, axis: isize, norm: FftNorm, session: &mut dyn BackendSession, ) -> Result<Tensor>

Execute a one-dimensional inverse FFT along axis.

§Errors

Returns Error::Validation with AxisOutOfBounds or InvalidArgument for axis/n, Error::Extension with ErrorKind::Unsupported for a non-complex input, a typed capability error when the session does not expose an FFT execution capability, or a typed backend source for execution.

Source

fn rfft( &self, n: Option<usize>, axis: isize, norm: FftNorm, session: &mut dyn BackendSession, ) -> Result<Tensor>

Execute a one-dimensional real FFT along axis.

§Errors

Returns Error::Validation with AxisOutOfBounds or InvalidArgument for axis/n, Error::Extension with ErrorKind::Unsupported for a non-F32/F64 input, a typed capability error when the session does not expose an FFT execution capability, or a typed backend source for execution.

Source

fn irfft( &self, n: Option<usize>, axis: isize, norm: FftNorm, session: &mut dyn BackendSession, ) -> Result<Tensor>

Execute a one-dimensional inverse real FFT along axis.

§Errors

Returns Error::Validation with AxisOutOfBounds, InvalidArgument, or spectrum-length details, Error::Extension with ErrorKind::Unsupported for a non-complex input, a typed capability error when the session does not expose an FFT execution capability, or a typed backend source for execution.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§