Opened 13 years ago

Last modified 13 years ago

#1518 closed defect (fixed)

Implement faster pow() math for integer exponents

Reported by: sjoelund.se Owned by: sjoelund.se
Priority: high Milestone:
Component: Version:
Keywords: Cc: sjoelund.se,

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;

Change History (0)

Note: See TracTickets for help on using tickets.