Skip to content

Commit e58ebd3

Browse files
jodaviestueda
authored andcommitted
Change EndSort type for transform statements
Since the transform statements are sorting into the workspace, and might have to merge patches, make them use a par=1 EndSort. This commit makes this change for all transform statements, though only mularg is going to produce an explosion of terms here. This fixes #230 and causes #183 to crash with a useful error (Term too complex during normalization).
1 parent 0112aa6 commit e58ebd3

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

check/fixes.frm

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,22 @@ P;
16941694
.end
16951695
assert succeeded?
16961696
assert result("F") =~ expr("rat(1,ep^2 + 2*ep + 1)")
1697-
*--#] Issue180 :
1697+
*--#] Issue180 :
1698+
*--#[ Issue183 :
1699+
#: MaxTermSize 16K
1700+
#: SubTermsInSmall 800
1701+
1702+
CF f;
1703+
Auto S x;
1704+
L F = f(<x1+x2+x3+x4>,...,<x6+x7+x8+x9>);
1705+
*repeat id f(x1?,x2?,?a) = f(x1*x2,?a); * error: Sorted function argument...
1706+
transform f,mulargs(1,last); * silent crash
1707+
P;
1708+
.end
1709+
# Runtime errors may freeze ParFORM.
1710+
#pend_if mpi?
1711+
assert runtime_error?("Term too complex during normalization")
1712+
*--#] Issue183 :
16981713
*--#[ Issue185 :
16991714
* Wrong result of content_
17001715
@@ -2002,6 +2017,29 @@ Symbol x;
20022017
.end
20032018
assert succeeded?
20042019
*--#] Issue222 :
2020+
*--#[ Issue230 :
2021+
#-
2022+
#: MaxTermSize 16K
2023+
#: SubTermsInSmall 800
2024+
2025+
2026+
Off Statistics;
2027+
2028+
Symbol x1,...,x11;
2029+
CFunction f;
2030+
2031+
Local test = f(x1+...+x11) - (x1+...+x11)^4;
2032+
Identify f(x1?) = f(x1,x1,x1,x1);
2033+
.sort
2034+
2035+
Transform f mulargs(1,last);
2036+
Identify f(x1?) = x1;
2037+
2038+
Print +s;
2039+
.end
2040+
assert succeeded?
2041+
assert result("test") =~ expr("0")
2042+
*--#] Issue230 :
20052043
*--#[ Issue231 :
20062044
Symbol x,y,z;
20072045
Local F = x + y + x*z;

sources/transform.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ returnvalues:;
840840
return(-1);
841841
}
842842
newterm = AT.WorkPointer;
843-
if ( EndSort(BHEAD newterm,0) < 0 ) {}
843+
if ( EndSort(BHEAD newterm,1) < 0 ) {}
844844
if ( ( *newterm && *(newterm+*newterm) != 0 ) || *newterm == 0 ) {
845845
MLOCK(ErrorMessageLock);
846846
MesPrint("&yes/no information in islyndon/tolyndon does not evaluate into a single term");
@@ -1379,7 +1379,7 @@ WORD RunReplace(PHEAD WORD *fun, WORD *args, WORD *info)
13791379
return(-1);
13801380
}
13811381
newterm = AT.WorkPointer;
1382-
if ( EndSort(BHEAD newterm,0) < 0 ) {}
1382+
if ( EndSort(BHEAD newterm,1) < 0 ) {}
13831383
if ( ( *newterm && *(newterm+*newterm) != 0 ) || *newterm == 0 ) {
13841384
MLOCK(ErrorMessageLock);
13851385
MesPrint("&information in replace transformation does not evaluate into a single term");
@@ -1641,7 +1641,7 @@ getthisone:;
16411641
return(-1);
16421642
}
16431643
term4 = AT.WorkPointer;
1644-
if ( EndSort(BHEAD term4,0) < 0 ) {}
1644+
if ( EndSort(BHEAD term4,1) < 0 ) {}
16451645
if ( ( *term4 && *(term4+*term4) != 0 ) || *term4 == 0 ) {
16461646
MLOCK(ErrorMessageLock);
16471647
MesPrint("&information in replace transformation does not evaluate into a single term");
@@ -1768,7 +1768,7 @@ dothisnow:;
17681768
return(-1);
17691769
}
17701770
term4 = AT.WorkPointer;
1771-
if ( EndSort(BHEAD term4,0) < 0 ) {}
1771+
if ( EndSort(BHEAD term4,1) < 0 ) {}
17721772
if ( ( *term4 && *(term4+*term4) != 0 ) || *term4 == 0 ) {
17731773
MLOCK(ErrorMessageLock);
17741774
MesPrint("&information in replace transformation does not evaluate into a single term");
@@ -2737,7 +2737,7 @@ WORD RunAddArg(PHEAD WORD *fun, WORD *args)
27372737
}
27382738
n++;
27392739
}
2740-
if ( EndSort(BHEAD tstop+ARGHEAD,0) ) return(-1);
2740+
if ( EndSort(BHEAD tstop+ARGHEAD,1) ) return(-1);
27412741
num = 0;
27422742
f2 = tstop+ARGHEAD;
27432743
while ( *f2 ) { f2 += *f2; num++; }
@@ -2883,7 +2883,7 @@ WORD RunMulArg(PHEAD WORD *fun, WORD *args)
28832883
NewSort(BHEAD0);
28842884
Generator(BHEAD scratch,AR.Cnumlhs);
28852885
newterm = AT.WorkPointer;
2886-
EndSort(BHEAD newterm+ARGHEAD,0);
2886+
EndSort(BHEAD newterm+ARGHEAD,1);
28872887
C->Pointer = C->Buffer+oldcpointer_pos;
28882888
C->numrhs = nb;
28892889
w = newterm+ARGHEAD; while ( *w ) w += *w;

0 commit comments

Comments
 (0)