-
Notifications
You must be signed in to change notification settings - Fork 60
/
prox_shift.m
37 lines (31 loc) · 1.13 KB
/
prox_shift.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
function op = prox_shift( funcF, c )
%PROX_SHIFT Shift a proximity/projection function
% SHIFTED_OP = PROX_SHIFT( OP, c )
% returns an implementation of the proximity operator
% defined by f(x) + c'*x
% where f is the proximity operator associated with OP.
%
% See also prox_scale
error(nargchk(2,2,nargin));
if ~isa( funcF, 'function_handle' ),
error( 'The first argument must be a function handle.' );
elseif ~isnumeric( c )
error( 'The second argument must be a numeric vector.' );
end
op = @(varargin)shift_func( funcF, c, varargin{:} );
function [ v, x ] = shift_func( prox_f, c, x, t )
if nargin < 3,
error( 'Not enough arguments.' );
end
if nargin == 4,
if numel(t) ~= 1
error('The stepsize must be a scalar');
end
[v,x] = prox_f(x-t*c,t);
v = v + tfocs_dot(x,c);
elseif nargout == 2,
error( 'This function is not differentiable.' );
end
% TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant.
% Copyright 2015 California Institute of Technology and CVX Research.
% See the file LICENSE for full license information.