-
Notifications
You must be signed in to change notification settings - Fork 137
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
brackets and #write #262
Labels
question
Question about FORM
Comments
Hi,
The bracket statement does not work for dollar expressions.
If you use %e instead, at least for me it works. As in:
S a,b,c;
L F = (a+b+c)^10;
B b;
.sort
#write <atest> " F = %e",F
.end
What goes wrong in your code is also that the preprocessor gets to do its thing
before the ‘algebra’ run. Hence, the #write gets executed before your expression has passed
the running and hence the bracketting.
Cheers
Jos
… On 8 Feb 2018, at 07:31, Vladyslav Shtabovenko ***@***.***> wrote:
I would like to use brackets to simplify the output of FORM before passing it to other programs. However,
it seems that the brackets do not survive a #write instruction, even if there is no intermediate sort inbetween. Consider for example
off statistics;
S a,b,z,y;
L exp = a*y^2 + 3*a + z*b+ z^3*b;
.sort
bracket a, b;
print exp;
#$a1 = exp;
#write <exp.frm> "%$",$a1;
.end
the print statement produces
exp =
+ b * ( z + z^3 )
+ a * ( 3 + y^2 );
which is exactly what I want, but the content of my exp.frm is nevertheless
b*z+b*z^3+3*a+a*y^2
A naive workaround is to use a "fake" collect
off statistics;
S a,b,z,y;
CF head;
L exp = a*y^2 + 3*a + z*b+ z^3*b;
.sort
bracket a, b;
.sort
collect head;
.sort
print exp;
#$a1 = exp;
#write <exp.frm> "%$",$a1;
.end
and remove head in a later step. However, this probably would not work for very large expressions and in general appears to be an ugly hack. I believe that I'm not the first person to encounter this complication, so I wonder what is the recommended workaround.
Cheers,
Vladyslav
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#262>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFLxEibrvQW50SrSkIfOybiNmCF_AJbCks5tSpS5gaJpZM4R93Vk>.
|
Perfect, many thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would like to use brackets to simplify the output of FORM before passing it to other programs. However,
it seems that the brackets do not survive a
#write
instruction, even if there is no intermediatesort
inbetween. Consider for examplethe
print
statement produceswhich is exactly what I want, but the content of my
exp.frm
is neverthelessA naive workaround is to use a "fake" collect
and remove
head
in a later step. However, this probably would not work for very large expressions and in general appears to be an ugly hack. I believe that I'm not the first person to encounter this complication, so I wonder what is the recommended workaround.Cheers,
Vladyslav
The text was updated successfully, but these errors were encountered: