This file is indexed.

/usr/share/octave/packages/control-2.6.2/@iddata/filter.m is in octave-control 2.6.2-1build1.

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
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
## Copyright (C) 2009-2014   Lukas F. Reichlin
##
## This file is part of LTI Syncope.
##
## LTI Syncope 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.
##
## LTI Syncope 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 LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
## @deftypefn {Function File} {@var{dat} =} filter (@var{dat}, @var{sys})
## @deftypefnx {Function File} {@var{dat} =} filter (@var{dat}, @var{b}, @var{a})
## Filter output and input signals of dataset @var{dat}.
## The filter is specified either by @acronym{LTI} system @var{sys}
## or by transfer function polynomials @var{b} and @var{a} as described
## in the help text of the built-in filter command.  Type @code{help filter}
## for more information.
##
## @strong{Inputs}
## @table @var
## @item dat
## iddata identification dataset containing signals in time-domain.
## @item sys
## @acronym{LTI} object containing the discrete-time filter.
## @item b
## Numerator polynomial of the discrete-time filter.
## Must be a row vector containing the coefficients
## of the polynomial in ascending powers of z^-1.
## @item a
## Denominator polynomial of the discrete-time filter.
## Must be a row vector containing the coefficients
## of the polynomial in ascending powers of z^-1.
## @end table
##
## @strong{Outputs}
## @table @var
## @item dat
## iddata identification dataset with filtered 
## output and input signals.
## @end table
##
## @end deftypefn

## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: August 2012
## Version: 0.1

function dat = filter (dat, b, a = [], si = [])

  if (nargin < 2 || nargin > 4)
    print_usage ();
  endif
  
  if (! isa (dat, "iddata"))          # there's at least one iddata set, but not as the first argument
    error ("iddata: filter: first argument must be an iddata set");
  endif

  if (! dat.timedomain)
    error ("iddata: filter: require iddata set in time-domain");
  endif

  if (isa (b, "lti"))                 # filter (dat, sys)
    if (nargin > 3)                   # filter (dat, sys, si) has at most 3 inputs
      print_usage ();
    endif
    if (! issiso (b))
      error ("iddata: filter: second argument must be a SISO LTI system");
    endif
    si = a;                           # filter (dat, sys, si)
    if (isct (b))                     # sys is continuous-time
      b = c2d (b, dat.tsam{1});       # does this discretization/tsam make sense?
    endif
    [b, a] = filtdata (b, "vector");  # convert LTI system to transfer function
  elseif (nargin < 3)
    print_usage ();
  endif

  ## use Octave's filter function for each experiment
  ## the fifth argument '1' specifies the dimension in case of datasets with only 1 sample
  dat.y = cellfun (@(y) filter (b, a, y, si, 1), dat.y, "uniformoutput", false);
  dat.u = cellfun (@(u) filter (b, a, u, si, 1), dat.u, "uniformoutput", false);

endfunction


## TODO: adapt test
%!shared DATD, Z
%! DAT = iddata ({[(1:10).', (1:2:20).'], [(10:-1:1).', (20:-2:1).']}, {[(41:50).', (46:55).'], [(61:70).', (-66:-1:-75).']});
%! DATD = detrend (DAT, "linear");
%! Z = zeros (10, 2);
%!assert (DATD.y{1}, Z, 1e-10);
%!assert (DATD.y{2}, Z, 1e-10);
%!assert (DATD.u{1}, Z, 1e-10);
%!assert (DATD.u{2}, Z, 1e-10);