Dear Maxima community
It looks like the linel option stops working if the display2d flag is set to false and large numbers are used.
I’m ready to accept that the break is happening in the wrong place, but I really miss the line break character (backslash), since its absence makes it difficult to parse the maxima output.
(%i1) linel; (%o1) 79 (%i2) display2d; (%o2) true (%i3) (x + 1) / (x^2 + 2^300); 2 (%o3) (x + 1)/(x + 2037035976334486086268445688409378161051468393665936250636\ 140449354381299763336706183397376) (%i4) linel: 40; (%o4) 40 (%i5) (x + 1) / (x^2 + 2^300); 2 (%o5) (x + 1)/(x + 2037035976334486086\ 268445688409378161051468393665936250636\ 140449354381299763336706183397376) (%i6) linel: 79; (%o6) 79 (%i7) display2d: false; (%o7) false (%i8) (x + 1) / (x^2 + 2^300); (%o8) (x+1)/(x^2+2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376) (%i9) linel: 40; (%o9) 40 (%i10) (x + 1) / (x^2 + 2^300); (%o10) (x+1)/(x^2+2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376) (%i11) linel: 10; (%o11) 10 (%i12) (x + 1) / (x^2 + 2^300); (%o12) (x+1) /(x^2 +2037035976334486086268445688409378161051468393665936250636140449354381299763336706183397376)
Maxima version: "5.43.2" Maxima build date: "2020-02-21 05:22:38" Host type: "x86_64-pc-linux-gnu" Lisp implementation type: "GNU Common Lisp (GCL)" Lisp implementation version: "GCL 2.6.12" User dir: "/home/kikke/.maxima" Temp dir: "/tmp" Object dir: "/home/kikke/.maxima/binary/5_43_2/gcl/GCL_2_6_12" Frontend: false
Thanks in advance.
As far as I can tell, with
display2d:false
, the printer never inserts a newline in the middle of a token (symbol, number, or string), so I don't see how a break can "happen[] in the wrong place" -- butlinel
continues to force line breaks between tokens.Since the printer starts each new line with a space, you can just concatenate all the output to parse it. I'm not sure what the value of a backslash character would be since one is essentially implicit at the end of every line.
Is this a bug? The documentation isn't explicit enough to say....
Thanks for your reply.
It would be nice if a comment about the lack of a line break in the middle of the token would be added to the documentation to the description of the display2d: false option. Then it will definitely not be a bug =)
I think the ticket can be closed
wxMaxima can be configured to add line breaks to long numbers. If that is the case a right-click on such a number will allow to select any of the other options.
It seems kind of inconsistent that
linel
is applied to atoms whendisplay2d
is enabled and not otherwise ... it seems like disablingdisplay2d
is more likely a situation in which one would like a fixed line width. What does anyone think about that? Kirill, what were you trying to do when you bumped intolinel
?I have a C++ program that sometimes has coefficients (fractions with polynomials), which need to be simplified. It uses
fork
andexecl
to start simplifier programs to which it sends the coefficients tostdin
and readsstdout
. And I'm trying to useMaxima
to do this. From the documentation I realized that I need to use the flagsratsimpexpons:true; display2d:false; stardisp:true; nolabels:true;
and theratsimp
function. Now I'm runningMaxima
with the--very-quiet
flag so that labels are not displayed in stdout, but two problems appear:1) Due to the interactive mode,
Maxima
writes not only simplified coefficient to stdout, but also the original one.2) Even if the problem 1) is resolved, it is still difficult to understand at what point the simplified coefficient ends. Adding the prefix I set to all the results of
ratsimp
would solve this problem. And with usinglinel
I tried to solve 2) the problem.Are there any ways to solve my problems with
Maxima
?Thanks in advance.
Kirill, I don't understand the problems (1) and (2) you mentioned. Here is an example input,
Let's say that's in a file named
/tmp/foo.mac
. Then when I say$ cat /tmp/foo.mac | maxima --very-quiet
then the output is just the one long line,
I don't see the input being echoed.
About (2), I don't understand what you mean about not knowing where the coefficient ends. Can you make
linel
very large and then just read the output from one line?My advice at this point is to open a new bug report and paste in an example input and output to illustrate what you are seeing. Please create a new bug report, since that will help us focus on the new issues.
I don't think it matters. It's not as though anyone is using TTY33's where excess characters pile up on the right margin.
Not breaking has the advantage that any process that consumes the output doesn't need to know what convention Maxima follows for continuation lines.
Let's just document the behavior (as the OP suggests) and move on.
Fixed by commit 758816, closing this report.
As discussed here, I updated the description of
display2d
to say how it interacts withlinel
. The behavior is actually not entirely consistent, but as we were saying, let it stand for now. I put in the following paragraphs, which are shown by? display2d
:Kirill, if you want to ensure that lines are exactly a certain length, the only way which I have found to ensure that is by setting
display2d: true
and then sayingstring(expr);
. E.g.,If you want to save stuff in a file, you could try something like
with_stdout("foo.out", print(string(expr)));
I found that when
expr
is very large, then the above procedure is surprisingly slow. I didn't figure out where is the bottleneck -- instring
,print
,with_stdout
? I don't know.