annotate solvers/CVX_add_const_Audio_declipping.m @ 186:9c418bea7f6a bug_386

Addresses Bug #386: removed the 4th output variable (versn) in all calls of function fileparts.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 09 Feb 2012 17:25:14 +0000
parents b14209313ba4
children
rev   line source
ivan@140 1 function solver=CVX_add_const_Audio_declipping(Problem, solver, idxFrame)
ivan@140 2
ivan@140 3 %% CVX additional constrains
ivan@140 4 % Clipping level: take the analysis window into account
ivan@140 5 % clipping level detection
ivan@140 6
ivan@140 7 signal = Problem.b1;
ivan@140 8 signalFull = Problem.b(:,idxFrame);
ivan@140 9 Dict = Problem.A;
ivan@140 10 DictFull = Problem.B;
ivan@140 11 Clipped = ~Problem.M(:,idxFrame);
ivan@140 12 W=1./sqrt(diag(Dict'*Dict));
ivan@140 13
ivan@140 14 idxCoeff = find(solver.solution~=0);
ivan@140 15
ivan@140 16 solution = solver.solution;
ivan@140 17
ivan@140 18 wa = Problem.wa(Problem.windowSize); % analysis window
ivan@140 19
ivan@140 20
ivan@140 21 clippingLevelEst = max(abs(signal./wa(~Clipped)'));
ivan@140 22
ivan@140 23 idxPos = find(signalFull>=0 & Clipped);
ivan@140 24 idxNeg = find(signalFull<0 & Clipped);
ivan@140 25
ivan@140 26 DictPos=DictFull(idxPos,:);
ivan@140 27 DictNeg=DictFull(idxNeg,:);
ivan@140 28
ivan@140 29
ivan@140 30 wa_pos = wa(idxPos);
ivan@140 31 wa_neg = wa(idxNeg);
ivan@140 32 b_ineq_pos = wa_pos(:)*clippingLevelEst;
ivan@140 33 b_ineq_neg = -wa_neg(:)*clippingLevelEst;
ivan@140 34 if isfield(Problem,'Upper_Limit') && ~isempty(Problem.Upper_Limit)
ivan@155 35 b_ineq_pos_upper_limit = wa_pos(:)*Problem.Upper_Limit;
ivan@155 36 b_ineq_neg_upper_limit = -wa_neg(:)*Problem.Upper_Limit;
ivan@140 37 else
ivan@140 38 b_ineq_pos_upper_limit = Inf;
ivan@140 39 b_ineq_neg_upper_limit = -Inf;
ivan@140 40 end
ivan@140 41
ivan@140 42
ivan@140 43 j = length(idxCoeff);
ivan@140 44
ivan@140 45 if isinf(b_ineq_pos_upper_limit)
ivan@140 46 %% CVX code
ivan@140 47 cvx_begin
ivan@140 48 cvx_quiet(true)
ivan@140 49 variable solution(j)
ivan@140 50 minimize(norm(Dict(:,idxCoeff)*solution-signal))
ivan@140 51 subject to
ivan@140 52 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_pos
ivan@140 53 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_neg
ivan@140 54 cvx_end
ivan@140 55 if cvx_optval>1e3
ivan@140 56 cvx_begin
ivan@140 57 cvx_quiet(true)
ivan@140 58 variable solution(j)
ivan@140 59 minimize(norm(Dict(:,idxCoeff)*solution-xObs))
ivan@140 60 cvx_end
ivan@140 61 end
ivan@140 62 else
ivan@140 63 %% CVX code
ivan@140 64 cvx_begin
ivan@140 65 cvx_quiet(true)
ivan@140 66 variable solution(j)
ivan@140 67 minimize(norm(Dict(:,idxCoeff)*solution-signal))
ivan@140 68 subject to
ivan@140 69 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_pos
ivan@140 70 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_neg
ivan@140 71 DictPos(:,idxCoeff)*(W(idxCoeff).*solution) <= b_ineq_pos_upper_limit
ivan@140 72 DictNeg(:,idxCoeff)*(W(idxCoeff).*solution) >= b_ineq_neg_upper_limit
ivan@140 73 cvx_end
ivan@140 74 if cvx_optval>1e3
ivan@140 75 cvx_begin
ivan@140 76 cvx_quiet(true)
ivan@140 77 variable solution(j)
ivan@140 78 minimize(norm(Dict(:,idxCoeff)*solution-xObs))
ivan@140 79 cvx_end
ivan@140 80 end
ivan@140 81 end
ivan@140 82
ivan@140 83 solver.solution(idxCoeff) = solution;
ivan@140 84
ivan@140 85