本文整理汇总了Python中sympy.Mul.as_ordered_factors方法的典型用法代码示例。如果您正苦于以下问题:Python Mul.as_ordered_factors方法的具体用法?Python Mul.as_ordered_factors怎么用?Python Mul.as_ordered_factors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Mul
的用法示例。
在下文中一共展示了Mul.as_ordered_factors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_as_ordered_factors
# 需要导入模块: from sympy import Mul [as 别名]
# 或者: from sympy.Mul import as_ordered_factors [as 别名]
def test_as_ordered_factors():
f, g = symbols("f,g", cls=Function)
assert x.as_ordered_factors() == [x]
assert (2 * x * x ** n * sin(x) * cos(x)).as_ordered_factors() == [Integer(2), x, x ** n, sin(x), cos(x)]
args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)]
expr = Mul(*args)
assert expr.as_ordered_factors() == args
示例2: test_as_ordered_factors
# 需要导入模块: from sympy import Mul [as 别名]
# 或者: from sympy.Mul import as_ordered_factors [as 别名]
def test_as_ordered_factors():
f, g = symbols("f,g", cls=Function)
assert x.as_ordered_factors() == [x]
assert (2 * x * x ** n * sin(x) * cos(x)).as_ordered_factors() == [Integer(2), x, x ** n, sin(x), cos(x)]
args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)]
expr = Mul(*args)
assert expr.as_ordered_factors() == args
A, B = symbols("A,B", commutative=False)
assert (A * B).as_ordered_factors() == [A, B]
assert (B * A).as_ordered_factors() == [B, A]