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


Python Q.complex_elements方法代码示例

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


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

示例1: test_field_assumptions

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_field_assumptions():
    X = MatrixSymbol('X', 4, 4)
    Y = MatrixSymbol('Y', 4, 4)
    assert ask(Q.real_elements(X), Q.real_elements(X))
    assert not ask(Q.integer_elements(X), Q.real_elements(X))
    assert ask(Q.complex_elements(X), Q.real_elements(X))
    assert ask(Q.complex_elements(X**2), Q.real_elements(X))
    assert ask(Q.real_elements(X**2), Q.integer_elements(X))
    assert ask(Q.real_elements(X+Y), Q.real_elements(X)) is None
    assert ask(Q.real_elements(X+Y), Q.real_elements(X) & Q.real_elements(Y))
    from sympy.matrices.expressions.hadamard import HadamardProduct
    assert ask(Q.real_elements(HadamardProduct(X, Y)),
                    Q.real_elements(X) & Q.real_elements(Y))
    assert ask(Q.complex_elements(X+Y), Q.real_elements(X) & Q.complex_elements(Y))

    assert ask(Q.real_elements(X.T), Q.real_elements(X))
    assert ask(Q.real_elements(X.I), Q.real_elements(X) & Q.invertible(X))
    assert ask(Q.real_elements(Trace(X)), Q.real_elements(X))
    assert ask(Q.integer_elements(Determinant(X)), Q.integer_elements(X))
    assert not ask(Q.integer_elements(X.I), Q.integer_elements(X))
    alpha = Symbol('alpha')
    assert ask(Q.real_elements(alpha*X), Q.real_elements(X) & Q.real(alpha))
    assert ask(Q.real_elements(LofLU(X)), Q.real_elements(X))
    e = Symbol('e', integer=True, negative=True)
    assert ask(Q.real_elements(X**e), Q.real_elements(X) & Q.invertible(X))
    assert ask(Q.real_elements(X**e), Q.real_elements(X)) is None
开发者ID:asmeurer,项目名称:sympy,代码行数:28,代码来源:test_matrices.py

示例2: test_matrix_element_sets

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_matrix_element_sets():
    X = MatrixSymbol('X', 4, 4)
    assert ask(Q.real(X[1, 2]), Q.real_elements(X))
    assert ask(Q.integer(X[1, 2]), Q.integer_elements(X))
    assert ask(Q.complex(X[1, 2]), Q.complex_elements(X))
    assert ask(Q.integer_elements(Identity(3)))
    assert ask(Q.integer_elements(ZeroMatrix(3, 3)))
    from sympy.matrices.expressions.fourier import DFT
    assert ask(Q.complex_elements(DFT(3)))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:11,代码来源:test_matrices.py

示例3: test_field_assumptions

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_field_assumptions():
    X = MatrixSymbol('X', 4, 4)
    Y = MatrixSymbol('Y', 4, 4)
    assert ask(Q.real_elements(X), Q.real_elements(X))
    assert not ask(Q.integer_elements(X), Q.real_elements(X))
    assert ask(Q.complex_elements(X), Q.real_elements(X))
    assert ask(Q.real_elements(X+Y), Q.real_elements(X)) is None
    assert ask(Q.real_elements(X+Y), Q.real_elements(X) & Q.real_elements(Y))
    assert ask(Q.complex_elements(X+Y), Q.real_elements(X) & Q.complex_elements(Y))

    assert ask(Q.real_elements(X.T), Q.real_elements(X))
    assert ask(Q.real_elements(X.I), Q.real_elements(X) & Q.invertible(X))
    assert ask(Q.real_elements(Trace(X)), Q.real_elements(X))
    assert ask(Q.integer_elements(Determinant(X)), Q.integer_elements(X))
    assert not ask(Q.integer_elements(X.I), Q.integer_elements(X))
开发者ID:mikepcoke,项目名称:sympy,代码行数:17,代码来源:test_matrices.py

示例4: test_assumptions

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_assumptions():
    n = Symbol('n')
    A = MatrixSymbol('A', 1, n)
    P = PermutationMatrix(A)
    assert ask(Q.integer_elements(P))
    assert ask(Q.real_elements(P))
    assert ask(Q.complex_elements(P))
开发者ID:mrocklin,项目名称:computations,代码行数:9,代码来源:test_permutation.py

示例5: test_dtype_of

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_dtype_of():
    X = MatrixSymbol('X', n, n)
    assert 'integer' in dtype_of(X, Q.integer_elements(X))
    assert 'real' in dtype_of(X, Q.real_elements(X))
    assert 'complex' in dtype_of(X, Q.complex_elements(X))

    alpha = Symbol('alpha', integer=True)
    assert 'integer' in dtype_of(alpha)
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_core.py

示例6: test_field_assumptions

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_field_assumptions():
    X = MatrixSymbol('X', 4, 4)
    Y = MatrixSymbol('Y', 4, 4)
    assert ask(Q.real_elements(X), Q.real_elements(X))
    assert not ask(Q.integer_elements(X), Q.real_elements(X))
    assert ask(Q.complex_elements(X), Q.real_elements(X))
    assert ask(Q.real_elements(X+Y), Q.real_elements(X)) is None
    assert ask(Q.real_elements(X+Y), Q.real_elements(X) & Q.real_elements(Y))
    from sympy.matrices.expressions.hadamard import HadamardProduct
    assert ask(Q.real_elements(HadamardProduct(X, Y)),
                    Q.real_elements(X) & Q.real_elements(Y))
    assert ask(Q.complex_elements(X+Y), Q.real_elements(X) & Q.complex_elements(Y))

    assert ask(Q.real_elements(X.T), Q.real_elements(X))
    assert ask(Q.real_elements(X.I), Q.real_elements(X) & Q.invertible(X))
    assert ask(Q.real_elements(Trace(X)), Q.real_elements(X))
    assert ask(Q.integer_elements(Determinant(X)), Q.integer_elements(X))
    assert not ask(Q.integer_elements(X.I), Q.integer_elements(X))
开发者ID:Maihj,项目名称:sympy,代码行数:20,代码来源:test_matrices.py

示例7: test_fftw

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_fftw():
    c = FFTW(y)
    with assuming(Q.complex_elements(y)):
        f = build(c, [y], [DFT(y)], modname='fftw', filename='tmp/fftw.f90')

    x = np.zeros(8, dtype='complex')
    expected = np.fft.fft(x)
    f(x)
    assert np.allclose(expected, x)
开发者ID:mrocklin,项目名称:computations,代码行数:11,代码来源:test_integrative.py

示例8: test_code_generation

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_code_generation():
    from computations.matrices.fortran.core import generate
    ic = inplace_compile(c)
    with assuming(Q.complex_elements(x)):
        s = generate(ic, [x], [DFT(n)*x])
    with open('tmp/tmpfftw.f90','w') as f:
      f.write(s)
    assert 'use, intrinsic :: iso_c_binding' in s
    assert "include 'fftw3.f03'" in s
    assert isinstance(s, str)
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_fftw.py

示例9: test_es_toy

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_es_toy():
    K = MatrixSymbol('K',n,1)
    phi = MatrixSymbol('phi', n, 1)
    V = MatrixSymbol('V',n,1)

    c = AXPY(1.0, HP(K,phi), DFT(n).T*HP(V,DFT(n)*phi)) + ElemProd(K,phi) + IFFTW(HP(V, DFT(n) * phi)) + FFTW(phi) + ElemProd(V, DFT(n) * phi)
#    show(c)
    with assuming(Q.complex_elements(phi), Q.real_elements(K), Q.real_elements(V)):
        f = build(c, [K,V,phi], [HP(K,phi) + DFT(n).T * HP(V,DFT(n) * phi)],
                modname='es', filename='tmp/es.f90')
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_integrative.py

示例10: dtype_of

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def dtype_of(expr, *assumptions):
    if hasattr(expr, 'fortran_type'):
        return expr.fortran_type()

    with assuming(*assumptions):
        if ask(Q.integer(expr) | Q.integer_elements(expr)) or expr.is_integer:
            result = 'integer'
        elif ask(Q.real(expr) | Q.real_elements(expr)) or expr.is_real:
            result = 'real(kind=8)'
        elif ask(Q.complex(expr) | Q.complex_elements(expr)) or expr.is_complex:
            result = 'complex(kind=8)'
        else:
            raise TypeError('Could not infer type of %s'%str(expr))
    return result
开发者ID:mrocklin,项目名称:computations,代码行数:16,代码来源:core.py

示例11: test_compile

# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import complex_elements [as 别名]
def test_compile():
    with assuming(Q.complex_elements(phi), Q.real_elements(K), Q.real_elements(V)):
      result = compile([K,V,phi], [Hphi])
    print result 
开发者ID:mrocklin,项目名称:megatron,代码行数:6,代码来源:test_estoy.py


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