forked from cvxr/TFOCS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtfocs_smooth.m
45 lines (40 loc) · 1.17 KB
/
tfocs_smooth.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
function op = tfocs_smooth( fcn )
% OP = TFOCS_SMOOTH(FCN)
% is a wrapper designed to facilitate users writing their own
% smooth functions.
%
% To use this, please see the file SMOOTH_HUBER as an example
%
% The basic layout of a file like SMOOTH_HUBER is as follows:
%
% function op = smooth_huber(mu)
% op = tfocs_smooth( @huber_impl )
%
% function [f,g] = huber_impl(x)
% ... this function calculates the function, f,
% and the gradient, g, of x ...
% end
% end
%
% Note: in the above template, the "end" statements are very important.
%
%
% Also, users may wish to test their smooth function
% with the script TEST_SMOOTH
%
% See also smooth_huber, test_smooth, private/tfocs_smooth, smooth_handles
op = @fcn_impl;
function [ v, g ] = fcn_impl(x, t )
if nargin == 2,
error( 'Proximity minimization not supported by this function.' );
end
if nargout == 2
[v,g] = fcn(x);
else
v = fcn(x);
end
end
end
% TFOCS v1.3 by Stephen Becker, Emmanuel Candes, and Michael Grant.
% Copyright 2013 California Institute of Technology and CVX Research.
% See the file LICENSE for full license information.