MathTL/numerics/cardinal_splines.h
inline
  double EvaluateCardinalBSpline(const int d, const int k, double x)
  {
    if (x < k)
      return 0.;
    else
      {
	if (x >= k+d)
	  return 0.;
	else
	  {
	    // we know that x\in\supp N_d(.-k) 
	    if (d == 1)
	      return 1.;
	    else
	      {
		// hard-encode case d=2 
		if (d == 2)
		  {
		    if (x < k+1)
		      return x-k;
		    else
		      return 2.-(x-k);
		  }
		else
		  return ((x-k) * EvaluateCardinalBSpline(d-1, k, x)
			  + (k+d-x) * EvaluateCardinalBSpline(d-1, k+1, x)) / (d-1);
	      }
	  }
      }
  }
/*!
    evaluate a shifted cardinal B-spline N_d(x-k) via recursion
    (remark: only use this version if the spline order d is unknown at compile time)
  */
evaluate a shifted cardinal B-spline N_d(x-k) via recursion
(remark: only use this version if the spline order d is unknown at compile time)
evaluate a shifted cardinal B - spline N_d ( x - k ) via recursion ( remark : only use this version if the spline order d is unknown at compile time )
inline
  double EvaluateCardinalBSpline(const int d, const int k, double x)
  {
    if (x < k)
      return 0.;
    else
      {
	if (x >= k+d)
	  return 0.;
	else
	  {
	    if (d == 1)
	      return 1.;
	    else
	      {
		if (d == 2)
		  {
		    if (x < k+1)
		      return x-k;
		    else
		      return 2.-(x-k);
		  }
		else
		  return ((x-k) * EvaluateCardinalBSpline(d-1, k, x)
			  + (k+d-x) * EvaluateCardinalBSpline(d-1, k+1, x)) / (d-1);
	      }
	  }
      }
  }
inline double EvaluateCardinalBSpline ( const int d , const int k , double x ) { if ( x < k ) return 0. ; else { if ( x >= k + d ) return 0. ; else { if ( d == 1 ) return 1. ; else { if ( d == 2 ) { if ( x < k + 1 ) return x - k ; else return 2. - ( x - k ) ; } else return ( ( x - k ) * EvaluateCardinalBSpline ( d - 1 , k , x ) + ( k + d - x ) * EvaluateCardinalBSpline ( d - 1 , k + 1 , x ) ) / ( d - 1 ) ; } } } }
evaluate a shifted cardinal B-spline N_d(x-k) via recursion
(remark: only use this version if the spline order d is unknown at compile time)
evaluate a shifted cardinal B - spline N_d ( x - k ) via recursion ( remark : only use this version if the spline order d is unknown at compile time )
// we know that x\in\supp N_d(.-k)  // hard-encode case d=2 