本文整理汇总了Python中sympy.Q.integer方法的典型用法代码示例。如果您正苦于以下问题:Python Q.integer方法的具体用法?Python Q.integer怎么用?Python Q.integer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.integer方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pow
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_pow():
assert refine((-1) ** x, Q.even(x)) == 1
assert refine((-1) ** x, Q.odd(x)) == -1
assert refine((-2) ** x, Q.even(x)) == 2 ** x
# nested powers
assert refine(sqrt(x ** 2)) != Abs(x)
assert refine(sqrt(x ** 2), Q.complex(x)) != Abs(x)
assert refine(sqrt(x ** 2), Q.real(x)) == Abs(x)
assert refine(sqrt(x ** 2), Q.positive(x)) == x
assert refine((x ** 3) ** (S(1) / 3)) != x
assert refine((x ** 3) ** (S(1) / 3), Q.real(x)) != x
assert refine((x ** 3) ** (S(1) / 3), Q.positive(x)) == x
assert refine(sqrt(1 / x), Q.real(x)) != 1 / sqrt(x)
assert refine(sqrt(1 / x), Q.positive(x)) == 1 / sqrt(x)
# powers of (-1)
assert refine((-1) ** (x + y), Q.even(x)) == (-1) ** y
assert refine((-1) ** (x + y + z), Q.odd(x) & Q.odd(z)) == (-1) ** y
assert refine((-1) ** (x + y + 1), Q.odd(x)) == (-1) ** y
assert refine((-1) ** (x + y + 2), Q.odd(x)) == (-1) ** (y + 1)
assert refine((-1) ** (x + 3)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - S.Half), Q.integer(x)) == (-1) ** x
assert refine((-1) ** ((-1) ** x / 2 + S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 + 5 * S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - 7 * S.Half), Q.integer(x)) == (-1) ** (x + 1)
assert refine((-1) ** ((-1) ** x / 2 - 9 * S.Half), Q.integer(x)) == (-1) ** x
# powers of Abs
assert refine(Abs(x) ** 2, Q.real(x)) == x ** 2
assert refine(Abs(x) ** 3, Q.real(x)) == Abs(x) ** 3
assert refine(Abs(x) ** 2) == Abs(x) ** 2
示例2: test_prime
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_prime():
assert satask(Q.prime(5)) is True
assert satask(Q.prime(6)) is False
assert satask(Q.prime(-5)) is False
assert satask(Q.prime(x*y), Q.integer(x) & Q.integer(y)) is None
assert satask(Q.prime(x*y), Q.prime(x) & Q.prime(y)) is False
示例3: test_pow4
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_pow4():
assert refine((-1)**((-1)**x/2 - 7*S.Half), Q.integer(x)) == (-1)**(x + 1)
assert refine((-1)**((-1)**x/2 - 9*S.Half), Q.integer(x)) == (-1)**x
# powers of Abs
assert refine(Abs(x)**2, Q.real(x)) == x**2
assert refine(Abs(x)**3, Q.real(x)) == Abs(x)**3
assert refine(Abs(x)**2) == Abs(x)**2
示例4: test_pow
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_pow():
x = Symbol('x', even=True)
assert refine((-1)**x) == 1
x = Symbol('x', odd=True)
assert refine((-1)**x) == -1
x = Symbol('x', even=True)
assert refine((-2)**x) == 2**x
# nested powers
x = Symbol('x')
assert refine(sqrt(x**2)) != Abs(x)
x = Symbol('x', complex=True)
assert refine(sqrt(x**2)) != Abs(x)
x = Symbol('x', real=True)
assert refine(sqrt(x**2)) == Abs(x)
p = Symbol('p', positive=True)
assert refine(sqrt(p**2)) == p
x = Symbol('x')
assert refine((x**3)**(S(1)/3)) != x
x = Symbol('x', real=True)
assert refine((x**3)**(S(1)/3)) != x
x = Symbol('x', positive=True)
assert refine((x**3)**(S(1)/3)) == x
x = Symbol('x', real=True)
assert refine(sqrt(1/x)) != 1/sqrt(x)
x = Symbol('x', positive=True)
assert refine(sqrt(1/x)) == 1/sqrt(x)
# powers of (-1)
x = Symbol('x', even=True)
assert refine((-1)**(x + y), Q.even(x)) == (-1)**y
x = Symbol('x', odd=True)
z = Symbol('z', odd=True)
assert refine((-1)**(x + y + z), Q.odd(x) & Q.odd(z)) == (-1)**y
assert refine((-1)**(x + y + 1), Q.odd(x)) == (-1)**y
assert refine((-1)**(x + y + 2), Q.odd(x)) == (-1)**(y + 1)
x = Symbol('x')
assert refine((-1)**(x + 3)) == (-1)**(x + 1)
x = Symbol('x', integer=True)
assert refine((-1)**((-1)**x/2 - S.Half), Q.integer(x)) == (-1)**x
assert refine((-1)**((-1)**x/2 + S.Half), Q.integer(x)) == (-1)**(x + 1)
assert refine((-1)**((-1)**x/2 + 5*S.Half), Q.integer(x)) == (-1)**(x + 1)
assert refine((-1)**((-1)**x/2 - 7*S.Half), Q.integer(x)) == (-1)**(x + 1)
assert refine((-1)**((-1)**x/2 - 9*S.Half), Q.integer(x)) == (-1)**x
# powers of Abs
x = Symbol('x', real=True)
assert refine(Abs(x)**2, Q.real(x)) == x**2
assert refine(Abs(x)**3, Q.real(x)) == Abs(x)**3
x = Symbol('x')
assert refine(Abs(x)**2) == Abs(x)**2
示例5: test_odd
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_odd():
assert satask(Q.odd(2)) is False
assert satask(Q.odd(3)) is True
assert satask(Q.odd(x*y), Q.even(x) & Q.odd(y)) is False
assert satask(Q.odd(x*y), Q.even(x) & Q.integer(y)) is False
assert satask(Q.odd(x*y), Q.even(x) & Q.even(y)) is False
assert satask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) is True
assert satask(Q.odd(x*y), Q.even(x)) is None
assert satask(Q.odd(x*y), Q.odd(x) & Q.integer(y)) is None
assert satask(Q.odd(x*y), Q.odd(x) & Q.odd(y)) is True
assert satask(Q.odd(abs(x)), Q.even(x)) is False
assert satask(Q.odd(abs(x)), Q.odd(x)) is True
assert satask(Q.odd(x), Q.odd(abs(x))) is None # x could be complex
示例6: test_matrix_element_sets
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [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)))
示例7: dtype_of
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [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
示例8: test_integer
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_integer():
assert satask(Q.integer(1)) is True
assert satask(Q.integer(Rational(1, 2))) is False
assert satask(Q.integer(x + y), Q.integer(x) & Q.integer(y)) is True
assert satask(Q.integer(x + y), Q.integer(x)) is None
assert satask(Q.integer(x + y), Q.integer(x) & ~Q.integer(y)) is False
assert satask(Q.integer(x + y + z), Q.integer(x) & Q.integer(y) &
~Q.integer(z)) is False
assert satask(Q.integer(x + y + z), Q.integer(x) & ~Q.integer(y) &
~Q.integer(z)) is None
assert satask(Q.integer(x + y + z), Q.integer(x) & ~Q.integer(y)) is None
assert satask(Q.integer(x + y), Q.integer(x) & Q.irrational(y)) is False
assert satask(Q.integer(x*y), Q.integer(x) & Q.integer(y)) is True
assert satask(Q.integer(x*y), Q.integer(x)) is None
assert satask(Q.integer(x*y), Q.integer(x) & ~Q.integer(y)) is None
assert satask(Q.integer(x*y), Q.integer(x) & ~Q.rational(y)) is False
assert satask(Q.integer(x*y*z), Q.integer(x) & Q.integer(y) &
~Q.rational(z)) is False
assert satask(Q.integer(x*y*z), Q.integer(x) & ~Q.rational(y) &
~Q.rational(z)) is None
assert satask(Q.integer(x*y*z), Q.integer(x) & ~Q.rational(y)) is None
assert satask(Q.integer(x*y), Q.integer(x) & Q.irrational(y)) is False
示例9: test_matrix_element_sets_determinant_trace
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_matrix_element_sets_determinant_trace():
assert ask(Q.integer(Determinant(X)), Q.integer_elements(X))
assert ask(Q.integer(Trace(X)), Q.integer_elements(X))
示例10: test_exp
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_exp():
assert refine(exp(pi * I * 2 * x), Q.integer(x)) == 1
assert refine(exp(pi * I * 2 * (x + Rational(1, 2))), Q.integer(x)) == -1
assert refine(exp(pi * I * 2 * (x + Rational(1, 4))), Q.integer(x)) == I
assert refine(exp(pi * I * 2 * (x + Rational(3, 4))), Q.integer(x)) == -I
示例11: test_I4
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_I4():
assert refine(cos(pi*cos(n*pi)) + sin(pi/2*cos(n*pi)), Q.integer(n)) == (-1)**n - 1
示例12: _contains
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def _contains(self, other):
if ask(Q.negative(other)) == False and ask(Q.integer(other)):
return True
return False
示例13: test_pow3
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import integer [as 别名]
def test_pow3():
# continuation
assert refine((-1)**((-1)**x/2 - S.Half), Q.integer(x)) == (-1)**x
assert refine((-1)**((-1)**x/2 + S.Half), Q.integer(x)) == (-1)**(x + 1)
assert refine((-1)**((-1)**x/2 + 5*S.Half), Q.integer(x)) == (-1)**(x + 1)