pub trait FftRepr: Repr {
type Complex;
type Real;
// Required methods
fn wrap_complex(t: Tensor) -> Result<Self::Complex>;
fn wrap_real(t: Tensor) -> Result<Self::Real>;
}Expand description
How an FFT result is returned for an input representation.
Erased returns Tensor. Typed<T> returns TypedTensor<T::Complex>
for spectra (fft, ifft, rfft and their N-dimensional forms) and
TypedTensor<T::Real> for irfft/irfftn.
§Examples
use num_complex::Complex64;
use tenferro_fft::FftRepr;
use tenferro_tensor::{Erased, Tensor, Typed};
let t = Tensor::from_vec_col_major(vec![1], vec![Complex64::new(1.0, 0.0)])?;
let typed = <Typed<f64> as FftRepr>::wrap_complex(t)?;
assert_eq!(typed.shape(), &[1]);
let t = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Erased as FftRepr>::wrap_real(t).is_ok());Required Associated Types§
Required Methods§
Sourcefn wrap_complex(t: Tensor) -> Result<Self::Complex>
fn wrap_complex(t: Tensor) -> Result<Self::Complex>
Wrap an erased complex result; typed representations downcast with a check.
§Errors
Returns Error::Internal when a typed representation receives a
tensor of another dtype.
§Examples
use num_complex::Complex64;
use tenferro_fft::FftRepr;
use tenferro_tensor::{Tensor, Typed};
let c = Tensor::from_vec_col_major(vec![1], vec![Complex64::new(1.0, 0.0)])?;
assert!(<Typed<f64> as FftRepr>::wrap_complex(c).is_ok());
let r = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Typed<f64> as FftRepr>::wrap_complex(r).is_err());Sourcefn wrap_real(t: Tensor) -> Result<Self::Real>
fn wrap_real(t: Tensor) -> Result<Self::Real>
Wrap an erased real result; typed representations downcast with a check.
§Errors
Returns Error::Internal when a typed representation receives a
tensor of another dtype.
§Examples
use tenferro_fft::FftRepr;
use tenferro_tensor::{Tensor, Typed};
let r = Tensor::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert!(<Typed<f64> as FftRepr>::wrap_real(r.duplicate()?).is_ok());
assert!(<Typed<f32> as FftRepr>::wrap_real(r).is_err());Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".