当前位置: 首页>>代码示例>>Python>>正文


Python Q.symmetric方法代码示例

本文整理汇总了Python中sympy.Q.symmetric方法的典型用法代码示例。如果您正苦于以下问题:Python Q.symmetric方法的具体用法?Python Q.symmetric怎么用?Python Q.symmetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.Q的用法示例。


在下文中一共展示了Q.symmetric方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_valid

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_valid():
    A = MatrixSymbol('A', n, n)
    B = MatrixSymbol('B', n, n)
    C = MatrixSymbol('C', n, n)
    assert GEMM.valid((1, A, B, 2, C), True)
    assert not SYMM.valid((1, A, B, 2, C), True)
    assert SYMM.valid((1, A, B, 2, C), Q.symmetric(A))
    assert SYMM.valid((1, A, B, 2, C), Q.symmetric(B))
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_blas.py

示例2: test_MatrixSlice

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [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))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:17,代码来源:test_matrices.py

示例3: test_POSV

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [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))
开发者ID:mrocklin,项目名称:computations,代码行数:9,代码来源:test_lapack.py

示例4: test_POSV_codemap

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [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()
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_lapack.py

示例5: test_SYMM_codemap

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_SYMM_codemap():
    A = MatrixSymbol('A', n, n)
    B = MatrixSymbol('B', n, m)
    C = MatrixSymbol('C', n, m)
    codemap = SYMM(a, A, B, c, C).codemap('aABcC', Q.symmetric(A))
    call = SYMM.fortran_template % codemap
    assert "('L', 'U', n, m, a, A, n, B, n, c, C, n)" in call
    assert 'dsymm' in call.lower()
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_blas.py

示例6: test_diagonal

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [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))
开发者ID:A-turing-machine,项目名称:sympy,代码行数:10,代码来源:test_matrices.py

示例7: test_SYMM_BA

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_SYMM_BA():
    A = MatrixSymbol('A', n, n)
    B = MatrixSymbol('B', m, n)
    C = MatrixSymbol('C', m, n)
    codemap = SYMM(a, B, A, c, C).codemap('aBAcC', Q.symmetric(A))
    call = SYMM.fortran_template % codemap
    print call
    assert "('R', 'U', m, n, a, A, n, B, m, c, C, m)" in call
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_blas.py

示例8: test_SYMM

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_SYMM():
    with assuming(Q.real_elements(A), Q.real_elements(X), Q.symmetric(A)):
        f = build(SYMM(1.0, A, X, 0.0, ZeroMatrix(A.rows, X.cols)),
                [A, X], [A*X], modname='symmtest', filename='tmp/symmtest.f90')

    nA = np.asarray([[1, 2], [2, 1]], dtype=np.float64, order='F')
    nX = np.asarray([[1], [1]], dtype=np.float64, order='F')
    expected = np.asarray([[3.], [3.]])
    result = f(nA, nX)
    assert np.allclose(expected, result)
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_integrative.py

示例9: refine_Transpose

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def refine_Transpose(expr, assumptions):
    """
    >>> from sympy import MatrixSymbol, Q, assuming, refine
    >>> X = MatrixSymbol('X', 2, 2)
    >>> X.T
    X'
    >>> with assuming(Q.symmetric(X)):
    ...     print(refine(X.T))
    X
    """
    if ask(Q.symmetric(expr), assumptions):
        return expr.arg

    return expr
开发者ID:AdrianPotter,项目名称:sympy,代码行数:16,代码来源:transpose.py

示例10: test_diagonal

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [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
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:18,代码来源:test_matrices.py

示例11: test_refine

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_refine():
    assert refine(C.T, Q.symmetric(C)) == C
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:4,代码来源:test_transpose.py

示例12: SYMM

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
    (A*B + beta*C, SYMM(1.0, A, B, beta, C), (A, B, beta, C), SYMM.condition),
    (A*B + C, SYMM(1.0, A, B, 1.0, C), (A, B, C), SYMM.condition),
    (alpha*A*B, SYMM(alpha, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), (alpha, A, B), SYMM.condition),
    (A*B, SYMM(1.0, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), (A, B), SYMM.condition),

    (alpha*A*B + beta*C, GEMM(*GEMM._inputs), GEMM._inputs, True),
    (alpha*A*B + C, GEMM(alpha, A, B, 1.0, C), (alpha, A, B, C), True),
    (A*B + beta*C, GEMM(1.0, A, B, beta, C), (A, B, beta, C), True),
    (A*B + C, GEMM(1.0, A, B, 1.0, C), (A, B, C), True),
    (alpha*A*B, GEMM(alpha, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), (alpha, A, B), True),
    (A*B, GEMM(1.0, A, B, 0.0, ZeroMatrix(A.rows, B.cols)), (A, B), True),

    (alpha*X + Y, AXPY(*AXPY._inputs), AXPY._inputs, AXPY.condition),
    (X + Y, AXPY(1.0, X, Y), (X, Y), True)
]

lapack_patterns = [
    (Z.I*X, POSV(Z, X), (Z, X), Q.symmetric(Z) & Q.positive_definite(Z)),
    (Z.I*X, GESV(Z, X) + LASWP(PermutationMatrix(IPIV(Z.I*X))*Z.I*X, IPIV(Z.I*X)), (Z, X), True),

]

ints = start1, stop1, step1, start2, stop2, step2 = map(Dummy,
        '_start1 _stop1 _step1 _start2 _stop2 _step2'.split())
other_patterns = [
    (DFT(n) * x, FFTW(x), (x, n), True),
    (DFT(n).T * x, IFFTW(x), (x, n), True),
]

patterns = lapack_patterns + blas_patterns + other_patterns
开发者ID:mrocklin,项目名称:computations,代码行数:32,代码来源:patterns.py

示例13: test_correct_computation_matches

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_correct_computation_matches():
    with variables(*vars):
        assert set(map(type, computations_for(expr))) == set((SYRK, GEMM))

        with assuming(Q.symmetric(X)):
            assert set(map(type, computations_for(expr))) == set((SYRK, GEMM, SYMM))
开发者ID:mrocklin,项目名称:megatron,代码行数:8,代码来源:test_core.py

示例14: locals

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
new = locals().copy()

vars = [v for (k, v) in new.items() if k not in old and k != 'old']

from computations.matrices.blas import GEMM, SYMM, AXPY, SYRK
from computations.matrices.lapack import GESV, POSV, IPIV, LASWP, GESVLASWP
from computations.matrices.fftw import FFTW, IFFTW
from computations.matrices.blocks import Slice, Join
from computations.matrices.elemental import ElemProd
from computations.matrices.permutation import PermutationMatrix
from sympy.matrices.expressions import ZeroMatrix, HadamardProduct
from sympy.matrices.expressions.fourier import DFT

comp_to_comp = [
    (GEMM(alpha, A, B, beta, C), SYMM(alpha, A, B, beta, C), Q.symmetric(A) | Q.symmetric(B)),
    ]


# pattern is (source expression, target expression, wilds, condition)
blas = [
    (A*A.T, SYRK(1.0, A, 0.0, ZeroMatrix(A.rows, A.rows)), True),
    (A.T*A, SYRK(1.0, A.T, 0.0, ZeroMatrix(A.cols, A.cols)), True),
    (alpha*A*B + beta*C, SYMM(alpha, A, B, beta, C), SYMM.condition),
    (alpha*A*B + C, SYMM(alpha, A, B, 1.0, C), SYMM.condition),
    (A*B + beta*C, SYMM(1.0, A, B, beta, C), SYMM.condition),
    (A*B + C, SYMM(1.0, A, B, 1.0, C), SYMM.condition),
    (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),
开发者ID:mrocklin,项目名称:megatron,代码行数:32,代码来源:patterns.py

示例15: test_symmetric

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import symmetric [as 别名]
def test_symmetric():
    assert ask(Q.symmetric(X), Q.symmetric(X))
    assert ask(Q.symmetric(X*Z), Q.symmetric(X)) is None
    assert ask(Q.symmetric(X*Z), Q.symmetric(X) & Q.symmetric(Z)) is True
    assert ask(Q.symmetric(X+Z), Q.symmetric(X) & Q.symmetric(Z)) is True
    assert ask(Q.symmetric(Y)) is False
    assert ask(Q.symmetric(Y*Y.T)) is True
    assert ask(Q.symmetric(Y.T*X*Y)) is None
    assert ask(Q.symmetric(Y.T*X*Y), Q.symmetric(X)) is True
    assert ask(Q.symmetric(X*X*X*X*X*X*X*X*X*X), Q.symmetric(X)) is True
开发者ID:archipleago-creature,项目名称:sympy,代码行数:12,代码来源:test_matrices.py


注:本文中的sympy.Q.symmetric方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。