-
Notifications
You must be signed in to change notification settings - Fork 3
/
atanT2.m
65 lines (54 loc) · 1.48 KB
/
atanT2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function x = atanT2(y,T,a)
% x = atanT(y,T,a)
%
% THRESHOLDING FUNCTION OF USING ARCTANGENT PENALTY FUNCTION:
% gives the solution of
% x = argmin_x f(x) = 0.5*(y-x)^2 + T*phi(x,a);
% where
% phi(x,a) = 2./(a*sqrt(3))*(atan((2*a*abs(x)+1)/sqrt(3)) - pi/6)
%
% INPUT
% y : data (scalar or multidimensional array)
% T : threshold (scalar or multidimensional array)
% a : penalty convexity parameter (a>0)
% if a is too small (less than 1e-10) there is no benifit of using the
% non-convex penalty function, and the result is approximatly equal
% to using soft-thresholding.
%
% OUTPUT
% x : output of atan thresholding
% if ( a < 1e-10 )
%
% x = soft(y, T);
%
% else
b = abs(y);
ab = a.*b;
i = find( ab == 1 );
u = a - ab.*a;
v = u.^3./(27.*a.^6) - (b - T)./(2.*a.^2) + (u.*(ab - 1))./(6.*a.^4);
w = (ab - 1)./(3.*a.^2) + u.^2./(9.*a.^4);
f = ((v.^2 - w.^3).^(1/2) - v).^(1/3);
z = f - u./(3.*a.^2) + w./f;
if isempty(i) ~= 1
z(i) = ( (b(i) - T )./a.^2 ) .^ (1/3);
end
x = abs(z) .* sign(y) .*( (b-T) >= 0);
% end
end
function x = soft(y, T)
% x = soft(y, T)
%
% SOFT THRESHOLDING
% for real or complex data.
%
% INPUT
% y : data (scalar or multidimensional array)
% T : threshold (scalar or multidimensional array)
%
% OUTPUT
% x : output of soft thresholding
%
% If x and T are both multidimensional, then they must be of the same size.
x = max(1 - T./abs(y), 0) .* y;
end