Home > manopt > manifolds > euclidean > euclideanfactory.m

euclideanfactory

PURPOSE ^

Returns a manifold struct to optimize over m-by-n matrices.

SYNOPSIS ^

function M = euclideanfactory(m, n)

DESCRIPTION ^

 Returns a manifold struct to optimize over m-by-n matrices.

 function M = euclideanfactory(m, n)

 Returns M, a structure describing the Euclidean space of m-by-n matrices,
 equipped with the standard Frobenius distance and associated trace inner
 product, as a manifold for Manopt.

 m and n in general can be vectors to handle multidimensional arrays.
 If either of m or n is a vector, they are concatenated as [m, n].

 Using this simple linear manifold, Manopt can be used to solve standard
 unconstrained optimization problems, for example in replacement of
 Matlab's fminunc.

 See also: euclideancomplexfactory

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function M = euclideanfactory(m, n)
0002 % Returns a manifold struct to optimize over m-by-n matrices.
0003 %
0004 % function M = euclideanfactory(m, n)
0005 %
0006 % Returns M, a structure describing the Euclidean space of m-by-n matrices,
0007 % equipped with the standard Frobenius distance and associated trace inner
0008 % product, as a manifold for Manopt.
0009 %
0010 % m and n in general can be vectors to handle multidimensional arrays.
0011 % If either of m or n is a vector, they are concatenated as [m, n].
0012 %
0013 % Using this simple linear manifold, Manopt can be used to solve standard
0014 % unconstrained optimization problems, for example in replacement of
0015 % Matlab's fminunc.
0016 %
0017 % See also: euclideancomplexfactory
0018 
0019 % This file is part of Manopt: www.manopt.org.
0020 % Original author: Nicolas Boumal, Dec. 30, 2012.
0021 % Contributors: Bamdev Mishra, May 4, 2015.
0022 % Change log:
0023 %
0024 %   July 5, 2013 (NB):
0025 %       Added egred2rgrad, ehess2rhess, mat, vec, tangent.
0026 %   May 4, 2015 (BM):
0027 %       Added functionality to handle multidimensional arrays.
0028 
0029 
0030     % The size can be defined using both m and n, or simply with m.
0031     % If m is a scalar, then n is implicitly 1.
0032     % This mimicks the use of built-in Matlab functions such as zeros(...).
0033     if ~exist('n', 'var') || isempty(n)
0034         if numel(m) == 1
0035             n = 1;
0036         else
0037             n = [];
0038         end
0039     end
0040     
0041     dimensions_vec = [m(:)', n(:)']; % We have a row vector.
0042     
0043     
0044     M.name = @() sprintf('Euclidean space R^(%s)', num2str(dimensions_vec)); % BM: okay.
0045     
0046     M.dim = @() prod(dimensions_vec);% BM: replacing m*n;
0047     
0048     M.inner = @(x, d1, d2) d1(:).'*d2(:); % BM: okay.
0049     
0050     M.norm = @(x, d) norm(d(:), 'fro');% BM: replacing norm(d, 'fro');
0051     
0052     M.dist = @(x, y) norm(x(:) - y(:), 'fro');% BM: replacing norm(x-y, 'fro');
0053     
0054     M.typicaldist = @() sqrt(prod(dimensions_vec));% BM: replacing sqrt(m*n);
0055     
0056     M.proj = @(x, d) d; % BM: okay.
0057     
0058     M.egrad2rgrad = @(x, g) g; % BM: okay.
0059     
0060     M.ehess2rhess = @(x, eg, eh, d) eh; % BM: okay.
0061     
0062     M.tangent = M.proj; 
0063     
0064     M.exp = @exp;
0065     function y = exp(x, d, t)
0066         if nargin == 3
0067             y = x + t*d; % BM: okay.
0068         else
0069             y = x + d; % BM: okay.
0070         end
0071     end
0072     
0073     M.retr = M.exp;
0074     
0075     M.log = @(x, y) y-x; % BM: okay.
0076 
0077     M.hash = @(x) ['z' hashmd5(x(:))]; % BM: okay.
0078     
0079     M.rand = @() randn(dimensions_vec);% BM: replacing randn(m, n);
0080     
0081     M.randvec = @randvec;
0082     function u = randvec(x) %#ok<INUSD>
0083         u = randn(dimensions_vec);% BM: replacing randn(m, n);
0084         u = u / norm(u(:), 'fro');% BM: replacing u / norm(u, 'fro');
0085     end
0086     
0087     M.lincomb = @matrixlincomb;
0088     
0089     M.zerovec = @(x) zeros(dimensions_vec);% BM: replacing zeros(m, n);
0090     
0091     M.transp = @(x1, x2, d) d;
0092     
0093     M.pairmean = @(x1, x2) .5*(x1+x2); % BM: okay.
0094     
0095     M.vec = @(x, u_mat) u_mat(:); % BM: okay.
0096     M.mat = @(x, u_vec) reshape(u_vec, dimensions_vec);% BM: replacing reshape(u_vec, [m, n]);
0097     M.vecmatareisometries = @() true;
0098 
0099 end

Generated on Sat 12-Nov-2016 14:11:22 by m2html © 2005