On Tue, Sep 2, 2008 at 6:34 PM, Waldek Hebisch wrote: > > Some time ago Bill Page proposed a patch to eliminate Fortran > names from the output of unparse. Unfortunatly, his patch > caused regression when printing some types. >
Yes. See: http://axiom-wiki.newsynthesis.org/401UnparseGeneratesFortranFunctionNames > AFAICS Bill idea was to use Fortran machinery for unparsing, > but to skip the renaming stage. Now, I think that ideally > we should not re-use Fortran generating code for unparsing > because Fortran machinery is doing a lot of Fortran specific > things. It was not my idea to use the Fortran machinery - that was just the way it was done - but I do think the Fortran renaming is not correct for true unparsing. I agree that the Fortran stuff is not right approach. > In fact, I think that uparsing should work in a quite different > way: > 1) we should first walk the expression tree and compute > priority at each node > 2) based on 1 we should mark places where we need to insert > parentheses -- in this step we probably should add various > symbols as markup, but we should still keep tree in symbolic > form > 3) Only in final step we should generate string from the tree, > just by simple walk which collects translations of separate > symbols. > > In principle steps 1 and 2 are similar for all output formats, > so we could use generic setup for them (of course values of > priorities may depend on output format). Ideally, much of > step 3 could be re-used. > That is (more or less) what the code does now, isn't it? > However, I think that we have much more urgent tasks > than re-write of output routines. In particular unparse has > only little use. unparse is critical for the Sage interface. > So I propose to apply a variation of Bill's patch. Compared > to Bill I am using Fortran machinery only for binary operators > (like current code). Also, I am setting a few variables used > by Fortran machinery -- I do not have a testcase, but I > expect that on complicated expressions Fortran machinery > will fail if those variables have no value. > > diff -ru --exclude=.svn trunk.bb/src/input/i-bugs2008.input.pamphlet > trunk/src/input/i-bugs2008.input.pamphlet > --- trunk.bb/src/input/i-bugs2008.input.pamphlet 2008-09-03 > 00:06:07.000000000 +0200 > +++ trunk/src/input/i-bugs2008.input.pamphlet 2008-09-03 00:05:22.000000000 > +0200 > @@ -34,6 +34,11 @@ > -- regression in printing Gamma > Gamma(2,3) > > +-- Strange case of linear printing > +K := Fraction Integer > +g := matrix [[1,0,0,0], [0,-1,0,0], [0,0,-1,0], [0,0,0,-1]] > +D := CliffordAlgebra(4,K, quadraticForm g) > + > @ > \eject > \begin{thebibliography}{99} > diff -ru --exclude=.svn trunk.bb/src/interp/format.boot > trunk/src/interp/format.boot > --- trunk.bb/src/interp/format.boot 2008-09-03 00:06:07.000000000 +0200 > +++ trunk/src/interp/format.boot 2008-09-03 00:07:38.000000000 +0200 > @@ -428,10 +428,15 @@ > argl := rest argl > (null argl) or null (first argl) => [lo, '".."] > [lo, '"..", form2String1 first argl] > - isBinaryInfix op => fortexp0 [op,:argl] > - -- COMPILED_-FUNCTION_-P(op) => form2String1 coerceMap2E(u1,NIL) > + isBinaryInfix op => binop2String [op,:argl] > application2String(op,[form2String1 x for x in argl], u1) > > +binop2String x == > + $exp2FortTempVarIndex : local := 0 > + $fortName : fluid := newFortranTempVar() > + $fortInts2Floats : fluid := nil > + fortranCleanUp exp2Fort1 exp2FortOptimize x > + > formWrapId id == > $formatSigAsTeX = 1 => id > $formatSigAsTeX = 2 => > I tried this patch but something goes wrong. See: http://axiom-wiki.newsynthesis.org/401UnparseGeneratesFortranFunctionNames#bottom Waldek, did you try this example? y := cos(x2) + 2*x1 unparse(y::INFORM) Does it work for you? Regards, Bill Page. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en -~----------~----~----~----~------~----~------~--~---
