Skip to content

Commit

Permalink
Check if it's a totally real number field
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Mar 6, 2018
1 parent 5446083 commit e8537fe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions diofant/core/numbers.py
Expand Up @@ -1854,6 +1854,9 @@ def __new__(cls, expr, coeffs=(1, 0), alias=None, **kwargs):

return obj

def _eval_is_real(self):
return self.root.is_real

@property
def free_symbols(self):
return set()
Expand Down
4 changes: 4 additions & 0 deletions diofant/domains/algebraicfield.py
Expand Up @@ -127,6 +127,10 @@ def is_nonnegative(self, a):
"""Returns True if ``a`` is non-negative. """
return self.domain.is_nonnegative(a.LC())

@property
def is_real(self):
return self.ext.is_real


class AlgebraicElement(DomainElement, CantSympify):
"""Dense Algebraic Number Polynomials over a field. """
Expand Down
5 changes: 5 additions & 0 deletions diofant/domains/tests/test_domains.py
Expand Up @@ -676,6 +676,11 @@ def test_Domain__algebraic_field():

assert alg.characteristic() == 0

assert alg.is_real is True

alg = QQ.algebraic_field(I)
assert alg.is_real is False


def test_PolynomialRing_from_FractionField():
F, x, y = field("x,y", ZZ)
Expand Down

0 comments on commit e8537fe

Please sign in to comment.