Author Topic: POW speed  (Read 2423 times)

Qedo

• Mr. Polyvector
• Posts: 164
• UNUS SED LEO
POW speed
« on: 2011-Sep-17 »
Don't use POW function  for value of power less or ugual to 40. It is very slow
Try this code
Ciao

• Guest
Re: POW speed
« Reply #1 on: 2011-Sep-17 »
My timings (on the PC) are including.  Wonder why its 10 times slower ?

« Last Edit: 2011-Sep-17 by MrTAToad »

Moebius

• Dr. Type
• Posts: 315
Re: POW speed
« Reply #2 on: 2011-Sep-18 »
POW allows exponents that aren't positive integers, hence requiring more complicated code than multiplying the base out a few times
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Qedo

• Mr. Polyvector
• Posts: 164
• UNUS SED LEO
Re: POW speed
« Reply #3 on: 2011-Sep-18 »
Right
Try this for negative elevations (not too complicated) .   Is always faster
Obviously this program does not work for elevations greater than 0 and less than 1
Ciao

Qedo

• Mr. Polyvector
• Posts: 164
• UNUS SED LEO
Re: POW speed
« Reply #4 on: 2011-Sep-18 »
I forgot to add that the elevations should not be decimal.
3, 5, 6, -4, -6 yes
-3,5, 5.67   no
Ciao

Moebius

• Dr. Type
• Posts: 315
Re: POW speed
« Reply #5 on: 2011-Sep-18 »
Which is exactly where POW differs from this integer exponent functions
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Qedo

• Mr. Polyvector
• Posts: 164
• UNUS SED LEO
Re: POW speed
« Reply #6 on: 2011-Sep-18 »
But where it is very useful in calculations of the type Bezier algorithm:
B(t)=(1-t)5P1 + 5t(1-t)4P2 + 10t2(1-t)3P3 + 10t3(1-t)2P4 + 5t4(1-t)P5+ t5P6
Ciao

• code monkey