source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/@ncvar/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.1 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.1 2006/08/10 18:00:22 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                %i = varargin{4};
53                %D = varargin{5};
54                %V = varargin{6};
55
56                % Call external to allow subsrefs in classs
57                [F,vars] = sort_internal(t,X,data);%i,D,V);
58
59                varargout{1} = F;
60                varargout{2} = struct('convexity','milp','monotonicity','milp','definiteness','milp');
61                varargout{3} = X;
62
63                % Currently a hack, gneral feature coming soon...
64                varargout{2}.models = vars;
65
66            otherwise
67                error('SDPVAR/SORT called with CHAR argument?');
68        end
69    otherwise
70        error('Strange type on first argument in SDPVAR/SORT');
71end
Note: See TracBrowser for help on using the repository browser.