10 #ifndef EIGEN_SPLINE_H
11 #define EIGEN_SPLINE_H
36 template <
typename Scalar_,
int Dim_,
int Degree_>
82 template <
typename OtherVectorType,
typename OtherArrayType>
89 template <
int OtherDegree>
136 template <
int DerivativeOrder>
180 template <
int DerivativeOrder>
226 template <
typename DerivativeType>
235 template <
typename Scalar_,
int Dim_,
int Degree_>
242 if (u <= knots(0))
return degree;
243 const Scalar* pos = std::upper_bound(knots.data()+degree-1, knots.data()+knots.size()-degree-1, u);
244 return static_cast<DenseIndex>( std::distance(knots.data(), pos) - 1 );
247 template <
typename Scalar_,
int Dim_,
int Degree_>
272 const Scalar tmp = N(r)/(right(r+1)+left(
j-r));
273 N[r] = saved + right(r+1)*tmp;
274 saved = left(
j-r)*tmp;
281 template <
typename Scalar_,
int Dim_,
int Degree_>
285 return m_knots.size() - m_ctrls.cols() - 1;
290 template <
typename Scalar_,
int Dim_,
int Degree_>
296 template <
typename Scalar_,
int Dim_,
int Degree_>
307 return (ctrl_weights * ctrl_pts).rowwise().sum();
312 template <
typename SplineType,
typename DerivativeType>
317 enum { DerivativeOrder = DerivativeType::ColsAtCompileTime };
321 typedef typename BasisDerivativeType::ConstRowXpr BasisDerivativeRowXpr;
328 der.resize(Dimension,
n+1);
331 const BasisDerivativeType basis_func_ders = spline.template basisFunctionDerivatives<DerivativeOrder>(u,
n+1);
334 for (
DenseIndex der_order=0; der_order<
n+1; ++der_order)
338 der.col(der_order) = (ctrl_weights * ctrl_pts).rowwise().sum();
342 template <
typename Scalar_,
int Dim_,
int Degree_>
343 typename SplineTraits< Spline<Scalar_, Dim_, Degree_> >::DerivativeType
351 template <
typename Scalar_,
int Dim_,
int Degree_>
352 template <
int DerivativeOrder>
361 template <
typename Scalar_,
int Dim_,
int Degree_>
362 typename SplineTraits< Spline<Scalar_, Dim_, Degree_> >::BasisVectorType
371 template <
typename Scalar_,
int Dim_,
int Degree_>
372 template <
typename DerivativeType>
401 left[
j] = u-U[span+1-
j];
402 right[
j] = U[span+
j]-u;
408 ndu(
j,r) = right[r+1]+left[
j-r];
409 temp = ndu(r,
j-1)/ndu(
j,r);
411 ndu(r,
j) =
static_cast<Scalar>(saved+right[r+1] * temp);
412 saved = left[
j-r] * temp;
415 ndu(
j,
j) =
static_cast<Scalar>(saved);
418 for (
j =
p;
j>=0; --
j)
422 DerivativeType
a(
n+1,
p+1);
431 for (
DenseIndex k=1; k<=static_cast<DenseIndex>(
n); ++k)
439 a(s2,0) =
a(s1,0)/ndu(pk+1,rk);
440 d =
a(s2,0)*ndu(rk,pk);
446 if (r-1 <= pk) j2 = k-1;
449 for (
j=j1;
j<=j2; ++
j)
451 a(s2,
j) = (
a(s1,
j)-
a(s1,
j-1))/ndu(pk+1,rk+
j);
452 d +=
a(s2,
j)*ndu(rk+
j,pk);
457 a(s2,k) = -
a(s1,k-1)/ndu(pk+1,r);
458 d +=
a(s2,k)*ndu(r,pk);
461 N_(k,r) =
static_cast<Scalar>(d);
462 j = s1; s1 = s2; s2 =
j;
469 for (
DenseIndex k=1; k<=static_cast<DenseIndex>(
n); ++k)
471 for (
j=
p;
j>=0; --
j) N_(k,
j) *= r;
476 template <
typename Scalar_,
int Dim_,
int Degree_>
481 BasisFunctionDerivativesImpl(u, order, degree(), knots(), der);
485 template <
typename Scalar_,
int Dim_,
int Degree_>
486 template <
int DerivativeOrder>
491 BasisFunctionDerivativesImpl(u, order, degree(), knots(), der);
495 template <
typename Scalar_,
int Dim_,
int Degree_>
496 typename SplineTraits<Spline<Scalar_, Dim_, Degree_> >::BasisDerivativeType
504 BasisFunctionDerivativesImpl(u, order, degree, knots, der);
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
static const ConstantReturnType Ones()
static const ConstantReturnType Zero()
A class representing multi-dimensional spline curves.
Spline(const OtherVectorType &knots, const OtherArrayType &ctrls)
Creates a spline from a knot vector and control points.
DenseIndex degree() const
Returns the spline degree.
SplineTraits< Spline >::DerivativeType derivatives(Scalar u, DenseIndex order) const
Evaluation of spline derivatives of up-to given order.
PointType operator()(Scalar u) const
Returns the spline value at a given site .
static void BasisFunctionDerivativesImpl(const typename Spline< Scalar_, Dim_, Degree_ >::Scalar u, const DenseIndex order, const DenseIndex p, const typename Spline< Scalar_, Dim_, Degree_ >::KnotVectorType &U, DerivativeType &N_)
SplineTraits< Spline, DerivativeOrder >::DerivativeType derivatives(Scalar u, DenseIndex order=DerivativeOrder) const
Evaluation of spline derivatives of up-to given order.
SplineTraits< Spline >::ParameterVectorType ParameterVectorType
The data type used to store parameter vectors.
SplineTraits< Spline, DerivativeOrder >::BasisDerivativeType basisFunctionDerivatives(Scalar u, DenseIndex order=DerivativeOrder) const
Computes the non-zero spline basis function derivatives up to given order.
SplineTraits< Spline >::BasisDerivativeType basisFunctionDerivatives(Scalar u, DenseIndex order) const
Computes the non-zero spline basis function derivatives up to given order.
const ControlPointVectorType & ctrls() const
Returns the ctrls of the underlying spline.
Spline(const Spline< Scalar, Dimension, OtherDegree > &spline)
Copy constructor for splines.
static DenseIndex Span(typename SplineTraits< Spline >::Scalar u, DenseIndex degree, const typename SplineTraits< Spline >::KnotVectorType &knots)
Computes the span within the provided knot vector in which u is falling.
SplineTraits< Spline >::KnotVectorType KnotVectorType
The data type used to store knot vectors.
SplineTraits< Spline >::ControlPointVectorType ControlPointVectorType
The data type representing the spline's control points.
DenseIndex span(Scalar u) const
Returns the span within the knot vector in which u is falling.
Spline()
Creates a (constant) zero spline. For Splines with dynamic degree, the resulting degree will be 0.
SplineTraits< Spline >::PointType PointType
The point type the spline is representing.
SplineTraits< Spline >::BasisVectorType BasisVectorType
The data type used to store non-zero basis functions.
SplineTraits< Spline >::BasisDerivativeType BasisDerivativeType
The data type used to store the values of the basis function derivatives.
static BasisDerivativeType BasisFunctionDerivatives(const Scalar u, const DenseIndex order, const DenseIndex degree, const KnotVectorType &knots)
Computes the non-zero spline basis function derivatives up to given order.
static BasisVectorType BasisFunctions(Scalar u, DenseIndex degree, const KnotVectorType &knots)
Returns the spline's non-zero basis functions.
const KnotVectorType & knots() const
Returns the knots of the underlying spline.
ControlPointVectorType m_ctrls
SplineTraits< Spline >::BasisVectorType basisFunctions(Scalar u) const
Computes the non-zero basis functions at the given site.
: TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex
void derivativesImpl(const SplineType &spline, typename SplineType::Scalar u, DenseIndex order, DerivativeType &der)