Question: Make me run faster `if` you can

Dear all

Can anyone suggest how the following code could run faster?

add(`if`(signum(eval(vs||i,{vBv=coord[1],vBu=coord[2],sr||i=ang||i}))=1,2^(i-1),0)
      +`if`(signum(eval(vt||i,{vBv=coord[1],vBu=coord[2],sr||i=ang||i}))=1,2^(i+3),0),i=1..4):
 
vs||i and vt||i evaluate to floats.

and

 
coord:=coordinates(centroid(G,[
                point(A,op(1,triples[n])[3],op(1,triples[n])[4])
               ,point(B,op(2,triples[n])[3],op(2,triples[n])[4])
               ,point(C,op(3,triples[n])[3],op(3,triples[n])[4])])):



Triples have the form 
[[9, 11, -.195, -.153], [3, 6, -.896e-1, -.400], [3, 11, -.308, -.400]]
 

I also attach a cut-down version of the code (Maple10, Classic) which shows the context for the above: in the actual code there will be +10^6 of calls to the code.

http://www.mapleprimes.com/2129_Make%20me%20run%20faster.mws

Any suggestions would be most appreciated.

 

Please Wait...