13 lines
650 B
Matlab
13 lines
650 B
Matlab
% cursed
|
|
% basically - I take pairs of adjacent values on the vector `x` and add them
|
|
% together. These sums are then checked against both members of the pair,
|
|
% and if either member is *larger* than the sum, that indicates a sign change
|
|
% since one of the values acted as a subtractor.
|
|
% "Glue" is added in the comparison stage, to skew ONLY on cases where
|
|
% we are comparing zero to zero (origin case). Its really a rounding error otherwise. lol
|
|
% The front is padded w/ a zero.
|
|
function ret = switchsign(x)
|
|
sum_check = x(1:end-1) + x(2:end);
|
|
ret = [0, ( abs(sum_check) < abs(x(1:end-1)+1e-7) ) | ( abs(sum_check) < abs(x(2:end)+1e-7) ) ];
|
|
end
|