def sproot(tck,mest=10): """ Find the roots of a cubic B-spline. Given the knots (>=8) and coefficients of a cubic B-spline return the roots of the spline. Parameters ---------- tck : tuple A tuple (t,c,k) containing the vector of knots, the B-spline coefficients, and the degree of the spline. The number of knots must be >= 8. The knots must be a montonically increasing sequence. mest : int An estimate of the number of zeros (Default is 10). Returns ------- zeros : ndarray An array giving the roots of the spline. See also -------- splprep, splrep, splint, spalde, splev bisplrep, bisplev UnivariateSpline, BivariateSpline References ---------- .. [1] C. de Boor, "On calculating with b-splines", J. Approximation Theory, 6, p.50-62, 1972. .. [2] M.G. Cox, "The numerical evaluation of b-splines", J. Inst. Maths Applics, 10, p.134-149, 1972. .. [3] P. Dierckx, "Curve and surface fitting with splines", Monographs on Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck if k==4: t=t[1:-1] if k==5: t=t[2:-2] try: c[0][0] parametric = True except: parametric = False if parametric: return _ntlist(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 %d>=8"%(len(t)) z,ier=_fitpack._sproot(t,c,k,mest) if ier==10: raise TypeError,"Invalid input data. t1<=..<=t4<t5<..<tn-3<=..<=tn must hold." if ier==0: return z if ier==1: print "Warning: the number of zeros exceeds mest" return z raise TypeError,"Unknown error"
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 == 4: t = t[1:-1] if k == 5: t = t[2:-2] try: c[0][0] parametric = True except: parametric = False if parametric: return _ntlist( 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 %d>=8" % (len(t)) z, ier = _fitpack._sproot(t, c, k, mest) if ier == 10: raise TypeError, "Invalid input data. t1<=..<=t4<t5<..<tn-3<=..<=tn must hold." if ier == 0: return z if ier == 1: print "Warning: the number of zeros exceeds mest" return z raise TypeError, "Unknown error"
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==4: t=t[1:-1] if k==5: t=t[2:-2] try: c[0][0] parametric = True except: parametric = False if parametric: return _ntlist(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 %d>=8"%(len(t)) z,ier=_fitpack._sproot(t,c,k,mest) if ier==10: raise TypeError,"Invalid input data. t1<=..<=t4<t5<..<tn-3<=..<=tn must hold." if ier==0: return z if ier==1: print "Warning: the number of zeros exceeds mest" return z raise TypeError,"Unknown error"
def sproot(tck,mest=10): """ Find the roots of a cubic B-spline. Given the knots (>=8) and coefficients of a cubic B-spline return the roots of the spline. Parameters ---------- 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) Returns ------- 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. References ---------- .. [1] C. de Boor, "On calculating with b-splines", J. Approximation Theory, 6, p.50-62, 1972. .. [2] M.G. Cox, "The numerical evaluation of b-splines", J. Inst. Maths Applics, 10, p.134-149, 1972. .. [3] P. Dierckx, "Curve and surface fitting with splines", Monographs on Numerical Analysis, Oxford University Press, 1993. """ t,c,k=tck if k==4: t=t[1:-1] if k==5: t=t[2:-2] try: c[0][0] parametric = True except: parametric = False if parametric: return _ntlist(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 %d>=8"%(len(t)) z,ier=_fitpack._sproot(t,c,k,mest) if ier==10: raise TypeError,"Invalid input data. t1<=..<=t4<t5<..<tn-3<=..<=tn must hold." if ier==0: return z if ier==1: print "Warning: the number of zeros exceeds mest" return z raise TypeError,"Unknown error"