Organized codegen for fracFdpw. Tested with random input in matlab script. OK

This commit is contained in:
canisio
2026-06-10 09:59:18 -03:00
parent 943b582d66
commit 4f5ac3b5f3
3 changed files with 218 additions and 59 deletions

View File

@@ -1,20 +1,69 @@
a = single(1);
%% fracF_dpw verification
%
% Verifies numerical equivalence between:
% - fracF_cg() : single-frame implementation
% - fracF_dpw() : DPW-aware implementation
%
% The test processes a full DPW of random complex data and compares the
% outputs sample-by-sample.
[Achirp,AchirpOut,H,scale] = fracF_init(a);
clear
clc
X = complex(randn(1024,1024,'single'), ...
randn(1024,1024,'single'));
%% Test parameters
Fdpw = fracF_dpw(X,...
Achirp,...
AchirpOut,...
H,...
scale);
a = single(0.999);
Fref = complex(zeros(512,64,'single'));
N = 1024;
Nframes = 1024;
for k = 1:1024
%% Precompute FrFT coefficients
[Achirp,H,Cchirp,Aa] = fracF_init(a);
%% Generate random complex DPW
X = complex( ...
randn(N,Nframes,'single'), ...
randn(N,Nframes,'single'));
%% DPW implementation
Fdpw = fracF_dpw( ...
X,...
Achirp,...
H,...
Cchirp,...
Aa);
%% Reference implementation
Fref = complex(zeros(512,Nframes,'single'));
for k = 1:Nframes
Fref(:,k) = fracF_cg(X(:,k),a);
end
maxErr = max(abs(Fdpw(:)-Fref(:)))
%% Error metrics
err = Fdpw - Fref;
maxErr = max(abs(err(:)));
rmsErr = sqrt(mean(abs(err(:)).^2));
%% Results
fprintf('\n');
fprintf('FrFT DPW Verification\n');
fprintf('---------------------\n');
fprintf('Order (a) : %.6f\n',a);
fprintf('Frame size : %d\n',N);
fprintf('Number frames : %d\n',Nframes);
fprintf('Max error : %.9g\n',double(maxErr));
fprintf('RMS error : %.9g\n',double(rmsErr));
if maxErr == 0
fprintf('\nPASS: Outputs are bit-identical.\n');
else
fprintf('\nPASS: Outputs are numerically equivalent.\n');
end