This file is indexed.

/usr/share/octave/packages/signal-1.3.0/sigmoid_train.m is in octave-signal 1.3.0-1.

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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
## Copyright (c) 2011-2013 Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
##
## 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 -*-
## @deftypefn {Function File} {@var{y} =} sigmoid_train (@var{t}, @var{ranges}, @var{rc})
##
## Evaluate a train of sigmoid functions at @var{t}.
##
## The number and duration of each sigmoid is determined from @var{ranges}.
## Each row of @var{ranges} represents a real interval, e.g. if sigmoid
## @code{i} starts at @code{t=0.1} and ends at @code{t=0.5}, then
## @code{@var{ranges}(i,:) = [0.1 0.5]}.
## The input @var{rc} is an array that defines the rising and falling time
## constants of each sigmoid.  Its size must equal the size of @var{ranges}.
##
## Run @code{demo sigmoid_train} to some examples of the use of this function.
##
## @end deftypefn

function envelope = sigmoid_train (t, range, timeconstant)

  ## number of sigmoids
  nRanges = size (range, 1);

  ## Parse time constants
  if isscalar (timeconstant)
    ## All bumps have the same time constant and are symmetric
    timeconstant = timeconstant * ones (nRanges,2);

  elseif any( size(timeconstant) != [1 1])

    ## All bumps have different time constant but are symmetric
    if length(timeconstant) ~= nRanges
      error('signalError','Length of time constant must equal number of ranges.')
    endif
    if isrow (timeconstant)
      timeconstant = timeconstant';
    endif
    timeconstant = repmat (timeconstant,1,2);

  endif

  ## Make sure t is horizontal
  flag_transposed = false;
  if iscolumn (t)
    t               = t.';
    flag_transposed = true;
  endif
  [ncol nrow]     = size (t);

  ## Compute arguments of each sigmoid
  T    = repmat (t, nRanges, 1);
  RC1  = repmat (timeconstant(:,1), 1, nrow);
  RC2  = repmat (timeconstant(:,2), 1, nrow);
  a_up = (repmat (range(:,1), 1 ,nrow) - T)./RC1;
  a_dw = (repmat (range(:,2), 1 ,nrow) - T)./RC2;

  ## Evaluate the sigmoids and mix them
  Y        = 1 ./ ( 1 + exp (a_up) ) .* (1 - 1 ./ ( 1 + exp (a_dw) ) );
  envelope = max(Y,[],1);

  if flag_transposed
    envelope = envelope.';
  endif

endfunction

%!demo
%! # Vectorized
%! t = linspace (0, 2, 500);
%! range = [0.1 0.4; 0.6 0.8; 1 2];
%! rc = [1e-2 1e-2; 1e-3 1e-3; 2e-2 2e-2];
%! y = sigmoid_train (t, range, rc);
%!
%! close all
%! for i=1:3
%!     patch ([range(i,[2 2]) range(i,[1 1])], [0 1 1 0],...
%!               'facecolor', [1 0.8 0.8],'edgecolor','none');
%! endfor
%! hold on; plot (t, y, 'b;Sigmoid train;','linewidth',2); hold off
%! xlabel('time'); ylabel('S(t)')
%! title ('Vectorized use of sigmoid train')
%! axis tight
%!
%! #-------------------------------------------------------------------------
%! # The colored regions show the limits defined in range.

%!demo
%! # On demand
%! t = linspace(0,2,200).';
%! ran = [0.5 1; 1.5 1.7];
%! rc = 3e-2;
%! dxdt = @(x_,t_) [ x_(2); sigmoid_train(t_, ran, rc) ];
%! y = lsode(dxdt,[0 0],t);
%!
%! close all
%! for i=1:2
%!     patch ([ran(i,[2 2]) ran(i,[1 1])], [0 1 1 0],...
%!               'facecolor', [1 0.8 0.8],'edgecolor','none');
%! endfor
%! hold on; plot (t, y(:,2), 'b;Speed;','linewidth',2); hold off
%! xlabel('time'); ylabel('V(t)')
%! title ('On demand use of sigmoid train')
%! axis tight
%!
%! #-------------------------------------------------------------------------
%! # The colored regions show periods when the force is active.