> > -- A single term is of the form alpha * a * v > > Term == Record(coe:R, sca:scaPart, vec:vecPart) > > > > -- A normal form is a sum of terms > > Rep := List Term > > > > but I'm not sure about the String there. Should we use Symbol, > > Variable or is String fine or what would you suggest? > > I quickly browsed through the paper (actually only the implementation > part). I somehow got the impression that the instead of String one can > that any domain that represents the name of a variable.
It seems to me too. Names are strings, so I assume String does the job here. The zero vector get a "0" by this method. I'm not sure if this is nice. > > Next I have this code for creating new vector objects: > > > > vector(x:Symbol) : % == [ [1::R, [], [string x]] ]::% > > > > Is this ok? It seems to work but I don't know if this is the > > best way to do it. > > According to your representation that looks OK to me. Ok. > However, I don't quite like the "::%" in this line. In Aldor this > wouldn't work, since you never define a function coerce: > List(Term)->%. Hmm ... ok. > Seemingly, the SPAD compiler is swallowing that (as it > does in other parts of the library), but I prefer to do it this way... > > https://github.com/hemmecke/fricas-svn/blob/master/src/algebra/xhash.spad.pamphlet#L82 > > Then define Rep with "==" instead of ":=" and you line would look like > > vector(x:Symbol) : % == per [ [1::R, [], [string x]] ] Ok, changed that all over the code and pushed up. > Maybe it doesn't look like a bit difference to you, but always > explicitly inserting rep and per makes the types much more obvious to > the reader of your code (and also to the compiler). Thanks for the hint. I would never have guessed that. I fact I thought the ::Type to be the good solution for converting types here. > > And then, I'm stuck with output and printing. I tried to study the > > print facilities of Quaternions but it did not help that much. I > > tried with something like: > > > > coerce: % -> OutputForm > > > > but have no idea if this is appropriate at all. And I do not know > > how to implement the function properly. Could you please give me > > some hints how this whole stuff works? > > Well, you can think of OutputForm as some kind of expression tree that > you build up. Look at this > > (1) -> 2::OutputForm + 3::OutputForm * ('x)::OutputForm > > (1) 2 + 3x > > You add two things of type OutputForm, which internally simply means > forming a tree with root "+" and the two respective leaves. (Same for > "*".) Aha, ok. > When FriCAS wants to print a result, it calls coerce: % -> OutputForm > of the respective result type on the result. Then there is a internal > handling of transforming OutputForm to something you see on screen. Makes sense. > But that is FriCAS-internal, you have only minor influence on this. I hoped that we could use bold letters in latex printing. And a special symbol for the wedge product. We do really not want to get a^b written as $a^{b}$. > And it allows FriCAS to print the result in different forms. Have you > tried > > (2) -> )set output tex on > (2) -> 2::OutputForm + 3::OutputForm * ('x)::OutputForm > > (2) 2 + 3x > $$ > 2+{3 \ x} > \leqno(2) > $$ Jep, I know about the TeX output. I use it sometimes. > There's also > > )set output texmacs on > )set output mathml on > > and all that formats are produced from the expression tree that is > reppresented by OutputForm. This is fine so far. Thanks for the explanations! It helps me to better understand what the biger picture looks like. But how do I need to implement the coerce? I have this code (just a special case to try): coerce(x : %) : OutputForm == xx := rep x t1 := first xx t1.vec :: OutputForm I would think that for a simple expressions consisting of only one vector of name "u" I should get back the name printed, which is not the case: (8) -> vector(u)$VA(INT) LISP output: (UNPRINTABLE) Type: VectorAlgebra(Integer) There must be a missing bit somewhere. BTW: How can I look at the Rep of some object? -- 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.
