This file is indexed.

/usr/share/octave/packages/nurbs-1.3.10/nrbunclamp.m is in octave-nurbs 1.3.10-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
120
121
122
123
124
125
126
127
128
129
130
function ucrv = nrbunclamp (crv, k, xdim)

% NRBUNCLAMP: Compute the knot vector and control points of the unclamped curve
%
% Calling Sequence:
% 
%   ucrv = nrbrunclamp (crv, k)
%   ucrv = nrbrunclamp (crv, k, dim)
% 
% INPUT:
% 
%   crv	: NURBS curve, see nrbmak.
%   k   : continuity for the unclamping (from 0 up to p-1)
%   dim : dimension in which to unclamp (all by default).
%
% OUTPUT:
% 
%   ucrv: NURBS curve with unclamped knot vector, see nrbmak
% 
% Description:
% 
%   Unclamps a curve, removing the open knot vector. Computes the new
%     knot vector and control points of the unclamped curve.
%
%    Adapted from Algorithm A12.1 from 'The NURBS BOOK' pg577.
% 
%    Copyright (C) 2013, 2014 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/>.

if (iscell (crv.knots))
  knt = crv.knots;
  curve = false;
else
  knt = {crv.knots};
  curve = true;
end

ndim = numel (knt);
if (nargin < 3)
  xdim = 1:ndim;
end

%if (iscell (crv.knots))
  if (numel(k) ~= ndim)
    k = k * ones(1, ndim);
  end

  Pw = crv.coefs;
  for idim = xdim
    p  = crv.order(idim) - 1;
    U  = knt{idim};
    n  = crv.number(idim);
    m = n + p + 1;
    kk = k(idim);

    if (kk >= p)
      warning ('Taking the maximum k allowed, degree - 1')
      kk = p - 1;
    end

  % Unclamp at left end
    for ii=0:kk
      U(kk-ii+1) = U(kk-ii+2) - (U(n+1-ii) - U(n-ii));
    end

    Pw = permute (Pw, [1, circshift([2 3 4], [0, 1-idim])]);
    for ii = p-kk-1:p-2
      for jj = ii:-1:0
        alpha = (U(p+1) - U(p+jj-ii)) / (U(p+jj+2) - U(p+jj-ii));
        Pw(:,jj+1,:,:) = (Pw(:,jj+1,:,:) - alpha*Pw(:,jj+2,:,:))/(1-alpha);
      end
    end


  % Unclamp at right end
    for ii=0:kk
      U(m-kk+ii) = U(m-kk+ii-1) + U(p+ii+1+1) - U(p+ii+1);
    end
    
    for ii = p-kk-1:p-2
      for jj = ii:-1:0
        alpha = (U(n+1)-U(n-jj))/(U(n+2-jj+ii)-U(n-jj));
        Pw(:,n-jj,:,:) = (Pw(:,n-jj,:,:) - (1-alpha)*Pw(:,n-jj-1,:,:))/alpha;
      end
    end
    
    Pw = permute (Pw, [1, circshift([2 3 4], [0, idim-1])]);
    knt{idim} = U;

  end
  if (~curve)
    ucrv = nrbmak (Pw, knt);
  else
    ucrv = nrbmak (Pw, knt{:});
  end
  
%!demo
%! crv = nrbcirc (1,[],0,2*pi/3);
%! crv = nrbdegelev (crv, 2);
%! figure
%! nrbctrlplot (crv); hold on
%! nrbctrlplot (nrbtform (nrbunclamp (crv, 1), vectrans([-0.4, -0.4])));
%! nrbctrlplot (nrbtform (nrbunclamp (crv, 2), vectrans([-0.8, -0.8])));
%! nrbctrlplot (nrbtform (nrbunclamp (crv, 3), vectrans([-1.6, -1.6])));
%! title ('Original curve and unclamped versions')

%!test
%! crv = nrbdegelev (nrbtestcrv,2);
%! x = linspace (0, 1, 100);
%! F = nrbeval (crv, x);
%! ucrv = nrbunclamp (crv, 0);
%! assert (F, nrbeval(ucrv, x));
%! ucrv = nrbunclamp (crv, 1);
%! assert (F, nrbeval(ucrv, x), 1e-14);
%! ucrv = nrbunclamp (crv, 2);
%! assert (F, nrbeval(ucrv, x), 1e-14);
%! ucrv = nrbunclamp (crv, 3);
%! assert (F, nrbeval(ucrv, x), 1e-14);