Checks whether the Hessian can be computed for a problem structure. function candoit = canGetHessian(problem) Returns true if the Hessian of the cost function can be computed given the problem description, false otherwise. See also: canGetCost canGetDirectionalDerivative canGetGradient
0001 function candoit = canGetHessian(problem) 0002 % Checks whether the Hessian can be computed for a problem structure. 0003 % 0004 % function candoit = canGetHessian(problem) 0005 % 0006 % Returns true if the Hessian of the cost function can be computed given 0007 % the problem description, false otherwise. 0008 % 0009 % See also: canGetCost canGetDirectionalDerivative canGetGradient 0010 0011 % This file is part of Manopt: www.manopt.org. 0012 % Original author: Nicolas Boumal, Dec. 30, 2012. 0013 % Contributors: 0014 % Change log: 0015 0016 candoit = isfield(problem, 'hess') || ... 0017 (isfield(problem, 'ehess') && canGetEuclideanGradient(problem)); 0018 0019 % Display an extra warning message to the user in anticipation of 0020 % common mistakes. 0021 if ~candoit && ... 0022 (isfield(problem, 'ehess') && ~canGetEuclideanGradient(problem)) 0023 warning('manopt:canGetHessian', ... 0024 ['If the Hessian is supplied as a Euclidean Hessian (ehess),\n' ... 0025 'then the Euclidean gradient must also be supplied (egrad).']); 0026 end 0027 0028 end