vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

Inconsistent use of power sign with "Format reduce" #359

Closed spj101 closed 3 years ago

spj101 commented 3 years ago

I understand that the REDUCE computer algebra system admits the use of the characters "^" and "**" as a power sign.

I am not completely familiar with the syntax of the system but I noticed that when using "Format reduce" FORM actually uses a mixture of these two power signs. Is this intentional behaviour?

Example:

Symbols x;
CFunctions f;
Local F = f(x^2)+f(x)^2;
Format reduce;
Print;
.end

Outputs:

F = f(x**2) + f(x)^2;

I believe the cause of this is in the file sources/sch.c, around line 1786 we see:

if ( AC.OutputMode == FORTRANMODE || AC.OutputMode == PFORTRANMODE
 || AC.OutputMode == REDUCEMODE )
TokenToLine((UBYTE *)")**(");

but later around line 2057 we see:

if ( AC.OutputMode == FORTRANMODE
|| AC.OutputMode == PFORTRANMODE ) { TokenToLine((UBYTE *)"**"); }

Is the omission in the latter block deliberate?

vermaseren commented 3 years ago

I guess it is an omission. You seem to be the first to notice. The case of the dictionary replacement also seems to gave gone totally untested, because there is a routine in the file dict.c (IsExponentSign) to locate it, but the routine is never called. The same for IsMultiplySign. It seems that when I designed this I recognised it all, but when I went to make it work I forgot to activate these two. And you are the first to complain…… Goes to show how some of the very powerful features in Form get used only by few people and mostly to a limited extent. It may need a bit of a study to repair this without further omissions.

Jos

On 14 Jul 2020, at 20:58, Stephen Jones notifications@github.com wrote:

I understand that the REDUCE computer algebra system admits the use of the characters "^" and "**" as a power sign.

I am not completely familiar with the syntax of the system but I noticed that when using "Format reduce" FORM actually uses a mixture of these two power signs. Is this intentional behaviour?

Example:

Symbols x; CFunctions f; Local F = f(x^2)+f(x)^2; Format reduce; Print; .end Outputs:

F = f(x**2) + f(x)^2; I believe the cause of this is in the file sources/sch.c, around line 1786 we see:

if ( AC.OutputMode == FORTRANMODE || AC.OutputMode == PFORTRANMODE || AC.OutputMode == REDUCEMODE ) TokenToLine((UBYTE *)")**("); but later around line 2057 we see:

if ( AC.OutputMode == FORTRANMODE || AC.OutputMode == PFORTRANMODE ) { TokenToLine((UBYTE *)"**"); } Is the omission in the latter block deliberate?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/359, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCETYTU635IULWZBJ3YLR3STFNANCNFSM4OZZUIDA.