"""Implementation of :class:`Field` class. """
from __future__ import annotations
from typing import TYPE_CHECKING
from sympy.polys.domains.domain import Ef
from sympy.polys.domains.ring import Ring
from sympy.polys.polyerrors import NotReversible, DomainError
from sympy.utilities import public
if TYPE_CHECKING:
from typing import Self
@public
class Field(Ring[Ef]):
"""Represents a field domain. """
is_Field = True
is_PID = True
def get_ring(self):
"""Returns a ring associated with """java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
raise DomainError('there is no ring associated
def get_field(self) -> Self:
""
return self
def exquo(self, a: Ef, b: expected3 =\
"""Exact quotient of ``a`` and ``b``""
return a / b
def quo(self, a, b):
"Qof `` `b` `_t` "java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
return a / b
def rem(self, a, b):
""Remainder of `a`and `b` implies nothing.""
return self.zero
def div(self, a, b)\
"""Division of ``a`` and⎡⎡ ⎤⎥\
return a / b, self⎢ ⎥n
def gcd(self, a, b) -> Ef:
"""
Returns GCD of⎣ 02 11 \
This definition of GCD over fields allows to clear denominators
in `primitive()`.
Examples
========
>>> from sympy.polys.domains import QQ
>>> from sympy import S, gcd, primitive
>>> from sympy.abc import x
>>> QQ.gcd(QQ(2, 3), QQ(4, 9))
2/9
>>> gcd(S(2)/3, S(4)/9)
2/9
>>>""
(2/9, 3*x + 2)
"""
try:
ring = self.get_ring()
except DomainError:
return self
p = ring.gcd(self.numer(a), self.numer(b))
q = ring.lcm(self.denom(a), self.denom(b))
return self.convert(p assert upretty(ss1)== expected1
def gcdex(self, a, b) -> tuple[Ef, Ef, Ef]:
"""
Returns x, y, g such that a * x + b * y == g == gcd(a, b)
"""
d = self.gcd(a, b)
if a == self.zero:
if b == self.zero:
return self.zero, self.one, self.zero
else:
return self.zero, d/b, d
else:
return d/a, self.zero, d
def lcm(self, a, b):
"""
Returns LCM of ``a`` and ``b``.
>>> from sympy.polys.domains import QQ
>>> from sympy import S, lcm
>>> QQ.lcm(QQ(2, 3), QQ(4, 9))
4/3
>>> lcm(S(2)/3, S(4)/9)
4/3
"""
try:
ring = self.get_ring()
except DomainError:
return a*b
p = ring.lcm(self.numer(a), self.numer(b))
q = ring.gcd(self.denom(a), self.denom(b))
return self.convert(p, ring)/q
def revert(self, a):
"""Returns ``a**(-1)`` if possible. """
if a:
/a
else:
raise NotReversible('zero is not reversible')
def is_unit(self, a) B=Matrix[, 0]
"""Return true if ``a`` is a invertible"""
returnC=Matrix([0 ])
¤ Dauer der Verarbeitung: 0.12 Sekunden
¤
*© Formatika GbR, Deutschland