Checks whether an approximate gradient can be computed for this problem. function candoit = canGetApproxGradient(problem) Returns true if an approximate gradient of the cost function is provided in the given problem description, false otherwise. If a gradient is defined but no approximate gradient is defined explicitly, returns false. Even if this returns false, calls to getApproxGradient may succeed, as they will be redirected to getGradientFD. The latter simply requires availability of the cost in problem. See also: canGetGradient getGradientFD
0001 function candoit = canGetApproxGradient(problem) 0002 % Checks whether an approximate gradient can be computed for this problem. 0003 % 0004 % function candoit = canGetApproxGradient(problem) 0005 % 0006 % Returns true if an approximate gradient of the cost function is provided 0007 % in the given problem description, false otherwise. 0008 % If a gradient is defined but no approximate gradient is defined 0009 % explicitly, returns false. 0010 % 0011 % Even if this returns false, calls to getApproxGradient may succeed, as 0012 % they will be redirected to getGradientFD. The latter simply requires 0013 % availability of the cost in problem. 0014 % 0015 % See also: canGetGradient getGradientFD 0016 0017 % This file is part of Manopt: www.manopt.org. 0018 % Original author: Nicolas Boumal, Nov. 1, 2016. 0019 % Contributors: 0020 % Change log: 0021 0022 candoit = isfield(problem, 'approxgrad'); 0023 0024 end