def B_012(x):
 x = np.atleast_1d(x)
 return np.piecewise(x, [((x < 0) | (x > 2)), ((x >= 0) & (x < 1)), ((x >= 1) & (x <= 2))], [(lambda x: 0.0), (lambda x: x), (lambda x: (2.0 - x))])

def B_012 ( x ) : x = np . atleast_1d ( x ) return np . piecewise ( x , [ ( ( x < 0 ) | ( x > 2 ) ) , ( ( x >= 0 ) & ( x < 1 ) ) , ( ( x >= 1 ) & ( x <= 2 ) ) ] , [ ( lambda x : 0.0 ) , ( lambda x : x ) , ( lambda x : ( 2.0 - x ) ) ] )
a linear b-spline function b .