本文整理汇总了Python中sympy.Q.diagonal方法的典型用法代码示例。如果您正苦于以下问题:Python Q.diagonal方法的具体用法?Python Q.diagonal怎么用?Python Q.diagonal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.diagonal方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_MatrixSlice
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_MatrixSlice():
X = MatrixSymbol('X', 4, 4)
B = MatrixSlice(X, (1, 3), (1, 3))
C = MatrixSlice(X, (0, 3), (1, 3))
assert ask(Q.symmetric(B), Q.symmetric(X))
assert ask(Q.invertible(B), Q.invertible(X))
assert ask(Q.diagonal(B), Q.diagonal(X))
assert ask(Q.orthogonal(B), Q.orthogonal(X))
assert ask(Q.upper_triangular(B), Q.upper_triangular(X))
assert not ask(Q.symmetric(C), Q.symmetric(X))
assert not ask(Q.invertible(C), Q.invertible(X))
assert not ask(Q.diagonal(C), Q.diagonal(X))
assert not ask(Q.orthogonal(C), Q.orthogonal(X))
assert not ask(Q.upper_triangular(C), Q.upper_triangular(X))
示例2: test_diagonal
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_diagonal():
assert ask(Q.diagonal(X + Z.T + Identity(2)), Q.diagonal(X) &
Q.diagonal(Z)) is True
assert ask(Q.diagonal(ZeroMatrix(3, 3)))
assert ask(Q.lower_triangular(X) & Q.upper_triangular(X), Q.diagonal(X))
assert ask(Q.diagonal(X), Q.lower_triangular(X) & Q.upper_triangular(X))
assert ask(Q.symmetric(X), Q.diagonal(X))
assert ask(Q.triangular(X), Q.diagonal(X))
示例3: test_DiagonalMatrix
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_DiagonalMatrix():
x = MatrixSymbol('x', n, m)
D = DiagonalMatrix(x)
assert D.diagonal_length is None
assert D.shape == (n, m)
x = MatrixSymbol('x', n, n)
D = DiagonalMatrix(x)
assert D.diagonal_length == n
assert D.shape == (n, n)
assert D[1, 2] == 0
assert D[1, 1] == x[1, 1]
i = Symbol('i')
j = Symbol('j')
x = MatrixSymbol('x', 3, 3)
ij = DiagonalMatrix(x)[i, j]
assert ij != 0
assert ij.subs({i:0, j:0}) == x[0, 0]
assert ij.subs({i:0, j:1}) == 0
assert ij.subs({i:1, j:1}) == x[1, 1]
assert ask(Q.diagonal(D)) # affirm that D is diagonal
x = MatrixSymbol('x', n, 3)
D = DiagonalMatrix(x)
assert D.diagonal_length == 3
assert D.shape == (n, 3)
assert D[2, m] == KroneckerDelta(2, m)*x[2, m]
assert D[3, m] == 0
raises(IndexError, lambda: D[m, 3])
x = MatrixSymbol('x', 3, n)
D = DiagonalMatrix(x)
assert D.diagonal_length == 3
assert D.shape == (3, n)
assert D[m, 2] == KroneckerDelta(m, 2)*x[m, 2]
assert D[m, 3] == 0
raises(IndexError, lambda: D[3, m])
x = MatrixSymbol('x', n, m)
D = DiagonalMatrix(x)
assert D.diagonal_length is None
assert D.shape == (n, m)
assert D[m, 4] != 0
x = MatrixSymbol('x', 3, 4)
assert [DiagonalMatrix(x)[i] for i in range(12)] == [
x[0, 0], 0, 0, 0, 0, x[1, 1], 0, 0, 0, 0, x[2, 2], 0]
# shape is retained, issue 12427
assert (
DiagonalMatrix(MatrixSymbol('x', 3, 4))*
DiagonalMatrix(MatrixSymbol('x', 4, 2))).shape == (3, 2)
示例4: test_diagonal
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_diagonal():
assert ask(Q.diagonal(X + Z.T + Identity(2)), Q.diagonal(X) &
Q.diagonal(Z)) is True
assert ask(Q.diagonal(ZeroMatrix(3, 3)))
assert ask(Q.lower_triangular(X) & Q.upper_triangular(X), Q.diagonal(X))
assert ask(Q.diagonal(X), Q.lower_triangular(X) & Q.upper_triangular(X))
assert ask(Q.symmetric(X), Q.diagonal(X))
assert ask(Q.triangular(X), Q.diagonal(X))
assert ask(Q.diagonal(C0x0))
assert ask(Q.diagonal(A1x1))
assert ask(Q.diagonal(A1x1 + B1x1))
assert ask(Q.diagonal(A1x1*B1x1))
assert ask(Q.diagonal(V1.T*V2))
assert ask(Q.diagonal(V1.T*(X + Z)*V1))
assert ask(Q.diagonal(MatrixSlice(Y, (0, 1), (1, 2)))) is True
assert ask(Q.diagonal(V1.T*(V1 + V2))) is True
示例5: test_DiagonalMatrix_Assumptions
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_DiagonalMatrix_Assumptions():
assert ask(Q.diagonal(D))
示例6: test_svd
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import diagonal [as 别名]
def test_svd():
U, S, V = svd(X)
assert U.shape == S.shape == V.shape == X.shape
assert ask(Q.orthogonal(U))
assert ask(Q.orthogonal(V))
assert ask(Q.diagonal(S))