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

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

Added original make3d

File size: 1.4 KB
Line 
1function varargout = SQRT(varargin)
2%SQRT (overloaded)
3%
4% t = sqrt(x)
5%
6% The variable t can only be used in concavity preserving
7% operations such as t>1, max t etc.
8%
9% When SQRT is used in a problem, the domain constraint
10% set(x>0) is automatically added to the problem.
11%
12% See also SDPVAR, SDPVAR/GEOMEAN
13
14% Author Johan Löfberg
15% $Id: sqrt.m,v 1.1 2006/08/10 18:00:22 joloef Exp $
16
17switch class(varargin{1})
18   
19case 'double' % What is the numerical value of this argument (needed for displays etc)       
20    X = sqrt(varargin{1});
21
22case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
23    X = varargin{1};
24    [n,m] = size(X);
25    if is(varargin{1},'real') & (n*m==1)
26        varargout{1} = yalmip('addextendedvariable',mfilename,varargin{:});   
27    else
28        error('SQRT can only be applied to real scalars');
29    end
30   
31case 'char' % YALMIP send 'model' when it wants the epigraph or hypograph
32    if isequal(varargin{1},'graph')
33        t = varargin{2}; % Second arg is the extended operator variable
34        X = varargin{3}; % Third arg and above are the args user used when defining t.           
35        varargout{1} = set(cone([(X-1)/2;t],(X+1)/2));
36        varargout{2} = struct('convexity','concave','monotonicity','increasing','definiteness','positive');
37        varargout{3} = X;
38    else           
39    end   
40otherwise
41end
Note: See TracBrowser for help on using the repository browser.