Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/ltfat/ltfat
Browse files Browse the repository at this point in the history
  • Loading branch information
allthatsounds committed Oct 16, 2023
2 parents 8d97f53 + fbbcfac commit 9bfc58f
Show file tree
Hide file tree
Showing 14 changed files with 444 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ltfat_automated_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Update submodules
run: git submodule update --init
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
- name: Run tests
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/unlocbox"]
path = thirdparty/unlocbox
url = https://github.com/epfl-lts2/unlocbox.git
35 changes: 26 additions & 9 deletions gabor/gabconvexopt.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
% Date : 18 Feb 2014


if nargin<4
if nargin<3
error('%s: Too few input parameters.',upper(mfilename));
end;

Expand Down Expand Up @@ -375,9 +375,18 @@
else
% - projection on a B2 ball -
% Frame-type matrix of the adjoint lattice
%G=tfmat('dgt',glong,M,a);
Fal=frame('dgt',glong,M,a);
G=framematrix(Fal,L);
%switching the role of a and M (see ltfatnote 020)
Ncoef = a/M*L;
lt = [0 1];
do_timeinv = 0;
tmpf = zeros(Ncoef,1); tmpf(1) = 1;
G = zeros(L,Ncoef);
for n = 1:Ncoef
coef = reshape(tmpf, [a, size(tmpf,1)/a,size(tmpf,2)]);
G(:,n) = comp_idgt(coef,g,M, lt, do_timeinv, 0);
tmpf = circshift(tmpf,1);
end
%assert(norm(Gold-G)< 10^(-15))
d=[a/M;zeros(a*b-1,1)];

% Using a B2 ball projection
Expand Down Expand Up @@ -415,16 +424,24 @@
paramPOCS.tol=20*eps;
paramPOCS.maxit=5000;
paramPOCS.verbose=flags.do_print+flags.do_debug;
paramPOCS.abs_tol=1;
%paramPOCS.abs_tol=1;
g5.prox = @(x,T) pocs(x,G,paramPOCS);
% g5.prox = @(x,T) ppxa(x,G,paramPOCS);
% g5.prox = @(x,T) douglas_rachford(x,g2,g4,paramPOCS);
% g5.prox = @(x,T) pocs2(x,g2,g4,20*eps,2000, flags.do_print+flags.do_debug);
g5.eval = @(x) 0;

else
Fal=frame('dgt',glong,M,a);
G=framematrix(Fal,L);
%switching the role of a and M (see ltfatnote 020)
Ncoef = a/M*L;
lt = [0 1];
do_timeinv = 0;
tmpf = zeros(Ncoef,1); tmpf(1) = 1;
for n = 1:Ncoef
coef = reshape(tmpf, [a, size(tmpf,1)/a,size(tmpf,2)]);
G(:,n) = comp_idgt(coef,g,M, lt, do_timeinv, 0);
tmpf = circshift(tmpf,1);
end
d=[a/M;zeros(a*b-1,1)];
Lfirst=ceil(Ldual/2);
Llast=Ldual-Lfirst;
Expand Down Expand Up @@ -604,8 +621,8 @@
% solving the problem

if nb_priors
[gd,iter,~]=ppxa(xin,F,param);

[gd,info]=ppxa(xin,F,param);
iter = info.iter;
% Force the hard constraint
if flags.do_hardconstraint
% In case of use of the douglas rachford algo instead of POCS
Expand Down
2 changes: 1 addition & 1 deletion gabor/gaboptdual.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
% Author: Nathanael Perraudin
% Date : 18 Feb 2014

if nargin<4
if nargin<3
error('%s: Too few input parameters.',upper(mfilename));
end;

Expand Down
24 changes: 24 additions & 0 deletions gabor/tconv.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,27 @@
h=spreadfun(Th);

end;

function coef=spreadfun(T)
%SPREADFUN Spreading function of a matrix
% Usage: c=spreadfun(T);
%
% `spreadfun(T)` computes the spreading function of the operator *T*,
% represented as a matrix. The spreading function represent the operator *T*
% as a weighted sum of time-frequency shifts. See the help text for
% |spreadop| for the exact definition.
%
% See also: spreadop, tconv, spreadinv, spreadadj

complainif_argnonotinrange(nargin,1,1,mfilename);

if ndims(T)>2 || size(T,1)~=size(T,2)
error('Input symbol T must be a square matrix.');
end;

L=size(T,1);

% The 'full' appearing on the next line is to guard the mex file.
coef=comp_col2diag(full(T));

coef=fft(coef)/L;
1 change: 1 addition & 0 deletions sigproc/Contents.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
% CRESTFACTOR - Compute the crest factor of a signal.
% LOWDISCREPANCY - Compute a low discrepancy sequence.
% UQUANT - Simulate uniform quantization.
% POSTPAD - Pad or truncate a vector.
%
% Window functions
% FIRWIN - FIR windows (Hanning,Hamming,Blackman,...).
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion testing/ltfatdiditfail.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function [test_failed,fail]=ltfatdiditfail(res,test_failed,tolerance);
%LTFATDIDITFAIL Did a test fail
%
% [test_fail,fail]=LTFATDIDITFAIL(res,test_fail) updates test_fail if
% [test_fail,fail]=LTFATDIDITFAIL(res,test_fail, tolerance) updates test_fail if
% res is above threshhold and outputs the word FAIL in the variable
% fail. Use only in testing scripts.
global LTFAT_TEST_TYPE;
Expand Down
2 changes: 1 addition & 1 deletion testing/test_all_ltfat.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'dtwfb', 'dwilt2', 'dwilt',...
'filterbankconstphase', 'filterbank',...
'firwin', 'frames', 'frametf', 'freqorder', 'frft',...
'fwt2', 'fwt', 'gabfilters', 'gabfirtight', 'gabmulappr',...
'fwt2', 'fwt', 'gabfilters', 'gabfirdual', 'gabfirtight', 'gabwintight', 'gabmulappr',...
'gabmuleigs', 'gabphasederivinterface', 'gabphasederiv',...
'gabphasederivreal', 'gga', 'idft', 'involute',...
'lconv', 'multidgtrealmp', 'multiwin', 'nonu2ufilterbank', 'nsdgt',...
Expand Down
121 changes: 121 additions & 0 deletions testing/test_gabfirdual.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
function test_failed=test_gabfirdual
%TEST_GABFIRDUAL Test GABFIRDUAL


Lr=[24,16,144,144];
ar=[ 4, 4, 8, 12];
Mr=[ 12, 16, 72, 48];

test_failed=0;
tolerance=1e-5;

disp(' =============== TEST_GABFIRDUAL ================');

disp('--- Used subroutines ---');

addpath([ltfatbasepath, 'thirdparty', filesep, 'unlocbox']);
if exist('init_unlocbox.m', 'file')
init_unlocbox;
else
disp('unlocbox not found. please initialize git submodule via git submodule update --init.')
end

for ii=1:length(Lr);

L=Lr(ii);

M=Mr(ii);
a=ar(ii);
b=L/M;
N=L/a;
c=gcd(a,M);
d=gcd(b,N);
p=a/c;
q=M/c;


for rtype=1:2

if rtype==1
rname='REAL ';
g=tester_rand(L,1);
else
rname='CMPLX';
g=tester_crand(L,1);
end;

global LTFAT_TEST_TYPE;
if strcmpi(LTFAT_TEST_TYPE,'single')
C = gabframebounds(g,a,M);
while C>1e3
% warning(sprintf(['The frame is too badly conditioned '...
% 'for single precision. Cond. num. %d. '...
% ' Trying again.'],C));

if rtype==1
rname='REAL ';
g=tester_rand(L,1);
else
rname='CMPLX';
g=tester_crand(L,1);
end;
C = gabframebounds(g,a,M);
end
end


gd=gabfirdual(L, g,a,M);

for W=1:3

if rtype==1
f=tester_rand(L,W);
else
f=tester_crand(L,W);
end;



% --- Test reconstruction of IDGT using the dual window. ---
cc=dgt(f,g,a,M);
r=idgt(cc,gd,a);
res=norm(f-r,'fro');
[test_failed,fail]=ltfatdiditfail(res,test_failed, tolerance);
s=sprintf(['REC %s L:%3i W:%2i a:%3i b:%3i c:%3i d:%3i p:%3i q:%3i ' ...
'%0.5g %s'],rname,L,W,a,b,c,d,p,q,res,fail);
disp(s)


% Test the real valued transform
if rtype==1

% --- Reference test ---
ccreal=dgtreal(f,g,a,M);
M2=floor(M/2)+1;

cdiff=cc(1:M2,:,:)-ccreal;
res=norm(cdiff(:));
[test_failed,fail]=ltfatdiditfail(res,test_failed, tolerance);
s=sprintf(['REFREAL L:%3i W:%2i a:%3i b:%3i c:%3i d:%3i p:%3i ' ...
'q:%3i %0.5g %s'],L,W,a,b,c,d,p,q,res,fail);
disp(s);

% --- Reconstruction test ---

rreal=idgtreal(ccreal,real(gd),a,M);

res=norm(f-rreal,'fro');
[test_failed,fail]=ltfatdiditfail(res,test_failed, tolerance);
s=sprintf(['RECREAL L:%3i W:%2i a:%3i b:%3i c:%3i d:%3i p:%3i ' ...
'q:%3i %0.5g %s'],L,W,a,b,c,d,p,q,res,fail);
disp(s)

end;
end;

end;

end;

close_unlocbox;
rmpath(([ltfatbasepath, 'thirdparty', filesep, 'unlocbox']));

0 comments on commit 9bfc58f

Please sign in to comment.