def _bspline_piecefunctions(order):
try:<EOL><INDENT>return _splinefunc_cache[order]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>def condfuncgen(num, val1, val2):<EOL><INDENT>if num == <NUM_LIT:0>:<EOL><INDENT>return lambda x: logical_and(less_equal(x, val1),<EOL>greater_equal(x, val2))<EOL><DEDENT>elif num == <NUM_LIT:2>:<EOL><INDENT>return lambda x: less_equal(x, val2)<EOL><DEDENT>else:<EOL><INDENT>return lambda x: logical_and(less(x, val1),<EOL>greater_equal(x, val2))<EOL><DEDENT><DEDENT>last = order // <NUM_LIT:2> + <NUM_LIT:2><EOL>if order % <NUM_LIT:2>:<EOL><INDENT>startbound = -<NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>startbound = -<NUM_LIT:0.5><EOL><DEDENT>condfuncs = [condfuncgen(<NUM_LIT:0>, <NUM_LIT:0>, startbound)]<EOL>bound = startbound<EOL>for num in xrange(<NUM_LIT:1>, last - <NUM_LIT:1>):<EOL><INDENT>condfuncs.append(condfuncgen(<NUM_LIT:1>, bound, bound - <NUM_LIT:1>))<EOL>bound = bound - <NUM_LIT:1><EOL><DEDENT>condfuncs.append(condfuncgen(<NUM_LIT:2>, <NUM_LIT:0>, -(order + <NUM_LIT:1>) / <NUM_LIT>))<EOL>fval = factorial(order)<EOL>def piecefuncgen(num):<EOL><INDENT>Mk = order // <NUM_LIT:2> - num<EOL>if (Mk < <NUM_LIT:0>):<EOL><INDENT>return <NUM_LIT:0>  <EOL><DEDENT>coeffs = [(<NUM_LIT:1> - <NUM_LIT:2> * (k % <NUM_LIT:2>)) * float(comb(order + <NUM_LIT:1>, k, exact=<NUM_LIT:1>)) / fval<EOL>for k in xrange(Mk + <NUM_LIT:1>)]<EOL>shifts = [-bound - k for k in xrange(Mk + <NUM_LIT:1>)]<EOL>def thefunc(x):<EOL><INDENT>res = <NUM_LIT:0.0><EOL>for k in range(Mk + <NUM_LIT:1>):<EOL><INDENT>res += coeffs[k] * (x + shifts[k]) ** order<EOL><DEDENT>return res<EOL><DEDENT>return thefunc<EOL><DEDENT>funclist = [piecefuncgen(k) for k in xrange(last)]<EOL>_splinefunc_cache[order] = (funclist, condfuncs)<EOL>return funclist, condfuncs<EOL>
Returns the function defined over the left-side pieces for a bspline of
    a given order.

    The 0th piece is the first one less than 0.  The last piece is a function
    identical to 0 (returned as the constant 0).  (There are order//2 + 2 total
    pieces).

    Also returns the condition functions that when evaluated return boolean
    arrays for use with `numpy.piecewise`.