def spalde(x,tck): """Evaluate all derivatives of a B-spline. Description: Given the knots and coefficients of a cubic B-spline compute all derivatives up to order k at a point (or set of points). Inputs: tck -- A length 3 sequence describing the given spline (See splev). x -- A point or a set of points at which to evaluate the derivatives. Note that t(k) <= x <= t(n-k+1) must hold for each x. Outputs: (results, ) results -- An array (or a list of arrays) containing all derivatives up to order k inclusive for each point x. See also: splprep, splrep, splint, sproot, splev - evaluation, roots, integral bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ t,c,k=tck try: c[0][0] # check if c is >1-d parametric = True # it is except TypeError: parametric = False # c is 1-d if parametric: return map(lambda c,x=x,t=t,k=k:spalde(x,[t,c,k]),c) else: try: x=x.tolist() except: try: x=list(x) except: x=[x] if len(x)>1: return map(lambda x,tck=tck:spalde(x,tck),x) c = c.copy() c.resize(len(t)) d,ier=dfitpack.spalde(t,c,k,x[0]) if ier==0: return d if ier==10: raise TypeError,"Invalid input data. t(k)<=x<=t(n-k+1) must hold." raise TypeError,"Unknown error"
def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" d, ier = dfitpack.spalde(*(self._eval_args + (x, ))) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return d
def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" d, ier = dfitpack.spalde(*(self._eval_args + (x,))) assert ier == 0, ` ier ` return d
def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" d,ier = dfitpack.spalde(*(self._eval_args+(x,))) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return d
def derivatives(self, x): """ Return all derivatives of the spline at the point x.""" d,ier = dfitpack.spalde(*(self._eval_args+(x,))) assert ier==0,`ier` return d