source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/usertest/gan.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.1 KB
Line 
1function varargout = entropy(varargin)
2%ENTROPY
3%
4% y = ENTROPY(x)
5%
6% Computes/declares entropy -sum(x.*log(x))
7%
8% Implemented as evalutation based nonlinear operator. Hence, the concavity
9% of this function is exploited to perform convexity analysis and rigorous
10% modelling.
11
12% Author Johan Löfberg
13% $Id: gan.m,v 1.1 2006/08/17 07:57:24 joloef Exp $
14
15switch class(varargin{1})
16
17    case 'double' % What is the numerical value of this argument (needed for displays etc)
18        x = varargin{1};
19        a = varargin{2};
20        varargout{1} = sum(x(:).*a(:).^(1./x(:)));
21       
22    case 'sdpvar' % Overloaded operator for SDPVAR objects.   
23        X = varargin{1};
24        if min(size(X))>1
25            error('ENTROPY only defined for vector arguments');
26        else
27%             y = [];
28%             for i = 1:length(X)
29%                 y = [y;yalmip('addEvalVariable',mfilename,X(i),varargin{2})];
30%             end
31%             varargout{1} = y;
32                        varargout{1} = yalmip('addEvalVariable',mfilename,varargin{:});
33        end
34           
35    case 'char' % YALMIP sends 'model' when it wants the epigraph or hypograph
36        switch varargin{1}
37            case 'graph'
38                t = varargin{2};
39                X = varargin{3};
40                A = varargin{4};
41                % This is different from so called extended operators
42                % Just do it!
43                F = SetupEvaluationVariable(varargin{:});
44               
45                % Now add your own code, such as domain constraints
46                F = F + set(X > 0);
47               
48                % Let YALMIP know about convexity etc               
49                varargout{1} = F;
50                varargout{2} = struct('convexity','convex','monotonicity','none','definiteness','none');
51                varargout{3} = X;
52               
53            case 'milp'
54                    varargout{1} = [];
55                    varargout{2} = [];
56                    varargout{3} = [];               
57            otherwise
58                error('SDPVAR/LOG called with CHAR argument?');
59        end
60    otherwise
61        error('SDPVAR/LOG called with CHAR argument?');
62end
Note: See TracBrowser for help on using the repository browser.