Opened 19 years ago

Last modified 14 years ago

#8 closed defect (fixed)

Rekursiv funktion gcd() med if-uttryck

Reported by: levsa Owned by: levsa
Priority: critical Milestone:
Component: Version:
Keywords: Cc: levsa, adrpo

Description

No description

Change History (4)

comment:1 Changed 19 years ago by levsa

OpenModelica bugg: Rekursiv funktion gcd() med if-uttryck verkar inte fungera.
Parsningen verkar inte ha avslutats eftersom det inte kommer något Ok.
Däremot kommer ju en ny prompt. (Kanske skulle varit parse error?)

function gcd input Integer u; input Integer v; output Integer res;

algorithm res := if v==0 then u else gcd(v,mod(u,v));

end gcd;

gcd(2,2)

Error evaluating expr.
# Error, type gcd not found.
# Couldn't find function gcd
# Error, type gcd not found.
# Couldn't find function gcd
# Error, type gcd not found.
# Couldn't find function gcd

Däremot fungerar en annan liknande funktion bra:

function foo input Integer u; input Integer v; output Integer res;
algorithm res := u+v; end foo;

Ok

foo(2,2)

4

algorithm res := u+v; end foo;
Ok

foo(2,2)

4

comment:2 Changed 18 years ago by petar

This is most probably because the amount of result data is pre-allocated without
considering the extra amount of data produced for events. To fix this we need to
change the pre-allocation to instead write to file during simulation, or to use
a dynamically sized memory block for storing data. If writing to file during
simulation is chosen this also requires a different storage format, since
current format requires whole time vector before begin saved.

This lies outside my interests, perhaps Håkan is intrested in this?

comment:3 Changed 18 years ago by petar

Sorry, made comment in wrong bug. Please skip comment above.

comment:4 Changed 14 years ago by perost

This seems to work now.

Note: See TracTickets for help on using tickets.