简体   繁体   中英

How to turn a system of sympy equations into matrix form

How do I turn a system of sympy equations into a matrix form?

For example, how do I turn a system like this:

equation_one = 4*a*x + 3*b*y
equation_two = 2*b*x + 1*a*y

Into a system like this:

matrix_form = ([equation_one, equation_two], [x, y])

That will return this:

[[4*a, 3*b], 
 [2*b, 1*a]]

Does a function like matrix_form() exist?

After some searching, I found

sympy.linear_eq_to_matrix(equations, *symbols)

This has solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM