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). See also: hessianspectrum hessianextreme tangentorthobasis orthogonalize

- StoreDB
- 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 % See also: hessianspectrum hessianextreme tangentorthobasis orthogonalize 0027 0028 % This file is part of Manopt: www.manopt.org. 0029 % Original author: Nicolas Boumal, July 14, 2016. 0030 % Contributors: 0031 % Change log: 0032 0033 0034 % Unless an orthonormal basis for the tangent space at x is provided, 0035 % pick a random one. 0036 if ~exist('basis', 'var') || isempty(basis) 0037 n = problem.M.dim(); 0038 basis = tangentorthobasis(problem.M, x, n); 0039 else 0040 n = numel(basis); 0041 end 0042 0043 % Create a store database and get a key for x 0044 storedb = StoreDB(1); 0045 key = storedb.getNewKey(); 0046 0047 % Apply the Hessian at x to each basis vector 0048 Hbasis = cell(n, 1); 0049 for k = 1 : numel(Hbasis) 0050 Hbasis{k} = getHessian(problem, x, basis{k}, storedb, key); 0051 end 0052 0053 % H is the matrix which contains the inner products of 0054 % the ((basis vectors)) with the ((Hessian applied to basis vectors)). 0055 H = zeros(n); 0056 for i = 1 : n 0057 H(i, i) = problem.M.inner(x, basis{i}, Hbasis{i}); 0058 for j = (i+1) : n 0059 H(i, j) = problem.M.inner(x, basis{i}, Hbasis{j}); 0060 H(j, i) = H(i, j); 0061 end 0062 end 0063 0064 end

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