How can I get the values of the solved vars from the returned expression from lsolve?
Hi I stumbled across this incredibly useful library and I wanted to use the lsolve function. I was reading the tutorial pdf to figure out how to use it. So from lsolve i end up with an expression like: *{a==3,b==4}
*
I was wondering how I could get a value of the a and b symbols from this? I would ideally like to store them in an int to use in another library. I have been looking for an answer for a while so I would really appreciate if anyone knows? I could parse it like a string but Im assuming there is a better way? Thank you for your time, Zach
Hi, I usually do as follow: first store the list produced by lsolve as L, then use a.subs(L) as the value of a. For a cleaner code you may wish to add a check that the result is indeed a numeric and no exception occured. Best wishes. Vladimir On Oct 11, 2012 11:19 PM, "Zach" <refinedcode@gmail.com> wrote:
Hi I stumbled across this incredibly useful library and I wanted to use the lsolve function. I was reading the tutorial pdf to figure out how to use it. So from lsolve i end up with an expression like:
*{a==3,b==4}
*
I was wondering how I could get a value of the a and b symbols from this? I would ideally like to store them in an int to use in another library. I have been looking for an answer for a while so I would really appreciate if anyone knows? I could parse it like a string but Im assuming there is a better way?
Thank you for your time, Zach
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
That worked great thank you! On Fri, Oct 12, 2012 at 4:29 AM, Vladimir V. Kisil <kisilv@maths.leeds.ac.uk
wrote:
Hi, I usually do as follow: first store the list produced by lsolve as L, then use a.subs(L) as the value of a. For a cleaner code you may wish to add a check that the result is indeed a numeric and no exception occured. Best wishes. Vladimir On Oct 11, 2012 11:19 PM, "Zach" <refinedcode@gmail.com> wrote:
Hi I stumbled across this incredibly useful library and I wanted to use the lsolve function. I was reading the tutorial pdf to figure out how to use it. So from lsolve i end up with an expression like:
*{a==3,b==4}
*
I was wondering how I could get a value of the a and b symbols from this? I would ideally like to store them in an int to use in another library. I have been looking for an answer for a while so I would really appreciate if anyone knows? I could parse it like a string but Im assuming there is a better way?
Thank you for your time, Zach
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
_______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
participants (2)
-
Vladimir V. Kisil
-
Zach