Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCi #2537

Draft
wants to merge 25 commits into
base: development
Choose a base branch
from
Draft

CCi #2537

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 110 additions & 1 deletion M2/Macaulay2/d/actors.d

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions M2/Macaulay2/d/actors2.dd
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,12 @@ leftshiftfun(e:Expr):Expr := (
then toExpr(x.v << toLong(y.v))
else WrongArgSmallInteger(2))
else WrongArgZZ(2))
is x:CCicell do (
when a.1 is y:ZZcell do (
if isLong(y.v)
then toExpr(x.v << toLong(y.v))
else WrongArgSmallInteger(2))
else WrongArgZZ(2))
else WrongArg(1,"an integral, real, or complex number"))
else WrongNumArgs(2))
else WrongNumArgs(2));
Expand All @@ -593,6 +599,9 @@ installMethod(Expr(LessLessS),RRiClass,ZZClass,
installMethod(Expr(LessLessS),CCClass,ZZClass,
Expr(CompiledFunction(leftshiftfun,nextHash()))
);
installMethod(Expr(LessLessS),CCiClass,ZZClass,
Expr(CompiledFunction(leftshiftfun,nextHash()))
);

rightshiftfun(e:Expr):Expr := (
when e
Expand Down Expand Up @@ -623,6 +632,12 @@ rightshiftfun(e:Expr):Expr := (
then toExpr(x.v >> toLong(y.v))
else WrongArgSmallInteger(2))
else WrongArgZZ(2))
is x:CCicell do (
when a.1 is y:ZZcell do (
if isLong(y.v)
then toExpr(x.v >> toLong(y.v))
else WrongArgSmallInteger(2))
else WrongArgZZ(2))
else WrongArgZZ(1))
else WrongNumArgs(2))
else WrongNumArgs(2));
Expand All @@ -638,6 +653,9 @@ installMethod(Expr(GreaterGreaterS),RRiClass,ZZClass,
installMethod(Expr(GreaterGreaterS),CCClass,ZZClass,
Expr(CompiledFunction(rightshiftfun,nextHash()))
);
installMethod(Expr(GreaterGreaterS),CCiClass,ZZClass,
Expr(CompiledFunction(rightshiftfun,nextHash()))
);

unSingleton(e:Expr):Expr := (
when e
Expand Down Expand Up @@ -692,6 +710,7 @@ exponent(e:Expr):Expr := (
is x:RRcell do toExpr(exponent(x.v)) -- # typical value: size2, RR, ZZ
is x:RRicell do toExpr(exponent(x.v)) -- # typical value: size2, RRi, ZZ
is z:CCcell do toExpr(exponent(z.v)) -- # typical value: size2, CC, ZZ
is z:CCicell do toExpr(exponent(z.v)) -- # typical value: size2, CCi, ZZ
else WrongArg("a number"));
setupfun("size2",exponent);

Expand All @@ -701,6 +720,7 @@ realPart(e:Expr):Expr := (
is RRcell do e
is RRicell do e
is z:CCcell do toExpr(realPart(z.v))
is z:CCicell do toExpr(realPart(z.v))
is QQcell do e
else WrongArg("a number"));
setupfun("realPart0",realPart);
Expand All @@ -711,6 +731,7 @@ imaginaryPart(e:Expr):Expr := (
is RRcell do zeroE
is RRicell do zeroE
is z:CCcell do toExpr(imaginaryPart(z.v))
is z:CCicell do toExpr(imaginaryPart(z.v))
is QQcell do zeroE
else WrongArg("a number"));
setupfun("imaginaryPart0",imaginaryPart);
Expand Down
52 changes: 50 additions & 2 deletions M2/Macaulay2/d/actors3.d
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ EqualEqualfun(x:Expr,y:Expr):Expr := (
is yy:RRcell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, ZZ, RR, Boolean
is yy:RRicell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, ZZ, RRi, Boolean
is yy:CCcell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, ZZ, CC, Boolean
is yy:CCicell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, ZZ, CCi, Boolean
else equalmethod(x,y)
)
is xx:SymbolClosure do (
Expand All @@ -121,6 +122,7 @@ EqualEqualfun(x:Expr,y:Expr):Expr := (
is yy:RRcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, QQ, RR, Boolean
is yy:RRicell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, QQ, RRi, Boolean
is yy:CCcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, QQ, CC, Boolean
is yy:CCicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, QQ, CCi, Boolean
else equalmethod(x,y)
)
is xx:RRcell do (
Expand All @@ -130,20 +132,35 @@ EqualEqualfun(x:Expr,y:Expr):Expr := (
is yy:RRcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RR, RR, Boolean
is yy:RRicell do toExpr(yy.v === xx.v) -- # typical value: symbol ==, RR, RRi, Boolean
is yy:CCcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RR, CC, Boolean
is yy:CCicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RR, CCi, Boolean
else equalmethod(x,y)
)
is xx:RRicell do (
when y is yy:RRicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, RRi, Boolean
is yy:ZZcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, ZZ, Boolean
is yy:QQcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, QQ, Boolean
is yy:RRcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, RR, Boolean
else buildErrorPacket(EngineError("equality not implemented")))
is yy:CCcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, CC, Boolean
is yy:CCicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, RRi, CCi, Boolean
else equalmethod(x,y))
is xx:CCcell do (
when y
is yy:ZZcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, ZZ, Boolean
is yy:QQcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, QQ, Boolean
is yy:RRcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, RR, Boolean
is yy:RRicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, RRi, Boolean
is yy:CCcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, CC, Boolean
is yy:CCicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CC, CCi, Boolean
else equalmethod(x,y)
)
is xx:CCicell do (
when y
is yy:ZZcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, ZZ, Boolean
is yy:QQcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, QQ, Boolean
is yy:RRcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, RR, Boolean
is yy:RRicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, RRi, Boolean
is yy:CCcell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, CC, Boolean
is yy:CCicell do toExpr(xx.v === yy.v) -- # typical value: symbol ==, CCi, CCi, Boolean
else equalmethod(x,y)
)
is xx:Boolean do (
Expand Down Expand Up @@ -242,6 +259,11 @@ compare(left:Expr,right:Expr):Expr := (
if flagged() then incomparableE else
if r < 0 then LessE else if r > 0 then GreaterE else EqualEqualE
)
is y:CCicell do (
r := compare(x.v,y.v);
if flagged() then incomparableE else
if r < 0 then LessE else if r > 0 then GreaterE else EqualEqualE
)
is Error do right
else binarycomparison(left,right))
is x:stringCell do (
Expand Down Expand Up @@ -302,6 +324,11 @@ compare(left:Expr,right:Expr):Expr := (
if flagged() then incomparableE else
if r < 0 then LessE else if r > 0 then GreaterE else EqualEqualE
)
is y:CCicell do (
r := compare(x.v,y.v);
if flagged() then incomparableE else
if r < 0 then LessE else if r > 0 then GreaterE else EqualEqualE
)
is Error do right
else binarycomparison(left,right))
is x:RRcell do (
Expand Down Expand Up @@ -989,6 +1016,7 @@ exp(e:Expr):Expr := (
is x:CCcell do toExpr(exp(x.v)) -- # typical value: exp, CC, CC
is x:RRcell do toExpr(exp(x.v)) -- # typical value: exp, RR, RR
is x:RRicell do toExpr(exp(x.v)) -- # typical value: exp, RRi, RRi
is x:CCicell do toExpr(exp(x.v)) -- # typical value: exp, CCi, CCi
else buildErrorPacket("expected a number")
);
setupfun("exp",exp).Protected=false;
Expand Down Expand Up @@ -1027,6 +1055,7 @@ log(e:Expr):Expr := (
is x:RRcell do if isNegative(x.v) then toExpr(logc(x.v)) else toExpr(log(x.v)) -- # typical value: log, RR, RR
is x:RRicell do if x.v >= 0 then toExpr(log(x.v)) -- # typical value: log, RRi, RRi
else buildErrorPacket("Not defined")
is x:CCicell do toExpr(log(x.v)) -- # typical value: log, CCi, CCi
else WrongArg("a number or a pair of numbers")
);
setupfun("log",log).Protected=false;
Expand Down Expand Up @@ -1067,6 +1096,11 @@ floor(e:Expr):Expr := (
if isinf(x.v) then buildErrorPacket("encountered infinite real number in conversion to integer") else
toExpr(floor(x.v.re))
)
is x:CCicell do (
if isnan(x.v) then buildErrorPacket("encountered NotANumber in conversion to integer") else
if isinf(x.v) then buildErrorPacket("encountered infinite real number in conversion to integer") else
toExpr(floor(x.v.re))
)
is x:QQcell do toExpr(floor(x.v))
is ZZcell do e
else buildErrorPacket("expected an integral, rational, or real number")
Expand All @@ -1087,10 +1121,16 @@ round0(e:Expr):Expr := (
if isnan(x.v) then buildErrorPacket("encountered NotANumber in conversion to integer") else
if isinf(x.v) then buildErrorPacket("encountered infinite real number in conversion to integer") else
toExpr(round(x.v)))
is x:CCicell do (
if isnan(x.v) then buildErrorPacket("encountered NotANumber in conversion to integer") else
if isinf(x.v) then buildErrorPacket("encountered infinite real number in conversion to integer") else
toExpr(round(x.v.re)))
else buildErrorPacket("expected a real number")
);
setupfun("round0",round0);



run(e:Expr):Expr := (
when e
is x:stringCell do toExpr(run(x.v))
Expand All @@ -1109,10 +1149,18 @@ sqrt(a:Expr):Expr := (
)
is x:RRicell do (
if leftRR(x.v) >= 0
then toExpr(sqrt(x.v)) -- # typical value: sqrt, RRi, RRi
then toExpr(sqrt(x.v)) -- # typical value: sqrt, RRi, RRi
else if rightRR(x.v) <= 0
then toExpr(negSqrt(x.v))
else buildErrorPacket("Not implemented")
)
is x:CCcell do toExpr(sqrt(x.v)) -- # typical value: sqrt, CC, CC
is x:CCicell do (
if leftRR(x.v.re) >= 0 || rightRR(x.v.re) <= 0 || leftRR(x.v.im) >= 0 || rightRR(x.v.im) <= 0
then if leftRR(x.v.re) <= rightRR(x.v.re) && leftRR(x.v.im) <= rightRR(x.v.im) then toExpr(sqrt(x.v)) -- # typical value: sqrt, CCi, CCi
else buildErrorPacket("Not implemented")
else buildErrorPacket("Not implemented")
)
is Error do a
else WrongArgRR());
setupfun("sqrt",sqrt).Protected=false;
Expand Down
Loading