Computes a matrix which represents the Hessian in some tangent basis. [H, basis] = hessianmatrix(problem, x) [H, basis] = hessianmatrix(problem, x, basis) problem is a Manopt problem structure with a manifold and cost function. x is a point on the manifold problem.M. basis (optional) is an orthonormal basis for the tangent space to the manifold at x. If no basis is supplied, one will be generated at random. If the basis spans only a subspace of the tangent space at x, then the returned matrix represents the Hessian restricted to that subspace. H is an n-by-n symmetric matrix (with n the number of vectors in the basis) such that H(i, j) is the inner product between basis{i} and Hess(basis{j}), with respect to the metric on the tangent space to problem.M at x, where Hess(basis{j}) is the vector obtained after applying the Hessian at x to basis{j}. For optimization, it is usually not useful to compute the Hessian matrix, as this quickly becomes expensive. This tool is provided mostly for exploration and debugging rather than to be used algorithmically in solvers. To access the spectrum of the Hessian, it may be more practical to call hessianextreme or hessianspectrum. This should coincide with eig(H). Example of equivalence: Hu = getHessian(problem, x, u) is equivalent to (but much faster than): B = tangentorthobasis(M, x); H = hessianmatrix(problem, x, B); u_vec = tangent2vec(M, x, B, u); Hu_vec = H*u_vec; Hu = lincomb(M, x, B, Hu_vec); Note that there will be some error due to numerical round-off. See also: hessianspectrum hessianextreme tangentorthobasis orthogonalize tangent2vec

- StoreDB
- canGetApproxHessian Checks whether an approximate Hessian can be computed for this problem.
- canGetHessian Checks whether the Hessian can be computed for a problem structure.
- getHessian Computes the Hessian of the cost function at x along d.
- tangentorthobasis Returns an orthonormal basis of tangent vectors in the Manopt framework.

0001 function [H, basis] = hessianmatrix(problem, x, basis) 0002 % Computes a matrix which represents the Hessian in some tangent basis. 0003 % 0004 % [H, basis] = hessianmatrix(problem, x) 0005 % [H, basis] = hessianmatrix(problem, x, basis) 0006 % 0007 % problem is a Manopt problem structure with a manifold and cost function. 0008 % x is a point on the manifold problem.M. 0009 % basis (optional) is an orthonormal basis for the tangent space to the 0010 % manifold at x. If no basis is supplied, one will be generated at random. 0011 % If the basis spans only a subspace of the tangent space at x, 0012 % then the returned matrix represents the Hessian restricted to that subspace. 0013 % 0014 % H is an n-by-n symmetric matrix (with n the number of vectors in the basis) 0015 % such that H(i, j) is the inner product between basis{i} 0016 % and Hess(basis{j}), with respect to the metric on the tangent space to 0017 % problem.M at x, where Hess(basis{j}) is the vector obtained after 0018 % applying the Hessian at x to basis{j}. 0019 % 0020 % For optimization, it is usually not useful to compute the Hessian matrix, 0021 % as this quickly becomes expensive. This tool is provided mostly for 0022 % exploration and debugging rather than to be used algorithmically in 0023 % solvers. To access the spectrum of the Hessian, it may be more practical 0024 % to call hessianextreme or hessianspectrum. This should coincide with eig(H). 0025 % 0026 % 0027 % Example of equivalence: 0028 % 0029 % Hu = getHessian(problem, x, u) 0030 % 0031 % is equivalent to (but much faster than): 0032 % 0033 % B = tangentorthobasis(M, x); 0034 % H = hessianmatrix(problem, x, B); 0035 % u_vec = tangent2vec(M, x, B, u); 0036 % Hu_vec = H*u_vec; 0037 % Hu = lincomb(M, x, B, Hu_vec); 0038 % 0039 % Note that there will be some error due to numerical round-off. 0040 % 0041 % 0042 % See also: hessianspectrum hessianextreme tangentorthobasis orthogonalize tangent2vec 0043 0044 % This file is part of Manopt: www.manopt.org. 0045 % Original author: Nicolas Boumal, July 14, 2016. 0046 % Contributors: 0047 % Change log: 0048 0049 0050 % No warning if an approximate Hessian is available, as then the user 0051 % is presumably aware of what they are doing. 0052 if ~canGetHessian(problem) && ~canGetApproxHessian(problem) 0053 warning('manopt:hessianmatrix:nohessian', ... 0054 ['The Hessian appears to be unavailable.\n' ... 0055 'Will try to use an approximate Hessian instead.\n'... 0056 'Since this approximation may not be linear or '... 0057 'symmetric,\nthe computation might fail and the '... 0058 'results (if any)\nmight make no sense.']); 0059 end 0060 0061 0062 % Unless an orthonormal basis for the tangent space at x is provided, 0063 % pick a random one. 0064 if ~exist('basis', 'var') || isempty(basis) 0065 n = problem.M.dim(); 0066 basis = tangentorthobasis(problem.M, x, n); 0067 else 0068 n = numel(basis); 0069 end 0070 0071 % Create a store database and get a key for x 0072 storedb = StoreDB(1); 0073 key = storedb.getNewKey(); 0074 0075 % Apply the Hessian at x to each basis vector 0076 Hbasis = cell(n, 1); 0077 for k = 1 : numel(Hbasis) 0078 Hbasis{k} = getHessian(problem, x, basis{k}, storedb, key); 0079 end 0080 0081 % H is the matrix which contains the inner products of 0082 % the ((basis vectors)) with the ((Hessian applied to basis vectors)). 0083 H = zeros(n); 0084 for i = 1 : n 0085 H(i, i) = problem.M.inner(x, basis{i}, Hbasis{i}); 0086 for j = (i+1) : n 0087 H(i, j) = problem.M.inner(x, basis{i}, Hbasis{j}); 0088 H(j, i) = H(i, j); 0089 end 0090 end 0091 0092 end

Generated on Mon 10-Sep-2018 11:48:06 by