On May 30, 12:45 pm, gpap <[email protected]> wrote: > Hi, > > I am very new to python and I am currently trying to migrate some code > from mathematica. What I'm stuck with is the following: > > I have created a linear system A.x = B, and I have a list of > replacement rules I would like to apply to the matrix A and the array > B before I go on to solve it. A minimal working example is as follows: > > ##################### > > from numpy import * > from sympy import * > t, t1, t2, t3 = symbols ('t', 't1', 't2', 't3') > A = array( [ [sin(t1)], [0], [sin(t3)], [sin(t)] ] ) > B = array( [sin(t1), 0, sin(t3), sin(t)] ) > def Rule_Sub(x): return (x).subs(Repl_Rules) > B= map(Rule_Sub, B) > for i in range(len(A)) > > ##################### > Now, I'd like to be able to do the same to the matrix A, i.e. apply a > list of replacement rules contd (I somehow managed to hit send before finishing). basically I was looking for a neat way of applying my replacement rules to the 2x2 array i.e. something along the lines of
map(Rule_Sub, map(Rule_Sub, A)) and also a clever way I could not bounce with an error on the zeros of my otherwise symbolic matrix when applying the replacement rules i.e. now when map(Rule_Sub, B) hits the zero it gives error since 0 is an integer - is there a way for sympy to pass it on as a symbol with value 0? -- You received this message because you are subscribed to the Google Groups "sympy" 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/sympy?hl=en.
