source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@ncvar/sign.m @ 37

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

Added original make3d

File size: 2.6 KB
Line 
1function varargout = norm(varargin)
2%SIGN (overloaded)
3
4% Author Johan Löfberg
5% $Id: sign.m,v 1.1 2006/08/10 18:00:22 joloef Exp $
6
7
8%% ***************************************************
9% This file defines a nonlinear operator for YALMIP
10%
11% It can take three different inputs
12% For DOUBLE inputs, it returns standard double values
13% For SDPVAR inputs, it generates an internal variable
14%
15% When first input is 'model' it returns the graph
16% in the first output and structure describing some
17% properties of the operator.
18
19%% ***************************************************
20switch class(varargin{1})
21
22    case 'double' % What is the numerical value of this argument (needed for displays etc)
23        % SHOULD NEVER HAPPEN, THIS SHOULD BE CAUGHT BY BUILT-IN
24        error('Overloaded SDPVAR/NORM CALLED WITH DOUBLE. Report error')
25
26    case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
27        if length(varargin{1}) == 1
28            varargout{1} = yalmip('addextendedvariable',mfilename,varargin{1});
29        else
30            y = [];
31            n = size(varargin{1},1);
32            m = size(varargin{1},2);
33            varargin{1} = reshape(varargin{1},n*m,1);
34            for i = 1:prod(size(varargin{1}))
35                inparg = extsubsref(varargin{1},i);
36                if isa(inparg,'double')
37                    y = sign(inparg);
38                else
39                    y = [y yalmip('addextendedvariable',mfilename,inparg)];
40                end
41            end
42            y = reshape(y,n,m);
43            varargout{1} = y;
44        end
45
46    case 'char' % YALMIP sends 'model' when it wants the epigraph or hypograph
47        switch varargin{1}
48            case 'graph'
49                t = varargin{2};
50                X = varargin{3};
51
52                % No linear model available
53
54                varargout{1} = [];
55                varargout{2} = [];
56                varargout{3} = [];
57            case 'milp'
58
59                t = varargin{2};
60                X = varargin{3};
61                p = varargin{4};
62
63                d = binvar(1,1);
64                [M,m] = derivebounds(X);
65                F = set([]);
66                F = set(X > d*m) + set(-2*d+1 <= t <= 1);
67                F = set(X < (1-d)*M) + set(-1     <= t <= -1 + 2*(1-d));
68
69                varargout{1} = F;
70                varargout{2} = struct('convexity','milp','monotonicity','milp','definiteness','positive');
71                varargout{3} = X;
72
73            otherwise
74                error('SDPVAR/NORM called with CHAR argument?');
75        end
76    otherwise
77        error('Strange type on first argument in SDPVAR/NORM');
78end
Note: See TracBrowser for help on using the repository browser.