1 | function varargout = geomean2(varargin) |
---|
2 | %GEOMEAN2 Nonlinear operator in YALMIP |
---|
3 | % |
---|
4 | % t = GEOMEAN2(X) |
---|
5 | % |
---|
6 | % For Hermitian matrix X, returns det(X)^(1/(2^ceil(log2(length(X))))) |
---|
7 | % |
---|
8 | % For real vector X, returns prod(X)^(1/(2^ceil(log2(length(X))))) |
---|
9 | % |
---|
10 | % This concave function is monotonically growing in det(P) |
---|
11 | % for P>0, so it can be used for maximizing det(P), |
---|
12 | % or to add lower bound constraints on the determinant. |
---|
13 | % |
---|
14 | % When GEOMEAN2 is used in a problem, the domain constraint |
---|
15 | % set(X>0) is automatically added to the problem. |
---|
16 | % |
---|
17 | % Note that the function is the geometric mean of |
---|
18 | % the elements (or eigenvalues) if the dimension of |
---|
19 | % X is a power of 2, hence the name GEOMEAN2. |
---|
20 | % |
---|
21 | % See also SDPVAR, SDPVAR/GEOMEAN, SUMK, SUMABSK |
---|
22 | |
---|
23 | % Author Johan Löfberg |
---|
24 | % $Id: geomean2.m,v 1.1 2006/03/30 13:36:39 joloef Exp $ |
---|
25 | |
---|
26 | switch class(varargin{1}) |
---|
27 | |
---|
28 | case 'double' % What is the numerical value of this argument (needed for displays etc) |
---|
29 | X = varargin{1}; |
---|
30 | [n,m] = size(X); |
---|
31 | if min(n,m)==1 |
---|
32 | varargout{1} = prod(X)^(1/(2^ceil(log2(length(X))))); |
---|
33 | else |
---|
34 | if norm(X-X')<n*eps |
---|
35 | varargout{1} = (real(det(X)))^(1/(2^ceil(log2(length(X))))); |
---|
36 | else |
---|
37 | error('GEOMEAN2 can only be applied to real vectors and Hermitian matrices'); |
---|
38 | end |
---|
39 | end |
---|
40 | |
---|
41 | case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them. |
---|
42 | X = varargin{1}; |
---|
43 | [n,m] = size(X); |
---|
44 | if is(varargin{1},'hermitian') | min(n,m)==1 |
---|
45 | varargout{1} = yalmip('addextendedvariable',mfilename,varargin{:}); |
---|
46 | else |
---|
47 | error('GEOMEAN2 can only be applied to real vectors and Hermitian matrices'); |
---|
48 | end |
---|
49 | |
---|
50 | case 'char' % YALMIP send 'model' when it wants the epigraph or hypograph |
---|
51 | if isequal(varargin{1},'graph') |
---|
52 | t = varargin{2}; % Second arg is the extended operator variable |
---|
53 | X = varargin{3}; % Third arg and above are the args user used when defining t. |
---|
54 | varargout{1} = detset(t,X); |
---|
55 | if issymmetric(X) |
---|
56 | varargout{2} = struct('convexity','concave','monotonicity','none','definiteness','positive'); |
---|
57 | else |
---|
58 | varargout{2} = struct('convexity','concave','monotonicity','increasing','definiteness','positive'); |
---|
59 | end |
---|
60 | varargout{3} = X; |
---|
61 | else |
---|
62 | end |
---|
63 | otherwise |
---|
64 | end |
---|