maude-help AT lists.siebelschool.illinois.edu
Subject: Maude-help mailing list
List archive
- From: Vlad Avram <vladz.avram AT gmail.com>
- To: maude-help AT cs.uiuc.edu
- Subject: [Maude-help] Help with Maude crashing
- Date: Thu, 23 May 2013 22:25:04 +0300
- List-archive: <http://lists.cs.uiuc.edu/pipermail/maude-help/>
- List-id: <maude-help.cs.uiuc.edu>
Hi,
I'm trying to implement a module for complex numbers in Maude and here's what I got for now:
fmod COMPLEX is
protecting FLOAT .
sort Complex .
op complex : Float Float -> Complex .
op realpart : Complex -> Float .
op imagpart : Complex -> Float .
op _+_ : Complex Complex -> Complex [assoc comm] .
op _-_ : Complex Complex -> Complex .
op _*_ : Complex Complex -> Complex .
op _/_ : Complex Complex -> Complex .
vars X Y : Complex .
vars R1 R2 : Float .
eq realpart(complex(R1,R2)) = R1 .
eq realpart(X + Y) = realpart(X) + realpart(Y) .
eq realpart(X - Y) = realpart(X) - realpart(Y) .
eq realpart(X * Y) = realpart(X) * realpart(Y) - imagpart(X) * imagpart(Y) .
ceq realpart(X / Y) = (realpart(X) * realpart(Y) + imagpart(X) * imagpart(Y)) / (realpart(Y) ^ 2.0 + imagpart(Y) ^ 2.0) if realpart(Y) =/= 0.0 and imagpart(Y) =/= 0.0 .
eq imagpart(complex(R1,R2)) = R2 .
eq imagpart(X + Y) = imagpart(X) + imagpart(Y) .
eq imagpart(X - Y) = imagpart(X) - imagpart(Y) .
eq imagpart(X * Y) = imagpart(X) * realpart(Y) + realpart(X) * imagpart(Y) .
ceq imagpart(X / Y) = (imagpart(X) * realpart(Y) - realpart(X) * imagpart(Y)) / (realpart(Y) ^ 2.0 + imagpart(Y) ^ 2.0) if realpart(Y) =/= 0.0 and imagpart(Y) =/= 0.0 .
eq X + Y = complex(realpart(X + Y),imagpart(X + Y)) .
eq X - Y = complex(realpart(X - Y),imagpart(X - Y)) .
eq X * Y = complex(realpart(X * Y),imagpart(X * Y)) .
eq X / Y = complex(realpart(X / Y),imagpart(X / Y)) .
endfm
The parsing works but when I try something like "red complex(2.0,1.0) + complex(3.0,1.0)", Maude crashes. Can I please get an answer of what I'm doing wrong?
Thanks!
- [Maude-help] Help with Maude crashing, Vlad Avram, 05/23/2013
- Re: [Maude-help] Help with Maude crashing, Steven Eker, 05/30/2013
Archive powered by MHonArc 2.6.16.