def roots(self): """ Return the zeros of the spline. Restriction: only cubic splines are supported by fitpack. """ k = self._data[5] if k == 3: z, m, ier = dfitpack.sproot(*self._eval_args[:2]) assert ier == 0, ` ier ` return z[:m] raise NotImplementedError, "finding roots not supported for non-cubic splines"
def roots(self): """ Return the zeros of the spline. Restriction: only cubic splines are supported by fitpack. """ k = self._data[5] if k==3: z,m,ier = dfitpack.sproot(*self._eval_args[:2]) assert ier==0,`ier` return z[:m] raise NotImplementedError,\ 'finding roots unsupported for non-cubic splines'
def roots(self): """ Return the zeros of the spline. Restriction: only cubic splines are supported by fitpack. """ k = self._data[5] if k == 3: z, m, ier = dfitpack.sproot(*self._eval_args[:2]) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return z[:m] raise NotImplementedError('finding roots unsupported for ' 'non-cubic splines')
def roots(self): """ Return the zeros of the spline. Restriction: only cubic splines are supported by fitpack. """ k = self._data[5] if k==3: z,m,ier = dfitpack.sproot(*self._eval_args[:2]) if not ier == 0: raise ValueError("Error code returned by spalde: %s" % ier) return z[:m] raise NotImplementedError('finding roots unsupported for ' 'non-cubic splines')
def sproot(tck,mest=10): """Find the roots of a cubic B-spline. Description: Given the knots (>=8) and coefficients of a cubic B-spline return the roots of the spline. Inputs: tck -- A length 3 sequence describing the given spline (See splev). The number of knots must be >= 8. The knots must be a montonically increasing sequence. mest -- An estimate of the number of zeros (Default is 10). Outputs: (zeros, ) zeros -- An array giving the roots of the spline. See also: splprep, splrep, splint, spalde, splev - evaluation, roots, integral bisplrep, bisplev - bivariate splines UnivariateSpline, BivariateSpline - an alternative wrapping of the FITPACK functions """ t,c,k=tck if k != 3: raise ValueError, "Sproot only valid for cubic bsplines" 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,t=t,k=k,mest=mest:sproot([t,c,k],mest),c) else: if len(t)<8: raise TypeError,"The number of knots be >=8" c = c.copy() c.resize(len(t)) z,m,ier=dfitpack.sproot(t,c,mest) if ier==10: raise TypeError,"Invalid input data. t1<=..<=t4<t5<..<tn-3<=..<=tn" \ "must hold." if ier==0: return z[0:m] if ier==1: print "Warning: the number of zeros exceeds mest" return z raise TypeError,"Unknown error"