I am trying to rewrite some C code from another author into Igor Pro (similarish notation to C). The code is available here.
I don't know how to deal with the lines if ((umin+=input[k+1]-vmin)<minlambda)
and else if ((umax+=input[k+1]-vmax)>lambda)
with regards to the order of how they go about updating umin
and umax
, and how the if/elseif statements evaluating to true or false affect the update..
Specifically:
On lines 99-107 there is:
if ((umin+=input[k+1]-vmin)<minlambda) {
do output[k0++]=vmin; while (k0<=kminus);
vmax=(vmin=input[kplus=kminus=k=k0])+twolambda;
umin=lambda; umax=minlambda;
} else if ((umax+=input[k+1]-vmax)>lambda) {
do output[k0++]=vmax; while (k0<=kplus);
vmin=(vmax=input[kplus=kminus=k=k0])-twolambda;
umin=lambda; umax=minlambda;
} else { /*blah blah */ }
I have refactored this to read:
if ((umin+=input[k+1]-vmin) < minlambda) //Todo
do
output[k0] = vmin
k0+=1
while(k0 <= kminus)
k=k0
kminus=k
kplus=kminus
vmin=input[kplus]
vmax = (vmin) + twolambda
umin = lambda
umax = minlambda
elseif ((umax+=input[k+1]-vmax) > lambda) //Todo
do
output[k0]=vmax
k0+=1
while(k0 <= kplus)
k=k0
kminus=k
kplus=kminus
vmax=input[kplus]
vmin = (vmax) - twolambda
umin = lambda
umax = minlambda
else //blah blah
Do umin and umax only get updated if their if statements evaluate to true? Or does it cascade? IF(umin) -> false, umin updated, ELSEIF(umax) -> true, umax updated, but IF(umin) -> true, umin updated, umax not updated? Or some other variant?
Another question about the same code.
Edit: fixed title. Added igor tag