This file is indexed.

/usr/share/octave/packages/nurbs-1.3.7/basisfunder.m is in octave-nurbs 1.3.7-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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
function dersv = basisfunder (ii, pl, uu, u_knotl, nders)

% BASISFUNDER:  B-Spline Basis function derivatives.
%
% Calling Sequence:
% 
%   ders = basisfunder (ii, pl, uu, k, nd)
%
%    INPUT:
%   
%      ii  - knot span index (see findspan)
%      pl  - degree of curve
%      uu  - parametric points
%      k   - knot vector
%      nd  - number of derivatives to compute
%
%    OUTPUT:
%   
%      ders - ders(n, i, :) (i-1)-th derivative at n-th point
%   
%    Adapted from Algorithm A2.3 from 'The NURBS BOOK' pg72.
%
% See also: 
%
%    numbasisfun, basisfun, findspan
%
%    Copyright (C) 2009,2011 Rafael Vazquez
%
%    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/>.

  dersv = zeros(numel(uu), nders+1, pl+1);

  for jj = 1:numel(uu)

    i = ii(jj)+1; %% convert to base-1 numbering of knot spans
    u = uu(jj);

    ders = zeros(nders+1,pl+1);
    ndu = zeros(pl+1,pl+1);
    left = zeros(pl+1);
    right = zeros(pl+1);
    a = zeros(2,pl+1);
    ndu(1,1) = 1;
    for j = 1:pl
      left(j+1) = u - u_knotl(i+1-j);
      right(j+1) = u_knotl(i+j) - u;
      saved = 0;
      for r = 0:j-1
        ndu(j+1,r+1) = right(r+2) + left(j-r+1);
        temp = ndu(r+1,j)/ndu(j+1,r+1);
        ndu(r+1,j+1) = saved + right(r+2)*temp;
        saved = left(j-r+1)*temp;
      end
      ndu(j+1,j+1) = saved;
    end   
    for j = 0:pl
      ders(1,j+1) = ndu(j+1,pl+1);
    end
    for r = 0:pl
      s1 = 0;
      s2 = 1;
      a(1,1) = 1;
      for k = 1:nders %compute kth derivative
        d = 0;
        rk = r-k;
        pk = pl-k;
        if (r >= k)
          a(s2+1,1) = a(s1+1,1)/ndu(pk+2,rk+1);
          d = a(s2+1,1)*ndu(rk+1,pk+1);
        end
        if (rk >= -1)
          j1 = 1;
        else 
          j1 = -rk;
        end
        if ((r-1) <= pk)
          j2 = k-1;
        else 
          j2 = pl-r;
        end
        for j = j1:j2
          a(s2+1,j+1) = (a(s1+1,j+1) - a(s1+1,j))/ndu(pk+2,rk+j+1);
          d = d + a(s2+1,j+1)*ndu(rk+j+1,pk+1);
        end
        if (r <= pk)
          a(s2+1,k+1) = -a(s1+1,k)/ndu(pk+2,r+1);
          d = d + a(s2+1,k+1)*ndu(r+1,pk+1);
        end
        ders(k+1,r+1) = d;
        j = s1;
        s1 = s2;
        s2 = j;
      end
    end
    r = pl;
    for k = 1:nders
      for j = 0:pl
        ders(k+1,j+1) = ders(k+1,j+1)*r;
      end
      r = r*(pl-k);
    end

    dersv(jj, :, :) = ders;
    
  end

end

%!test
%! k    = [0 0 0 0 1 1 1 1];
%! p    = 3;
%! u    = rand (1);
%! i    = findspan (numel(k)-p-2, p, u, k);
%! ders = basisfunder (i, p, u, k, 1);
%! sumders = sum (squeeze(ders), 2);
%! assert (sumders(1), 1, 1e-15);
%! assert (sumders(2:end), 0, 1e-15);

%!test
%! k    = [0 0 0 0 1/3 2/3 1 1 1 1];
%! p    = 3;
%! u    = rand (1);
%! i    = findspan (numel(k)-p-2, p, u, k);
%! ders = basisfunder (i, p, u, k, 7); 
%! sumders = sum (squeeze(ders), 2);
%! assert (sumders(1), 1, 1e-15);
%! assert (sumders(2:end), zeros(rows(squeeze(ders))-1, 1), 1e-13);

%!test
%! k    = [0 0 0 0 1/3 2/3 1 1 1 1];
%! p    = 3;
%! u    = rand (100, 1);
%! i    = findspan (numel(k)-p-2, p, u, k);
%! ders = basisfunder (i, p, u, k, 7);
%! for ii=1:10
%!   sumders = sum (squeeze(ders(ii,:,:)), 2);
%!   assert (sumders(1), 1, 1e-15);
%!   assert (sumders(2:end), zeros(rows(squeeze(ders(ii,:,:)))-1, 1), 1e-13);
%! end
%! assert (ders(:, (p+2):end, :), zeros(numel(u), 8-p-1, p+1), 1e-13)
%! assert (all(all(ders(:, 1, :) <= 1)), true)