Implicit product syntax and tracking variable assignments

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

Lephe
Messages : 5
Inscription : sam. déc. 29, 2018 8:44 am

Implicit product syntax and tracking variable assignments

Message par Lephe » mer. août 05, 2020 4:16 pm

For a CAS calculator project based on Giac (Symbolibre), we are building GUIs that use Giac as a backend and exploring the various ways we can input and output data with the library. We'd like some insight into Giac's behavior for two aspects in particular:
  • Is the implicit product syntax supported? Things like (x+1)(y+1), where disambiguation with function calls supposedly based on the type of the left operand. We considered various ways of inserting products manually but they would all need help from Giac's parser to work properly.
  • Is there a way to hook to variable assignments? We'd like to know at various times what variables are defined in a context and when their values change, but scanning the whole tabptr each time is not very performance-friendly. We figured we could do that in the sto() function, but the context's tabptr seems to be accessed directly in many places. Is there a safe way to track changes here?
We'd be happy to look into it and provide tentative PRs if work is welcome on these questions.

Lephe' :)

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Implicit product syntax and tracking variable assignments

Message par parisse » mer. août 05, 2020 7:45 pm

There is partial support for implicit multiplication, but it's not robust code. I always discourage using implicit multiplication, except for things like 2x or 2sin(x), in fact I think it's bad for learning math, it would probably better to avoid implicit multiplication on the blackboard too at the highschool level.
The code is inside check_symb_of in usual.cc.

There is no 100% safe way to track variable assignement, sorry. I believe that adding code in sto should work for variables assignement made by users.

Lephe
Messages : 5
Inscription : sam. déc. 29, 2018 8:44 am

Re: Implicit product syntax and tracking variable assignments

Message par Lephe » jeu. août 27, 2020 7:54 am

Thank you, it seems that the existing implicit product syntax captures most of the "natural" behavior, or at least enough to work until a warning is shown.

For variable assignments, we'll experiment with a polling method and avoid tracking too many variables, it should be sufficient (and efficient enough) for most purposes. ^^

Répondre