This file is indexed.

/usr/include/ITK-4.9/itkCoxDeBoorBSplineKernelFunction.hxx is in libinsighttoolkit4-dev 4.9.0-4ubuntu1.

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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef itkCoxDeBoorBSplineKernelFunction_hxx
#define itkCoxDeBoorBSplineKernelFunction_hxx

#include "itkCoxDeBoorBSplineKernelFunction.h"
#include "itkMath.h"

namespace itk
{
template<unsigned int VSplineOrder, typename TRealValueType>
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::CoxDeBoorBSplineKernelFunction()
{
  this->m_SplineOrder = VSplineOrder;
  this->GenerateBSplineShapeFunctions( this->m_SplineOrder + 1 );
}

template<unsigned int VSplineOrder, typename TRealValueType>
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::~CoxDeBoorBSplineKernelFunction()
{}

template<unsigned int VSplineOrder, typename TRealValueType>
void
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::SetSplineOrder( const unsigned int order )
{
  if ( order != this->m_SplineOrder )
    {
    this->m_SplineOrder = order;
    this->GenerateBSplineShapeFunctions( this->m_SplineOrder + 1 );
    this->Modified();
    }
}

template<unsigned int VSplineOrder, typename TRealValueType>
void
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::GenerateBSplineShapeFunctions( const unsigned int order )
{
  const unsigned int numberOfPieces =
    static_cast<unsigned int>( static_cast< TRealValueType >(0.5) * ( order + 1 ) );

  this->m_BSplineShapeFunctions.set_size( numberOfPieces, order );

  VectorType knots( order + 1 );
  for( unsigned int i = 0; i < knots.size(); i++ )
    {
    knots[i] = static_cast< TRealValueType >(-0.5) * static_cast< TRealValueType >( order ) +
      static_cast< TRealValueType >( i );
    }

  for( unsigned int i = 0; i < numberOfPieces; i++ )
    {
    const PolynomialType poly = this->CoxDeBoor( order, knots,
      0, static_cast< unsigned int >( static_cast< TRealValueType >(0.5) * ( order ) ) + i );
    this->m_BSplineShapeFunctions.set_row( i, poly.coefficients() );
    }
}

template<unsigned int VSplineOrder, typename TRealValueType>
typename CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>::PolynomialType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::CoxDeBoor( const unsigned short order, const VectorType knots,
  const unsigned int whichBasisFunction, const unsigned int whichPiece )
{
  VectorType tmp( 2 );
  PolynomialType poly1( NumericTraits< TRealValueType >::ZeroValue() );
  PolynomialType poly2( NumericTraits< TRealValueType >::ZeroValue() );
  const unsigned short p = order - 1;
  const unsigned short i = whichBasisFunction;

  if ( p == 0 && whichBasisFunction == whichPiece )
    {
    PolynomialType poly( NumericTraits< TRealValueType >::OneValue() );
    return poly;
    }

  // Term 1
  TRealValueType den = knots(i + p) - knots(i);

  if ( itk::Math::AlmostEquals(den, NumericTraits< TRealValueType >::ZeroValue()) )
    {
    PolynomialType poly( NumericTraits< TRealValueType >::ZeroValue() );
    poly1 = poly;
    }
  else
    {
    tmp(0) = NumericTraits< TRealValueType >::OneValue();
    tmp(1) = -knots(i);
    tmp /= den;
    poly1 = PolynomialType( tmp ) *
      this->CoxDeBoor( order - 1, knots, i, whichPiece );
    }

  // Term 2
  den = knots(i + p + 1) - knots(i + 1);
  if ( itk::Math::AlmostEquals(den, NumericTraits< TRealValueType >::ZeroValue()) )
    {
    PolynomialType poly( NumericTraits< TRealValueType >::ZeroValue() );
    poly2 = poly;
    }
  else
    {
    tmp(0) = -NumericTraits< TRealValueType >::OneValue();
    tmp(1) = knots(i + p + 1);
    tmp /= den;
    poly2 = PolynomialType( tmp ) *
      this->CoxDeBoor( order - 1, knots, i + 1, whichPiece );
    }
  return ( poly1 + poly2 );
}

template<unsigned int VSplineOrder, typename TRealValueType>
typename CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>::MatrixType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::GetShapeFunctionsInZeroToOneInterval()
{
  const int order = this->m_SplineOrder + 1;
  const unsigned int numberOfPieces = static_cast<unsigned int>( order );
  MatrixType shapeFunctions( numberOfPieces, order );

  VectorType knots( 2 * order );

  for( unsigned int i = 0; i < knots.size(); i++ )
    {
    knots[i] = -static_cast<TRealValueType>( this->m_SplineOrder ) +
      static_cast<TRealValueType>( i );
    }

  for( unsigned int i = 0; i < numberOfPieces; i++ )
    {
    const PolynomialType poly = this->CoxDeBoor( order, knots, i, order - 1 );
    shapeFunctions.set_row( i, poly.coefficients() );
    }
  return shapeFunctions;
}

template<unsigned int VSplineOrder, typename TRealValueType>
typename CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>::MatrixType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::GetShapeFunctions()
{
  return this->m_BSplineShapeFunctions;
}


template<unsigned int VSplineOrder, typename TRealValueType>
TRealValueType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::Evaluate( const TRealValueType &u ) const
{
  const TRealValueType absValue = vnl_math_abs( u );

  unsigned int which;
  if( this->m_SplineOrder % 2 == 0 )
    {
    which = static_cast< unsigned int >( absValue + static_cast< TRealValueType >(0.5) );
    }
  else
    {
    which = static_cast< unsigned int >( absValue );
    }

  if( which < this->m_BSplineShapeFunctions.rows() )
    {
    return PolynomialType(
      this->m_BSplineShapeFunctions.get_row( which ) ).evaluate( absValue );
    }
  else
    {
    return NumericTraits< TRealValueType >::ZeroValue();
    }
}

template<unsigned int VSplineOrder, typename TRealValueType>
TRealValueType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::EvaluateDerivative( const TRealValueType &u ) const
{
  return this->EvaluateNthDerivative( u, 1 );
}

template<unsigned int VSplineOrder, typename TRealValueType>
TRealValueType
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::EvaluateNthDerivative( const TRealValueType & u, const unsigned int n ) const
{
  const TRealValueType absValue = vnl_math_abs( u );

  unsigned int which;
  if( this->m_SplineOrder % 2 == 0 )
    {
    which = static_cast<unsigned int>( absValue + static_cast< TRealValueType >(0.5) );
    }
  else
    {
    which = static_cast<unsigned int>( absValue );
    }

  if( which < this->m_BSplineShapeFunctions.rows() )
    {
    PolynomialType polynomial(
      this->m_BSplineShapeFunctions.get_row( which ) );
    for( unsigned int i = 0; i < n; i++ )
      {
      polynomial = polynomial.derivative();
      }
    const TRealValueType der = polynomial.evaluate( absValue );
    if( u < NumericTraits< TRealValueType >::ZeroValue() && n % 2 != 0 )
      {
      return -der;
      }
    else
      {
      return der;
      }
    }
  else
    {
    return NumericTraits< TRealValueType >::ZeroValue();
    }
}

template<unsigned int VSplineOrder, typename TRealValueType>
void
CoxDeBoorBSplineKernelFunction<VSplineOrder,TRealValueType>
::PrintSelf( std::ostream &os, Indent indent ) const
{
  Superclass::PrintSelf(os, indent);
  os << indent  << "Spline Order: " << this->m_SplineOrder << std::endl;
  os << indent  << "Piecewise Polynomial Pieces: " << std::endl;

  TRealValueType a = NumericTraits< TRealValueType >::ZeroValue();
  TRealValueType b = NumericTraits< TRealValueType >::ZeroValue();

  for( unsigned int i = 0; i < this->m_BSplineShapeFunctions.rows(); i++ )
    {
    os << indent << indent;

    PolynomialType( this->m_BSplineShapeFunctions.get_row(  i) ).print( os );

    if ( i == 0 )
      {
      if ( this->m_SplineOrder % 2 == 0 )
        {
        b = static_cast< TRealValueType >(0.5);
        }
      else
        {
        b = NumericTraits< TRealValueType >::OneValue();
        }
      }
    else
      {
      a = b;
      b += NumericTraits< TRealValueType >::OneValue();
      }

    os << ",  X \\in [" << a << ", " << b << "]" << std::endl;
    }
}
} // namespace itk

#endif