Opened 14 years ago
Last modified 14 years ago
#1518 closed defect (fixed)
Implement faster pow() math for integer exponents
Reported by: | Martin Sjölund | Owned by: | Martin Sjölund |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Martin Sjölund, |
Description
r*r2*r3 is roughly 4 times faster than using pow() because we only have access to pow(double,double). Use for example something from http://en.wikipedia.org/wiki/Exponentiation_by_squaring
And implement a check for xn (n is a literal that is actually an integer)
model M function f input Real r; output Real o; protected Real r2 := r,r3 := r; algorithm for i in 1:100000 loop //o := r*r2*r3; o := r^3; //o := sqrt(r); end for; o := 42.0; end f; parameter Real x(fixed=false); initial equation x = f(time+10); end M;
Note:
See TracTickets
for help on using tickets.