1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
use hpt_common::axis::axis::Axis;
use hpt_common::error::base::TensorError;
use hpt_common::shape::shape::Shape;
/// A trait for Fast Fourier Transform (FFT) operations.
pub trait FFTOps
where
Self: Sized,
{
/// Computes the Fast Fourier Transform (FFT) of the tensor along a specified axis.
///
/// The `fft` function computes the one-dimensional discrete Fourier Transform of the input tensor,
/// converting the signal from the time domain to the frequency domain.
///
/// # Parameters
///
/// - `axis`: The axis along which to compute the FFT.
#[track_caller]
fn fft(&self, n: usize, axis: i64, norm: Option<&str>) -> Result<Self, TensorError>;
/// Computes the inverse Fast Fourier Transform (IFFT) of the tensor along a specified axis.
///
/// The `ifft` function computes the one-dimensional inverse discrete Fourier Transform of the input tensor,
/// converting the signal from the frequency domain back to the time domain.
///
/// # Parameters
///
/// - `axis`: The axis along which to compute the IFFT.
///
/// # Returns
///
/// - `anyhow::Result<_Tensor<FloatType<T>>>`: A tensor of real numbers representing the time-domain signal.
///
/// # Notes
///
/// - **Inverse Fourier Transform**: Converts frequency-domain signals back to the time domain.
/// - **Axis Specification**: The IFFT is computed along the specified axis.
///
/// # See Also
///
/// - [`fft`]: Computes the FFT of the tensor.
/// - [`ifft2`]: Computes the 2D inverse FFT of the tensor.
#[track_caller]
fn ifft(&self, n: usize, axis: i64, norm: Option<&str>) -> Result<Self, TensorError>;
/// Computes the 2D Fast Fourier Transform (FFT2) of the tensor.
///
/// The `fft2` function computes the two-dimensional discrete Fourier Transform of the input tensor,
/// converting the signal from the time domain to the frequency domain in two dimensions.
///
/// # Returns
///
/// - `anyhow::Result<_Tensor<ComplexType<T>>>`: A tensor of complex numbers representing the frequency components.
///
/// # Notes
///
/// - **Fourier Transform**: Converts 2D time-domain signals to frequency-domain signals.
/// - **Multidimensional**: Operates over two axes at once.
///
/// # See Also
///
/// - [`ifft2`]: Computes the 2D inverse FFT of the tensor.
/// - [`fft`]: Computes the 1D FFT of the tensor.
#[track_caller]
fn fft2<S: Into<Shape>>(
&self,
s: S,
axis1: i64,
axis2: i64,
norm: Option<&str>,
) -> Result<Self, TensorError>;
/// Computes the 2D inverse Fast Fourier Transform (IFFT2) of the tensor.
///
/// The `ifft2` function computes the two-dimensional inverse discrete Fourier Transform of the input tensor,
/// converting the signal from the frequency domain back to the time domain in two dimensions.
///
/// # Returns
///
/// - `anyhow::Result<_Tensor<FloatType<T>>>`: A tensor of real numbers representing the time-domain signal.
///
/// # Notes
///
/// - **Inverse Fourier Transform**: Converts 2D frequency-domain signals back to the time domain.
/// - **Multidimensional**: Operates over two axes at once.
///
/// # See Also
///
/// - [`fft2`]: Computes the 2D FFT of the tensor.
/// - [`ifft`]: Computes the 1D inverse FFT of the tensor.
#[track_caller]
fn ifft2<S: Into<Shape>>(
&self,
s: S,
axis1: i64,
axis2: i64,
norm: Option<&str>,
) -> Result<Self, TensorError>;
/// Computes the N-dimensional Fast Fourier Transform (FFTN) of the tensor.
///
/// The `fftn` function computes the N-dimensional discrete Fourier Transform of the input tensor,
/// converting the signal from the time domain to the frequency domain in N dimensions.
///
/// # Returns
///
/// - `anyhow::Result<_Tensor<ComplexType<T>>>`: A tensor of complex numbers representing the frequency components.
///
/// # Notes
///
/// - **Fourier Transform**: Converts N-dimensional time-domain signals to frequency-domain signals.
/// - **Multidimensional**: Operates over multiple axes at once.
///
/// # See Also
///
/// - [`ifftn`]: Computes the N-dimensional inverse FFT of the tensor.
/// - [`fft2`]: Computes the 2D FFT of the tensor.
#[track_caller]
fn fftn<A: Into<Axis>, S: Into<Shape>>(
&self,
s: S,
axes: A,
norm: Option<&str>,
) -> Result<Self, TensorError>;
/// Computes the N-dimensional inverse Fast Fourier Transform (IFFTN) of the tensor.
///
/// The `ifftn` function computes the N-dimensional inverse discrete Fourier Transform of the input tensor,
/// converting the signal from the frequency domain back to the time domain in N dimensions.
///
/// # Returns
///
/// - `anyhow::Result<_Tensor<FloatType<T>>>`: A tensor of real numbers representing the time-domain signal.
///
/// # Notes
///
/// - **Inverse Fourier Transform**: Converts N-dimensional frequency-domain signals back to the time domain.
/// - **Multidimensional**: Operates over multiple axes at once.
///
/// # See Also
///
/// - [`fftn`]: Computes the N-dimensional FFT of the tensor.
/// - [`ifft2`]: Computes the 2D inverse FFT of the tensor.
#[track_caller]
fn ifftn<A: Into<Axis>, S: Into<Shape>>(
&self,
s: S,
axes: A,
norm: Option<&str>,
) -> Result<Self, TensorError>;
}