  function y = Bstar(z)
% z is a column m-vector and y is a column m-vector with the property that
% y(k) = B_{*}(x(k)), k=1:m
m = length(z);
y = zeros(m,1);
for k=1:m
    t = z(k);
    if -2<=t && t<=-1
        y(k) = (2+t)^3/6;
    elseif  -1<=t && t<=0
        y(k) = (-3*(1+t)^3 + 3*(1+t)^2 + 3*(1+t) + 1)/6;
    elseif 0<=t && t<=1
        y(k) = (-3*(1-t)^3 + 3*(1-t)^2 + 3*(1-t) + 1)/6;
    elseif 1<=t  && t<=2
        y(k) = (2-t)^3/6;
    end
end
% This can be made much more efficient by using the Matlab function
% find and vectorizing.