ComplexJaM.mesa
Written by Michael Plass, 29-Sep-81
Last edit by Michael Plass, December 2, 1982 11:03 am
Last edit by Maureen Stone February 8, 1984 6:24:54 pm PST (Cedar5.1 and new JaM)
Makes complex functions visible to JaM
DIRECTORY
Complex,
Rope,
JaM USING [PushReal, PopReal, Register, State, RegisterInit];
ComplexJaM: CEDAR PROGRAM IMPORTS Complex, JaM =
BEGIN OPEN JaM;
PushVec: PROC[s: State, v:Complex.Vec] =
BEGIN
PushReal[s,v.x];
PushReal[s,v.y];
END;
PopVec: PROC[s: State] RETURNS [Complex.Vec] =
BEGIN
y:REAL ← PopReal[s];
x:REAL ← PopReal[s];
RETURN[[x,y]];
END;
CAdd: PROC[s: State] = {b:Complex.Vec ← PopVec[s]; PushVec[s,Complex.Add[PopVec[s],b]]};
CSub: PROC[s: State] = {b:Complex.Vec ← PopVec[s]; PushVec[s,Complex.Sub[PopVec[s],b]]};
CMul: PROC[s: State] = {b:Complex.Vec ← PopVec[s]; PushVec[s,Complex.Mul[PopVec[s],b]]};
CDiv: PROC[s: State] = {b:Complex.Vec ← PopVec[s]; PushVec[s,Complex.Div[PopVec[s],b]]};
CFromPolar:
PROC[s: State] = {b:REAL ← PopReal[s]; PushVec[s,Complex.FromPolar[PopReal[s],b]]};
CAbs: PROC[s: State] = {PushReal[s,Complex.Abs[PopVec[s]]]};
CSqrAbs: PROC[s: State] = {PushReal[s,Complex.SqrAbs[PopVec[s]]]};
CArg: PROC[s: State] = {PushReal[s,Complex.Arg[PopVec[s]]]};
CExp: PROC[s: State] = {PushVec[s,Complex.Exp[PopVec[s]]]};
CLn: PROC[s: State] = {PushVec[s,Complex.Ln[PopVec[s]]]};
CSqr: PROC[s: State] = {PushVec[s,Complex.Sqr[PopVec[s]]]};
CSqRt: PROC[s: State] = {PushVec[s,Complex.SqRt[PopVec[s]]]};
Init: PROC[state: State] = {
Register[state,"Complex.Add",CAdd];
Register[state,"Complex.Sub",CSub];
Register[state,"Complex.Mul",CMul];
Register[state,"Complex.Div",CDiv];
Register[state,"Complex.FromPolar",CFromPolar];
Register[state,"Complex.Abs",CAbs];
Register[state,"Complex.SqrAbs",CSqrAbs];
Register[state,"Complex.Arg",CArg];
Register[state,"Complex.Exp",CExp];
Register[state,"Complex.Ln",CLn];
Register[state,"Complex.Sqr",CSqr];
Register[state,"Complex.Sqrt",CSqRt];
};
RegisterInit["ComplexJaM",Init];
END.