/usr/share/octave/packages/symbolic-2.6.0/dirac.m is in octave-symbolic 2.6.0-3build1.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | %% Copyright (C) 2006 Sylvain Pelissier <sylvain.pelissier@gmail.com>
%% Copyright (C) 2015-2016 Colin B. Macdonald <cbm@m.fsf.org>
%%
%% This program is free software; you can redistribute it and/or modify it under
%% the terms of the GNU General Public License as published by the Free Software
%% Foundation; either version 3 of the License, or (at your option) any later
%% version.
%%
%% This program is distributed in the hope that it will be useful, but WITHOUT
%% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
%% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
%% details.
%%
%% You should have received a copy of the GNU General Public License along with
%% this program; if not, see <http://www.gnu.org/licenses/>.
%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defun dirac (@var{x})
%% Compute the Dirac delta (generalized) function.
%%
%% The Dirac delta ``function'' is a generalized function (or distribution)
%% which is zero almost everywhere, except at the origin where it is
%% infinite.
%%
%% Examples:
%% @example
%% @group
%% dirac (0)
%% @result{} Inf
%% dirac (1)
%% @result{} 0
%% dirac ([-10 -1 0 1 inf])
%% @result{} 0 0 Inf 0 0
%% @end group
%% @end example
%% @seealso{heaviside, @@sym/dirac}
%% @end defun
function y = dirac(x)
if (nargin ~= 1)
print_usage ();
end
if (~isreal (x))
error ('dirac: X must not contain complex values');
end
y = zeros (size (x), class (x));
y(x == 0) = Inf;
y(isnan (x)) = NaN;
end
%!assert (isinf (dirac (0)))
%!assert (dirac (1) == 0)
%!assert (isnan (dirac (nan)))
%!assert (isequaln (dirac ([-1 1 0 eps inf -inf nan]), [0 0 inf 0 0 0 nan]))
%!error <complex values> dirac (1i)
%!assert (isa (dirac (single (0)), 'single'))
|