Sample implementations of proximal operators
This "library" contains sample implementations of various proximal operators in Matlab. These implementations are intended to be pedagogical, not the most performant.
This code is associated with the paper Proximal Algorithms by Neal Parikh and Stephen Boyd.
The C functions rely on the GNU Scientific Library (GSL). Some of these functions also contain OpenMP directives to parallelize some
forloops, so compiling with OpenMP is optional, but some of the functions will be substantially faster if it is used.
The Matlab function
Evaluating the proximal operator of the l1 norm via CVX and the function here:
>> n = 100; >> lambda = 1; >> >> v = randn(n,1); >> >> % CVX baseline >> cvx_begin quiet >> variable x(n) >> minimize(norm(x,1) + (1/(2*lambda))*sum_square(x - v)) >> cvx_end >> >> % Custom method >> x2 = prox_l1(v, lambda); >> >> % Comparison >> norm(x - x2) ans = 7.7871e-05
Evaluating the proximal operator of the nuclear norm:
>> m = 10; >> n = 30; >> lambda = 1; >> >> V = randn(m,n); >> >> % CVX baseline >> cvx_begin quiet >> variable X(m,n) >> minimize(norm_nuc(X) + (1/(2*lambda))*square_pos(norm(X - V,'fro'))) >> cvx_end >> >> % Custom method >> X2 = prox_matrix(V, lambda, @prox_l1); >> >> % Comparison >> norm(X - X2) ans = 1.9174e-05
This second example shows a case where one of the arguments is a function handle to another proximal operator.
The other Matlab functions work similarly; just use
For a C example, see the file
example.cin the C source directory.
The Matlab functions include the following examples:
There are other libraries with implementations of proximal or projection operators that may be preferable or contain more examples:
This code is released under a BSD license; see the "LICENSE" file.