> -- 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. > 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. 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)->%. 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]] ] 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). > 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 "*".) 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. But that is FriCAS-internal, you have only minor influence on this. 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) $$ 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. Ralf PS: Actually, since the authors of the paper have written their code in Aldor, it would be wise to ask them to release their code under a free license. Then it could be included into FriCAS without you wasting your time in reimplementing things. I'm sure there are other things that are not yet implemented in FriCAS and which would be a good exercise to learn SPAD. -- 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.
