Added codegen folder and scripts for fracF operating in DPW (matrix)

This commit is contained in:
canisio
2026-06-09 16:15:39 -03:00
parent 22c51e1597
commit f64f4fde31
18 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
function [Achirp,AchirpOut,H,scale] = fracF_init(a)
%#codegen
%
% fracF_init
%
% Precompute FrFT coefficients for DPW processing.
%
% INPUT:
% a - FrFT order (single)
%
% OUTPUTS:
% Achirp [1024 x 1]
% AchirpOut [512 x 1]
% H [2048 x 1]
% scale scalar
N = 1024;
pi_s = single(pi);
phi = a * (pi_s/2);
tan_half_phi = tan(phi/2);
sin_phi = sin(phi);
cos_phi = cos(phi);
csc_phi = 1/sin_phi;
cot_phi = cos_phi/sin_phi;
twoDelta = 2*sqrt(single(N)/2);
%% Chirp A
n = single((-N/2:N/2-1).') / twoDelta;
Achirp = exp(-1j*pi_s*(n.^2)*tan_half_phi);
%% Chirp B
m = single((-N:N-1).') / twoDelta;
Bchirp = exp(1j*pi_s*csc_phi*(m.^2));
%% FFT of Chirp B
H = fft(Bchirp);
%% Output chirp
AchirpOut = Achirp(1:2:end);
%% Scale factor
scale = sqrt(1 - 1j*cot_phi) / twoDelta;
%% Force single precision complex
Achirp = complex(single(real(Achirp)), ...
single(imag(Achirp)));
AchirpOut = complex(single(real(AchirpOut)), ...
single(imag(AchirpOut)));
H = complex(single(real(H)), ...
single(imag(H)));
scale = complex(single(real(scale)), ...
single(imag(scale)));
end