Opened 20 years ago

Last modified 15 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, Adrian Pop

Description

No description

Change History (4)

comment:1 by levsa, 20 years ago

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 by Peter Aronsson, 18 years ago

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 by Peter Aronsson, 18 years ago

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

comment:4 by Per Östlund, 15 years ago

This seems to work now.

Note: See TracTickets for help on using tickets.