source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/@sdpvar/sort.m @ 37

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

Added original make3d

File size: 2.0 KB
Line 
1function varargout=sort(varargin)
2%SORT (overloaded)
3%
4% [t,loc] = sort(x)
5%
6% The variable t will be the sorted version of x.
7%
8% SORT is implemented in the nonlinear operator framework using a big-M
9% model.
10
11
12% Author Johan Löfberg
13% $Id: sort.m,v 1.6 2006/09/01 09:46:03 joloef Exp $
14
15switch class(varargin{1})
16
17    case 'double'
18        error('Overloaded SDPVAR/SORT CALLED WITH DOUBLE. Report error')
19
20    case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
21
22        if nargin > 1 | min(size(varargin{1}))>1
23            error('SDPVAR/SORT only supports simple 1-D sorting'),
24        end
25
26        x = varargin{1};
27        data.D = binvar(length(x),length(x),'full');
28        data.V = sdpvar(length(x),length(x),'full');
29        y = [];
30
31        for i = 1:length(x)
32            data.i = i;
33            data.isthisloc = 0;
34            y = [y;yalmip('addextendedvariable',mfilename,x,data)];%i,P,V)];
35        end
36        loc = [];
37        for i = 1:length(x)
38            data.i = i;
39            data.isthisloc = 1;
40            loc = [loc;yalmip('addextendedvariable',mfilename,x,data)];
41        end
42        varargout{1} = y;
43        varargout{2} = loc;
44
45    case 'char' % YALMIP send 'graph' when it wants the epigraph or hypograph
46        switch varargin{1}
47            case {'milp','graph'}
48                % Description using epigraphs
49                t = varargin{2};
50                X = varargin{3};
51                data = varargin{4};
52
53                % Call external to allow subsrefs in classs
54                [F,vars] = sort_internal(t,X,data);
55
56                varargout{1} = F;
57                varargout{2} = struct('convexity','milp','monotonicity','milp','definiteness','milp');
58                varargout{3} = X;
59
60                % Inofficial way to model several nonlinear variables in
61                % one call
62                varargout{2}.models = vars;
63
64            otherwise
65                error('SDPVAR/SORT called with CHAR argument?');
66        end
67    otherwise
68        error('Strange type on first argument in SDPVAR/SORT');
69end
Note: See TracBrowser for help on using the repository browser.