sympy
prints some expressions putting the negative term first.
Sensy打印了一些表达式,将否定项放在第一位。
example:
示例:
from sympy import symbols, Matrix
import numpy as np
m = 3
obj = np.dtype(object)
ρ = np.asarray([symbols(f"ρ_{i}") for i in range(m)], obj)
ε = np.asarray([symbols(f"ε_{i}") for i in range(m)], obj)
expr = ε - ρ * ε[1]
Matrix(expr)
output:
输出:
Here, I want second and third elements to be printed as the first element (positive term comes first), is there a solution for that?
在这里,我希望打印第二个和第三个元素作为第一个元素(第一个元素是积极项),有什么解决方案吗?
更多回答
优秀答案推荐
The best thing you can try is:
你可以尝试的最好办法是:
from sympy import *
import numpy as np
init_printing(order="none")
then:
然后:
m = 3
obj = np.dtype(object)
ρ = np.asarray([symbols(f"ρ_{i}") for i in range(m)], obj)
ε = np.asarray([symbols(f"ε_{i}") for i in range(m)], obj)
expr = ε - ρ * ε[1]
Matrix(expr)
更多回答
我是一名优秀的程序员,十分优秀!