In reply to Anders Sköllermo.

There are definitely aspects here that are counterintuitive. The solution

negSum = sum(choose(z0,z,0));

runs in about two-thirds of the time that the two line solution based around the loc function takes, yet sum(choose(z<0,z,0)) must perform around twice as many additions as sum(z[loc(z<0)]). So additions at least can not be expensive. Any comments Rick?