[SciPy-user] symbolic strings

Ryan Krauss ryanlists at gmail.com
Fri Feb 3 11:46:34 CST 2006


I may be getting in over my head, but I think this can work.  I do a
lot of analysis with matrices using the transfer matrix method.  
Sometimes I want to do numeric work with them and sometimes I use
python to generate an input script for Maxima.  Right now I have two
methods for my transfer matrix element, one that outputs a numeric
matrix and one that outputs a string for Maxima.  I am working on a
new element and would like to combined these two expressions by
creating a symbolic string method so that expressions like
a=-(L0*m1*r1*s**2-c1*s-k1)/(c1*s+k1)

make sense whether L0, m1, r1, s, etc are floats or symstrs (my new
class).  I overrode the __mul__, __add__, __div__,__sub__, and __pow__
methods but don't know if there are methods to override to deal with
the parenthesis and the unary - out in front.  Can this be done with
only a little bit more work?  Basically I want the output of this
expression to be 'a=-(L0*m1*r1*s**2-c1*s-k1)/(c1*s+k1)' if it is a
string and a float or complex if the variables are numbers.

Thanks,

Ryan



More information about the SciPy-user mailing list