Skip to content

Commit cdf7c77

Browse files
committed
Check whether inital function value or gradient is NaN
1 parent 6d0ace4 commit cdf7c77

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

optim/fminscg.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@
127127

128128
sigma0 = 1.0e-4;
129129
[fold,gradold] = fun(x); % Initial function value and gradient
130+
if isnan(fold)
131+
error('Initial function value is NaN')
132+
end
133+
if isnan(gradold)
134+
error('Initial gradient is NaN')
135+
end
130136
funcCount=1;
131137
gradCount=1;
132138
gradnew = gradold;

0 commit comments

Comments
 (0)