graph TD
A[Start] --> B[Initialize Variables and Allocate Memory]
B --> C[Check Memory Allocation]
C --> D[Quantize Feed-Forward Coefficients]
D --> E[Initialize norm_factor Array]
E --> F[Apply Filter to Compute Stable SDFT]
F --> G[Apply Filter Coefficients to Compute y_real and y_imag]
G --> H[Normalize Output]
H --> I[Convert Results to NumPy Array]
I --> J[Free Allocated Memory]
J --> K[Return Result]
subgraph "Filter Application Loop"
direction LR
F --> L[Loop Over Each Sample]
L --> M[Compute y_real and y_imag]
end
subgraph "Normalization and Conversion"
direction LR
H --> N[Loop Over Each Sample for Normalization]
N --> O[Normalize y_real and y_imag]
O --> P[Convert to NumPy Array]
end
-
Start
- Initialization of the
cython_stable_sdft
function.
- Initialization of the
-
Initialize Variables and Allocate Memory
- Initialize necessary variables such as
y_real
,y_imag
,norm_factor
,exp_factor_real
,exp_factor_imag
,cos_factor
,B_real
,B_imag
, andA
. - Allocate memory for
y_real
,y_imag
, andnorm_factor
.
- Initialize necessary variables such as
-
Check Memory Allocation
- Check if memory allocation was successful. If not, raise a
MemoryError
.
- Check if memory allocation was successful. If not, raise a
-
Compute Quantized Coefficients
- Compute and quantize the coefficients for the filter:
exp_factor_real
andexp_factor_imag
for the exponential factor.cos_factor
for the cosine factor.
- Quantize these coefficients to ensure precision.
- Compute and quantize the coefficients for the filter:
-
Initialize norm_factor Array
- Initialize the
norm_factor
array to 1.0 (simplified normalization).
- Initialize the
-
Apply Filter to Compute Stable SDFT
- Apply the filter to compute the stable SDFT for each sample in the signal:
- Loop over each sample in the signal:
- Compute y_real and y_imag for Each Sample
- For each sample, compute the real part (
y_real
) and imaginary part (y_imag
) of the output using the quantized coefficients and previous samples. - Apply feedback using the
A
coefficients.
- For each sample, compute the real part (
- Compute y_real and y_imag for Each Sample
- Loop over each sample in the signal:
- Apply the filter to compute the stable SDFT for each sample in the signal:
-
Normalize Output
- Normalize the output by dividing
y_real
andy_imag
by thenorm_factor
.
- Normalize the output by dividing
-
Convert Results to NumPy Array
- Convert the results (
y_real
andy_imag
) to a NumPy array of complex numbers.
- Convert the results (
-
Free Allocated Memory
- Free the allocated memory for
y_real
,y_imag
, andnorm_factor
.
- Free the allocated memory for
-
Return Result
- Return the final result as a NumPy array of complex numbers.