>
> I think that going via InputForm is not the right way to do such a
> conversion from FriCAS Expression(INT) into a Sage expression.
>
> Wouldn't it be wiser to add functions to Expression in order to
> decompose an element. There are already some such functions.
>
At least for the moment, no. The problem is that, currently and in the
near future, there is no (sensible) way to access FriCAS data structures
from sage directly. While I know that this would be possible in principle,
I do not have the expertise to do that, and so far, nobody indicated that
(s)he would be able and have the time to do it.
But even then, I think that InputForm would be the correct way to talk to
other systems, because it is a very general way to transport typed
information.
In any case, currently all I can get from FriCAS is a string. There is a
reasonably efficient and well-maintained, parser in sage, all I have to do
is to provide a lookup table which tells it how to interpret a particular
function, which is completely straightforward most of the time, and
extremely easy to maintain. For example:
def safe_subs(f, v, n):
if n in f.variables():
return f, v
return f.subs({v:n}), n
register_symbol(lambda f,v,n,a,b: symbolic_sum(*(safe_subs(f, v, n)
+ (a, b))), {'fricas':'_defsum'})
register_symbol(lambda f,v,n,a,b: symbolic_prod(*(safe_subs(f, v,
n) + (a, b))), {'fricas':'_defprod'})
is all I have to do to make the translation for sums and products. (FriCAS
has the
concept of dummy variables, which sage has not, that's the reason for
"safe_subs".)
Note that for other FriCAS types, I use a slightly different approach, but
still mostly
the InputForm. For those FriCAS domains that lack InputForm, I have to use
ugly
hacks, but that's OK...
Anyway, it would be great to have a polished version of my proposal in the
next release...
Martin
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.