From 90761d6725bf1c9fb2cd0f68081e5b3d97dcaa45 Mon Sep 17 00:00:00 2001 From: vermaseren Date: Tue, 30 Jun 2015 20:10:09 +0200 Subject: [PATCH] Made flag for negative powers in SymbolNormalize --- sources/normal.c | 18 ++++++++++-------- sources/ratio.c | 6 ++++-- sources/startup.c | 1 + sources/structs.h | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/sources/normal.c b/sources/normal.c index d63386a4..56abdfdd 100644 --- a/sources/normal.c +++ b/sources/normal.c @@ -5101,15 +5101,17 @@ Nexti:; /* Veto negative powers */ - b = buffer; bb = b + b[1]; b += 3; - while ( b < bb ) { - if ( *b < 0 ) { - MLOCK(ErrorMessageLock); - MesPrint("Negative power in SymbolNormalize"); - MUNLOCK(ErrorMessageLock); - return(-1); + if ( AT.LeaveNegative == 0 ) { + b = buffer; bb = b + b[1]; b += 3; + while ( b < bb ) { + if ( *b < 0 ) { + MLOCK(ErrorMessageLock); + MesPrint("Negative power in SymbolNormalize"); + MUNLOCK(ErrorMessageLock); + return(-1); + } + b += 2; } - b += 2; } /* Now we use the fact that the new term will not be longer than the old one diff --git a/sources/ratio.c b/sources/ratio.c index c5993844..35edcb55 100644 --- a/sources/ratio.c +++ b/sources/ratio.c @@ -1326,7 +1326,7 @@ WORD *MultiplyWithTerm(PHEAD WORD *in, WORD *term, WORD par) } /* - #] MultiplyWithTerm : + #] MultiplyWithTerm : #[ TakeContent : */ /** @@ -2982,7 +2982,9 @@ NormArg:; /* We can use MultiplyWithTerm. */ + AT.LeaveNegative = 1; numerator = MultiplyWithTerm(BHEAD arg1+ARGHEAD,rmininv,0); + AT.LeaveNegative = 0; r[-1] = rcopy; r = numerator; while ( *r ) r += *r; AT.WorkPointer = r+1; @@ -3106,7 +3108,7 @@ NormArg:; } /* - #] ExpandRat : + #] ExpandRat : #[ InvPoly : The input polynomial is represented as a sequence of terms in ascending diff --git a/sources/startup.c b/sources/startup.c index 8d8fd3ca..01782c88 100644 --- a/sources/startup.c +++ b/sources/startup.c @@ -1339,6 +1339,7 @@ WORD IniVars() AT.inprimelist = -1; AT.sizeprimelist = 0; AT.primelist = 0; + AT.LeaveNegative = 0; AT.TrimPower = 0; AN.SplitScratch = 0; AN.SplitScratchSize = AN.InScratch = 0; diff --git a/sources/structs.h b/sources/structs.h index 509adda6..bf7e0f95 100644 --- a/sources/structs.h +++ b/sources/structs.h @@ -1967,7 +1967,7 @@ struct T_const { int ListSymbolsSize; int NumListSymbols; int numpoly; - int ListPolySize; + int LeaveNegative; int TrimPower; /* Indicates trimming in polyratfun expansion */ WORD small_power_maxx; /* size of the cache for small powers */ WORD small_power_maxn; /* size of the cache for small powers */