def B_0123(x, der=0):
 x = np.atleast_1d(x)
 conds = [(x < 1), ((x > 1) & (x < 2)), (x > 2)]
 if (der == 0):
  funcs = [(lambda x: ((x * x) / 2.0)), (lambda x: ((3.0 / 4) - ((x - (3.0 / 2)) ** 2))), (lambda x: (((3.0 - x) ** 2) / 2))]
 elif (der == 2):
  funcs = [(lambda x: 1.0), (lambda x: (-2.0)), (lambda x: 1.0)]
 else:
  raise ValueError(('never be here: der=%s' % der))
 pieces = np.piecewise(x, conds, funcs)
 return pieces

def B_0123 ( x , der = 0 ) : x = np . atleast_1d ( x ) conds = [ ( x < 1 ) , ( ( x > 1 ) & ( x < 2 ) ) , ( x > 2 ) ] if ( der == 0 ) : funcs = [ ( lambda x : ( ( x * x ) / 2.0 ) ) , ( lambda x : ( ( 3.0 / 4 ) - ( ( x - ( 3.0 / 2 ) ) ** 2 ) ) ) , ( lambda x : ( ( ( 3.0 - x ) ** 2 ) / 2 ) ) ] elif ( der == 2 ) : funcs = [ ( lambda x : 1.0 ) , ( lambda x : ( - 2.0 ) ) , ( lambda x : 1.0 ) ] else : raise ValueError ( ( 'never be here: der=%s' % der ) ) pieces = np . piecewise ( x , conds , funcs ) return pieces
a quadratic b-spline function b .