/usr/share/octave/site/m/vlfeat/toolbox/misc/vl_numder2.m is in octave-vlfeat 0.9.17+dfsg0-6+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | function d = vl_numder2(func, x, varargin)
% VL_NUMDER2 Numerical second derivative
% D = VL_NUMDER2(FUNC, X) computes the numerical second derivative of
% the function FUNC at point X.
%
% D = VL_NUMDER2(FUNC, X, ARG1, ARG2, ...) allow to pass extra
% parameters to the function FUNC.
%
% See also: VL_NUMDER(), VL_HELP().
N=length(x(:)) ;
f00 = feval(func, x, varargin{:}) ;
d=zeros(length(f00),N,N) ;
D=1e-5 ;
D2=D*D ;
for n=1:N
en=zeros(size(x)) ; en(n)=1 ;
for m=1:N
em=zeros(size(x)) ; em(m)=1 ;
if( n ~= m )
f10 = feval(func, x+en*D, varargin{:}) ;
f01 = feval(func, x+em*D, varargin{:}) ;
f11 = feval(func, x+en*D+em*D, varargin{:}) ;
d(:,n,m) = (f11-f01+f00-f10)/D2 ;
else
fp = feval(func, x+en*D, varargin{:}) ;
fm = feval(func, x-en*D, varargin{:}) ;
d(:,n,m) = (fm+fp-2*f00)/D2 ;
end
end
end
|