Home > manopt > manifolds > euclidean > euclideanfactory.m

euclideanfactory

PURPOSE ^

Returns a manifold struct to optimize over real matrices.

SYNOPSIS ^

function M = euclideanfactory(m, n)

DESCRIPTION ^

 Returns a manifold struct to optimize over real matrices.

 function M = euclideanfactory(m)
 function M = euclideanfactory(m, n)
 function M = euclideanfactory([n1, n2, ...])

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

Generated on Fri 08-Sep-2017 12:43:19 by m2html © 2005