本文整理汇总了Python中sympy.Q.positive_definite方法的典型用法代码示例。如果您正苦于以下问题:Python Q.positive_definite方法的具体用法?Python Q.positive_definite怎么用?Python Q.positive_definite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.positive_definite方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_POSV
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
def test_POSV():
X = MatrixSymbol('X', n, n)
Y = MatrixSymbol('Y', n, m)
posv = POSV(X, Y)
assert posv.outputs[0] == X.I*Y
assert not POSV.valid(posv.inputs, True)
assert POSV.valid(posv.inputs, Q.symmetric(X) & Q.positive_definite(X))
示例2: test_POSV_codemap
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
def test_POSV_codemap():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, m)
assumptions = Q.positive_definite(A) & Q.symmetric(A)
codemap = POSV(A, B).codemap('A B INFO'.split(), assumptions)
call = POSV.fortran_template % codemap
assert "('U', n, m, A, n, B, n, INFO)" in call
assert 'dposv' in call.lower()
示例3: test_POTRS
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
def test_POTRS():
from sympy.matrices.expressions.factorizations import UofCholesky
from computations.matrices.lapack import POTRS
c = POTRS(UofCholesky(A), X)
with assuming(Q.real_elements(A), Q.real_elements(X),
Q.positive_definite(A)):
f = build(c, [UofCholesky(A), X], [A.I*X], modname='potrs',
filename='tmp/potrs.f90')
nA = np.asarray([[1, 0], [0, 1]], dtype=np.float64, order='F')
nX = np.asarray([[1, 2], [3, 4]], dtype=np.float64, order='F')
expected = np.asarray([[1., 2.], [3., 4.]])
f(nA, nX); result = nX
assert np.allclose(expected, result)
示例4: SYMM
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
(alpha*A*B, SYMM(alpha, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), SYMM.condition),
(A*B, SYMM(1.0, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), SYMM.condition),
(alpha*A*B + beta*C, GEMM(alpha, A, B, beta, C), True),
(alpha*A*B + C, GEMM(alpha, A, B, 1.0, C), True),
(A*B + beta*C, GEMM(1.0, A, B, beta, C), True),
(A*B + C, GEMM(1.0, A, B, 1.0, C), True),
(alpha*A*B, GEMM(alpha, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), True),
(A*B, GEMM(1.0, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), True),
(alpha*X + Y, AXPY(alpha, X, Y), AXPY.condition),
(X + Y, AXPY(1.0, X, Y), True)
]
lapack = [
(Z.I*X, POSV(Z, X), Q.symmetric(Z) & Q.positive_definite(Z)),
(Z.I*X, GESVLASWP(Z, X), True),
# (Z.I*X, GESV(Z, X) + LASWP(MatMul(PermutationMatrix(IPIV(Z.I*X)), Z.I*X), IPIV(Z.I*X)), True),
]
other = [
(DFT(n)*x, FFTW(x), True),
(DFT(n).T*x, IFFTW(x), True),
(HadamardProduct(A, X), ElemProd(A, X), True),
(BlockMatrix(blocks), Join(BlockMatrix(blocks)), True),
(X[i1:i2:i3, i4:i5:i6], Slice(X[i1:i2:i3, i4:i5:i6]), True),
]
patterns = lapack + blas + other
示例5: test_positive_definite
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
def test_positive_definite():
assert ask(Q.positive_definite(X), Q.positive_definite(X))
assert ask(Q.positive_definite(X.T), Q.positive_definite(X)) is True
assert ask(Q.positive_definite(X.I), Q.positive_definite(X)) is True
assert ask(Q.positive_definite(Y)) is False
assert ask(Q.positive_definite(X)) is None
assert ask(Q.positive_definite(X*Z*X),
Q.positive_definite(X) & Q.positive_definite(Z)) is True
assert ask(Q.positive_definite(X), Q.orthogonal(X))
assert ask(Q.positive_definite(Y.T*X*Y),
Q.positive_definite(X) & Q.orthogonal(Y)) is True
assert ask(Q.positive_definite(Identity(3))) is True
assert ask(Q.positive_definite(ZeroMatrix(3, 3))) is False
assert ask(Q.positive_definite(X+Z), Q.positive_definite(X) &
Q.positive_definite(Z)) is True
assert not ask(Q.positive_definite(-X), Q.positive_definite(X))
示例6: test_det_trace_positive
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
def test_det_trace_positive():
X = MatrixSymbol('X', 4, 4)
assert ask(Q.positive(Trace(X)), Q.positive_definite(X))
assert ask(Q.positive(Determinant(X)), Q.positive_definite(X))
示例7: Symbol
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import positive_definite [as 别名]
from sympy.matrices.expressions import MatrixSymbol, Transpose
from sympy import Symbol, Q
n, k = Symbol('n'), Symbol('k')
mu = MatrixSymbol('mu', n, 1)
Sigma = MatrixSymbol('Sigma', n, n)
H = MatrixSymbol('H', k, n)
R = MatrixSymbol('R', k, k)
data = MatrixSymbol('data', k, 1)
newmu = mu + Sigma*H.T * (R + H*Sigma*H.T).I * (H*mu - data)
newSigma= Sigma - Sigma*H.T * (R + H*Sigma*H.T).I * H * Sigma
newSigma = -1.0*Sigma*H.T*(H*Transpose(H*Sigma) + R).I*H*Sigma + Sigma
newmu = Sigma*H.T*(H*Transpose(H*Sigma) + R).I*(-1.0*data + H*mu) + mu
assumptions = (Q.positive_definite(Sigma), Q.symmetric(Sigma),
Q.positive_definite(R), Q.symmetric(R), Q.fullrank(H))
inputs = mu, Sigma, H, R, data
outputs = newmu, newSigma