daltv1d - DAL for 1D TV denoising Overview: Solves the optimization problem: xx = argmin ||A*x-bb|| + lambda*||diff(x)||_1 Syntax: [xx,status]=dallrgl(xx, A, bb, lambda, <opt>) Inputs: xx : initial solution ([nn,1]) A : the design matrix A ([mm,nn]) or a cell array {fA, fAT, mm, nn} where fA and fAT are function handles to the functions that return A*x and A'*x, respectively, and mm and nn are the numbers of rows and columns of A. bb : the target vector ([mm,1]) lambda : the regularization constant <opt> : list of 'fieldname1', value1, 'filedname2', value2, ... stopcond : stopping condition, which can be 'pdg' : Use relative primal dual gap (default) 'fval' : Use the objective function value (see dal.m for other options) Outputs: xx : the final solution ([nn,1]) status : various status values Copyright(c) 2009 Ryota Tomioka This software is distributed under the MIT license. See license.txt
0001 % daltv1d - DAL for 1D TV denoising 0002 % 0003 % Overview: 0004 % Solves the optimization problem: 0005 % xx = argmin ||A*x-bb|| + lambda*||diff(x)||_1 0006 % 0007 % Syntax: 0008 % [xx,status]=dallrgl(xx, A, bb, lambda, <opt>) 0009 % 0010 % Inputs: 0011 % xx : initial solution ([nn,1]) 0012 % A : the design matrix A ([mm,nn]) or a cell array {fA, fAT, mm, nn} 0013 % where fA and fAT are function handles to the functions that 0014 % return A*x and A'*x, respectively, and mm and nn are the 0015 % numbers of rows and columns of A. 0016 % bb : the target vector ([mm,1]) 0017 % lambda : the regularization constant 0018 % <opt> : list of 'fieldname1', value1, 'filedname2', value2, ... 0019 % stopcond : stopping condition, which can be 0020 % 'pdg' : Use relative primal dual gap (default) 0021 % 'fval' : Use the objective function value 0022 % (see dal.m for other options) 0023 % Outputs: 0024 % xx : the final solution ([nn,1]) 0025 % status : various status values 0026 % 0027 % Copyright(c) 2009 Ryota Tomioka 0028 % This software is distributed under the MIT license. See license.txt 0029 0030 function [ww,status]=daltv1d(ww,A,bb, lambda, varargin) 0031 0032 opt=propertylist2struct(varargin{:}); 0033 opt=set_defaults(opt,'solver','nt',... 0034 'stopcond','pdg'); 0035 0036 0037 0038 prob.floss = struct('p',@loss_sqp,'d',@loss_sqd,'args',{{bb}}); 0039 prob.fspec = @(xx)abs(xx); 0040 prob.dnorm = @(vv)max(abs(vv)); 0041 prob.obj = @objdall1; 0042 prob.softth = @l1_softth; 0043 prob.stopcond = ['stopcond_' opt.stopcond]; 0044 prob.ll = -inf*ones(size(bb)); 0045 prob.uu = inf*ones(size(bb)); 0046 prob.Ac =[]; 0047 prob.bc =[]; 0048 prob.info =[]; 0049 0050 if isequal(opt.solver,'cg') 0051 prob.hessMult = @hessMultdall1; 0052 end 0053 0054 if isequal(opt.stopcond,'fval') 0055 opt.feval = 1; 0056 end 0057 0058 [mm,nn]=size(A); 0059 prob.mm = mm; 0060 prob.nn = nn-1; 0061 0062 0063 uu=ww(end); 0064 xx=-diff(ww); 0065 0066 0067 A=cumsum(A')'; 0068 B=A(:,end); 0069 A=A(:,1:end-1); 0070 0071 [xx,uu,status]=dal(prob,xx,uu,A,B,lambda,opt); 0072 0073 ww=flipud(cumsum(flipud(xx))); 0074 ww=[ww+uu; uu];