Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Solve matrix and vector multiplication with parameters instead of values (preferably in python)

$
0
0

I want to look at some vector operations and see which matrix elements go into which vector, e.g. if I define a matrix with elements

mat = [["a11", "a12"], ["a21", "a22"]]

and a vector

vec = ["v1", "v2"]

then I'm looking for some module / library that gives me the result when I calclulate the product:

res = mat*vec = ["a11"*"v1" +"a12"*"v2", "a21"*"v1" +"a22"*"v2"]

I know this is easy to do if all the parameters are actual numbers with numpy and of course I could work this out by hand, but if the operations becomes more complex it would be nice to have a way to automatically generate the resulting vector as a parameter equation.

Bonus points if the equation gets simplified, if e.g. the result has +"a11" - "a11" somewhere and reduces this to 0.

Is this at all possible to do in python? Wolfram Alfa gets me what I'm looking for, but I also need some operations on input data so a way to do this with a script would be great.


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>