arctans.numbers =============== .. py:module:: arctans.numbers .. autoapi-nested-parse:: Numbers. Attributes ---------- .. autoapisummary:: arctans.numbers.j arctans.numbers.zero arctans.numbers.one Classes ------- .. autoapisummary:: arctans.numbers.AbstractNumber arctans.numbers.RealNumber arctans.numbers.Integer arctans.numbers.Rational arctans.numbers.GaussianInteger arctans.numbers.GaussianRational Functions --------- .. autoapisummary:: arctans.numbers._simplify_type arctans.numbers._as_common_type Module Contents --------------- .. py:class:: AbstractNumber Bases: :py:obj:`arctans.core.Representable` Base class for number. .. py:property:: real :type: RealNumber :abstractmethod: Real part. .. py:property:: imag :type: RealNumber :abstractmethod: Imaginary part. .. py:property:: numerator :type: AbstractNumber :abstractmethod: Numerator. .. py:property:: denominator :type: Integer :abstractmethod: Denominator. .. py:method:: conjugate() -> AbstractNumber :abstractmethod: Compute the complex conjugate. .. py:method:: __int__() -> int :abstractmethod: .. py:method:: __float__() -> float :abstractmethod: .. py:method:: __complex__() -> complex :abstractmethod: .. py:method:: _to_same_type(other: Any) -> Self :abstractmethod: Convert other to the same type as self. .. py:method:: _add(other: Self) -> AbstractNumber :abstractmethod: Add something of the same type to this. .. py:method:: _sub(other: Self) -> AbstractNumber :abstractmethod: Subtract something of the same type from this. .. py:method:: _mul(other: Self) -> AbstractNumber :abstractmethod: Multiply something of the same type by this. .. py:method:: _truediv(other: Self) -> AbstractNumber :abstractmethod: Divide this by something of the same type. .. py:method:: _mod(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _floordiv(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _eq(other: Self) -> bool :abstractmethod: Check if something of the same type is equal to this. .. py:method:: _pow(other: int) -> AbstractNumber Raise to an integer power. .. py:method:: __add__(other: Any) .. py:method:: __radd__(other: Any) .. py:method:: __sub__(other: Any) .. py:method:: __rsub__(other: Any) .. py:method:: __mul__(other: Any) .. py:method:: __rmul__(other: Any) .. py:method:: __neg__() .. py:method:: __truediv__(other: Any) .. py:method:: __rtruediv__(other: Any) .. py:method:: __mod__(other: Any) .. py:method:: __rmod__(other: Any) .. py:method:: __floordiv__(other: Any) .. py:method:: __rfloordiv__(other: Any) .. py:method:: __eq__(other) -> bool .. py:method:: __pow__(other) .. py:method:: __rpow__(other) .. py:method:: __iadd__(other) .. py:method:: __isub__(other) .. py:method:: __imul__(other) .. py:method:: __abs__() .. py:method:: __hash__() .. py:class:: RealNumber Bases: :py:obj:`AbstractNumber` A real number. .. py:property:: real :type: RealNumber Real part. .. py:property:: imag :type: RealNumber Imaginary part. .. py:method:: conjugate() -> AbstractNumber Compute the complex conjugate. .. py:method:: __lt__(other) -> bool .. py:method:: __le__(other) -> bool .. py:method:: __gt__(other) -> bool .. py:method:: __ge__(other) -> bool .. py:class:: Integer(i: int) Bases: :py:obj:`RealNumber` An integer. .. py:attribute:: _i .. py:method:: __str__() .. py:method:: __repr__() .. py:method:: as_latex() -> str Represent in LaTeX. .. py:property:: numerator :type: AbstractNumber Numerator. .. py:property:: denominator :type: Integer Denominator. .. py:method:: __int__() -> int .. py:method:: __float__() -> float .. py:method:: __complex__() -> complex .. py:method:: _to_same_type(other: Any) -> Integer Convert other to the same type as self. .. py:method:: _add(other: Self) -> AbstractNumber Add something of the same type to this. .. py:method:: _sub(other: Self) -> AbstractNumber Subtract something of the same type from this. .. py:method:: _mul(other: Self) -> AbstractNumber Multiply something of the same type by this. .. py:method:: _truediv(other: Self) -> AbstractNumber Divide this by something of the same type. .. py:method:: _pow(other: int) -> AbstractNumber Raise to an integer power. .. py:method:: _mod(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _floordiv(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _eq(other: Self) -> bool Check if something of the same type is equal to this. .. py:method:: __abs__() .. py:method:: __hash__() .. py:class:: Rational(numerator: int, denominator: int) Bases: :py:obj:`RealNumber` A rational number. .. py:attribute:: _num .. py:attribute:: _den .. py:method:: as_latex() -> str Represent in LaTeX. .. py:method:: __str__() .. py:method:: __repr__() .. py:property:: numerator :type: AbstractNumber Numerator. .. py:property:: denominator :type: Integer Denominator. .. py:method:: __int__() -> int .. py:method:: __float__() -> float .. py:method:: __complex__() -> complex .. py:method:: _to_same_type(other: Any) -> Rational Convert other to the same type as self. .. py:method:: _add(other: Self) -> AbstractNumber Add something of the same type to this. .. py:method:: _sub(other: Self) -> AbstractNumber Subtract something of the same type from this. .. py:method:: _mul(other: Self) -> AbstractNumber Multiply something of the same type by this. .. py:method:: _truediv(other: Self) -> AbstractNumber Divide this by something of the same type. .. py:method:: _pow(other: int) -> AbstractNumber Raise to an integer power. .. py:method:: _eq(other: Self) -> bool Check if something of the same type is equal to this. .. py:method:: __abs__() .. py:class:: GaussianInteger(re: int, im: int) Bases: :py:obj:`AbstractNumber` A Gaussian integer. .. py:attribute:: _re .. py:attribute:: _im .. py:method:: __str__() .. py:method:: __repr__() .. py:property:: real :type: RealNumber Real part. .. py:property:: imag :type: RealNumber Imaginary part. .. py:method:: conjugate() -> AbstractNumber Compute the complex conjugate. .. py:method:: as_latex() -> str Represent in LaTeX. .. py:property:: numerator :type: AbstractNumber Numerator. .. py:property:: denominator :type: Integer Denominator. .. py:method:: __int__() -> int .. py:method:: __float__() -> float .. py:method:: __complex__() -> complex .. py:method:: _to_same_type(other: Any) -> GaussianInteger Convert other to the same type as self. .. py:method:: _add(other: Self) -> AbstractNumber Add something of the same type to this. .. py:method:: _sub(other: Self) -> AbstractNumber Subtract something of the same type from this. .. py:method:: _mul(other: Self) -> AbstractNumber Multiply something of the same type by this. .. py:method:: _truediv(other: Self) -> AbstractNumber Divide this by something of the same type. .. py:method:: _mod(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _floordiv(other: Self) -> AbstractNumber Find the remainder when dividing this by something of the same type. .. py:method:: _eq(other: Self) -> bool Check if something of the same type is equal to this. .. py:class:: GaussianRational(re_numerator: int, re_denominator, im_numerator: int, im_denominator: int) Bases: :py:obj:`AbstractNumber` A Gaussian rational. .. py:attribute:: _re_num .. py:attribute:: _re_den .. py:attribute:: _im_num .. py:attribute:: _im_den .. py:method:: __str__() .. py:method:: __repr__() .. py:property:: real :type: RealNumber Real part. .. py:property:: imag :type: RealNumber Imaginary part. .. py:method:: as_latex() -> str Represent in LaTeX. .. py:method:: conjugate() -> AbstractNumber Compute the complex conjugate. .. py:property:: numerator :type: AbstractNumber Numerator. .. py:property:: denominator :type: Integer Denominator. .. py:method:: __int__() -> int .. py:method:: __float__() -> float .. py:method:: __complex__() -> complex .. py:method:: _to_same_type(other: Any) -> GaussianRational Convert other to the same type as self. .. py:method:: _add(other: Self) -> AbstractNumber Add something of the same type to this. .. py:method:: _sub(other: Self) -> AbstractNumber Subtract something of the same type from this. .. py:method:: _mul(other: Self) -> AbstractNumber Multiply something of the same type by this. .. py:method:: _truediv(other: Self) -> AbstractNumber Divide this by something of the same type. .. py:method:: _eq(other: Self) -> bool Check if something of the same type is equal to this. .. py:function:: _simplify_type(i: AbstractNumber) -> AbstractNumber Convert i to a simpler type if possible. .. py:function:: _as_common_type(a: AbstractNumber, b: Any) -> tuple[AbstractNumber, AbstractNumber] Convert a and b to the same type. .. py:data:: j .. py:data:: zero .. py:data:: one