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 30, 2023
2 parents 6e9d080 + cac98e7 commit d82837e
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 18 deletions.
File renamed without changes.
90 changes: 90 additions & 0 deletions gabor/gabconvexopt.m
Expand Up @@ -678,3 +678,93 @@
% this function force the signal to be even
x= (x+involute(x))/2;
end

function [ sol ] = proj_dual( x,~, param )
%PROJ_DUAL projection onto the dual windows space
% Usage: sol=proj_proj(x, ~, param)
% [sol, infos]=proj_b2(x, ~, param)
%
% Input parameters:
% x : Input signal.
% param : Structure of optional parameters.
% Output parameters:
% sol : Solution.
% infos : Structure summarizing informations at convergence
%
% `proj_dual(x,~,param)` solves:
%
% .. sol = argmin_{z} ||x - z||_2^2 s.t. A z=y
%
% .. math:: sol = \min_z ||x - z||_2^2 \hspace{1cm} s.t. \hspace{1cm} A z= y
%
% param is a Matlab structure containing the following fields:
%
% * *param.y* : measurements (default: 0).
%
% * *param.A* : Matrix (default: Id).
%
% * *param.AAtinv* : $(A A^*)^(-1)$ Define this parameter to speed up computation.
%
% * *param.verbose* : 0 no log, 1 a summary at convergence, 2 print main
% steps (default: 1)
%
%
% infos is a Matlab structure containing the following fields:
%
% * *infos.algo* : Algorithm used
%
% * *infos.iter* : Number of iteration
%
% * *infos.time* : Time of execution of the function in sec.
%
% * *infos.final_eval* : Final evaluation of the function
%
% * *infos.crit* : Stopping critterion used
%
% * *infos.residue* : Final residue
%
%
% Rem: The input "~" is useless but needed for compatibility issue.
%
% See also: prox_l2 proj_b1
%
% References: fadili2009monotone

%
% Author: Nathanael Perraudin
% Date: Feb 20, 2013
%

% Start the time counter
t1 = tic;

% Optional input arguments
%if ~isfield(param, 'y'), param.y = 0; end
%if ~isfield(param, 'A'), param.A = eye(length(x)); end
%if ~isfield(param, 'AAtinv'), param.AAtinv=pinv(A*At); end
%if ~isfield(param, 'verbose'), param.verbose = 1; end


% Projection

sol = x - param.A'*param.AAtinv*(param.A*x-param.y);
crit = 'TOL_EPS'; iter = 0; u = NaN;



% Log after the projection onto the L2-ball
error=norm(param.y-param.A *sol );
if param.verbose >= 1
fprintf([' Proj. dual windows: ||y-Ax||_2 = %e,', ...
' %s, iter = %i\n'],error , crit, iter);
end

% Infos about algorithm
infos.algo=mfilename;
infos.iter=iter;
infos.final_eval=error;
infos.crit=crit;
infos.residue=u;
infos.time=toc(t1);

end
26 changes: 14 additions & 12 deletions gabor/wilwin.m
@@ -1,4 +1,4 @@
function [g,info] = wilwin(g,M,L,callfun);
function [g,info] = wilwin(g,M,L, varargin)
%WILWIN Compute a Wilson/WMDCT window from text or cell array
% Usage: [g,info] = wilwin(g,M,L);
%
Expand Down Expand Up @@ -124,22 +124,24 @@
winname=lower(g);
switch(winname)
case {'pgauss','gauss'}
complain_L(L,callfun);
complain_L(L,mfilename);
g=comp_pgauss(L,2*M*M/L,0,0);
info.gauss=1;
info.tfr=2*M*M/L;
case {'psech','sech'}
complain_L(L,callfun);
complain_L(L,mfilename);
g=psech(L,2*M*M/L);
a = 2*M;
info.tfr=a*M/L;
case {'dualgauss','gaussdual'}
complain_L(L,callfun);
complain_L(L,mfilename);
g=comp_pgauss(L,2*M*M/L,0,0);
g=wildual(g,M);
info.isdual=1;
a = 2*M;
info.tfr=a*M/L;
case {'tight'}
complain_L(L,callfun);
complain_L(L,mfilename);
g=wilorth(M,L);
info.tfr=2*M*M/L;
info.istight=1;
Expand All @@ -150,7 +152,7 @@
info.istight=1;
end;
otherwise
error('%s: Unknown window type: %s',callfun,winname);
error('%s: Unknown window type: %s',mfilename,winname);
end;
end;

Expand All @@ -163,15 +165,15 @@

switch(winname)
case {'pgauss','gauss'}
complain_L(L,callfun);
complain_L(L,mfilename);
[g,info.tfr]=pgauss(L,g{2:end});
info.gauss=1;
case {'psech','sech'}
complain_L(L,callfun);
complain_L(L,mfilename);
[g,info.tfr]=psech(L,g{2:end});
case {'dual'}
gorig = g{2};
[g,info.auxinfo] = wilwin(gorig,M,L,callfun);
[g,info.auxinfo] = wilwin(gorig,M,L,mfilename);
g = wildual(g,M,L);

% gorig can be string or cell array
Expand All @@ -182,7 +184,7 @@
info.isdual=1;
case {'tight'}
gorig = g{2};
[g,info.auxinfo] = wilwin(g{2},M,L,callfun);
[g,info.auxinfo] = wilwin(g{2},M,L,mfilename);
g = wilorth(g,M,L);
% gorig can be string or cell array
if info.auxinfo.isfir && test_isfir(gorig,M)
Expand Down Expand Up @@ -220,11 +222,11 @@
info.isfir=1;
end;

function complain_L(L,callfun)
function complain_L(L,mfilename)

if isempty(L)
error(['%s: You must specify a length L if a window is represented as a ' ...
'text string or cell array.'],callfun);
'text string or cell array.'],mfilename);
end;

function isfir=test_isfir(gorig,M)
Expand Down
4 changes: 2 additions & 2 deletions gabor/zak.m
Expand Up @@ -54,11 +54,11 @@
complainif_argnonotinrange(nargin,2,2,mfilename);

if (prod(size(a))~=1 || ~isnumeric(a))
error([callfun,': a must be a scalar']);
error([mfilename,': a must be a scalar']);
end;

if rem(a,1)~=0
error([callfun,': a must be an integer']);
error([mfilename,': a must be an integer']);
end;


Expand Down
13 changes: 10 additions & 3 deletions sigproc/largestr.m
Expand Up @@ -57,16 +57,23 @@
wascell=iscell(xi);

if wascell
[xi,shape]=cell2vec(xi);
%[xi,shape]=cell2vec(xi);
xi = cell2mat(xi);
end;

% Determine the size of the array.
ss=numel(xi);

N=round(ss*p);
% Determine if p was given as a fraction or as an integer
if floor(p)==p
N = p;
else
N=round(ss*p);
end

[xo,Nout]=largestn(xi,N,flags.outclass,flags.iofun);

if wascell
xo=vec2cell(xo,shape);
%xo=vec2cell(xo,shape);
xo = mat2cell(xo,size(xo,1), size(xo,2));
end;
2 changes: 1 addition & 1 deletion test_all_ltfat.m
Expand Up @@ -19,7 +19,7 @@
'nsdgt','filterbank','gabfilters'...
'pgauss','pfilt',...
'rangecompress',...
'gabmuleigs','phaselock',...
'gabmuleigs','phaselock', 'hermbasis'...
'fwt','blockfwt','ufwt','wfbt','uwfbt','wpfbt','uwpfbt','fwt2','undeceq',...
'wfbt2filterbank','freqorder','gga','chirpzt',...
'frames', 'frametf', 'frft', 'nonu2ufilterbank', 'dtwfb', 'dtwfb2filterbank',...
Expand Down
4 changes: 4 additions & 0 deletions deprecated/test_hermbasis.m → testing/test_hermbasis.m
@@ -1,3 +1,7 @@
function test_failed = test_hermbasis()

test_failed = 0;

Lr=[100,101,102,103];

test_failed=0;
Expand Down

0 comments on commit d82837e

Please sign in to comment.