本文整理汇总了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
示例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)))
示例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))
示例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))
示例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)
示例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))
示例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)
示例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)
示例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')
示例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
示例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