NZMATH
1.2.0
About: NZMATH is a Python based number theory oriented calculation system.
![]() ![]() |
Public Member Functions | |
def | __init__ (self, numerator, denominator=1) |
def | __add__ (self, other) |
def | __sub__ (self, other) |
def | __mul__ (self, other) |
def | __truediv__ (self, other) |
def | __radd__ (self, other) |
def | __rsub__ (self, other) |
def | __rmul__ (self, other) |
def | __rtruediv__ (self, other) |
def | __pow__ (self, index) |
def | __lt__ (self, other) |
def | __le__ (self, other) |
def | __eq__ (self, other) |
def | __ne__ (self, other) |
def | __gt__ (self, other) |
def | __ge__ (self, other) |
def | __pos__ (self) |
def | __neg__ (self) |
def | __abs__ (self) |
def | __long__ (self) |
def | __str__ (self) |
def | __repr__ (self) |
def | __nonzero__ (self) |
def | __hash__ (self) |
def | expand (self, base, limit) |
def | trim (self, max_denominator) |
def | compare (self, other) |
def | getRing (self) |
def | __float__ (self) |
def | toFloat (self) |
def | decimalString (self, N) |
![]() | |
def | inverse (self) |
![]() | |
def | __init__ (self) |
def | exact_division (self, other) |
![]() | |
def | mul_module_action (self, other) |
![]() | |
def | __init__ (self, *args, **kwd) |
Public Attributes | |
denominator | |
numerator | |
![]() | |
numerator | |
denominator | |
Private Member Functions | |
def | _reduce (self) |
def | _init_by_Rational_Rational (self, numerator, denominator) |
def | _init_by_float_Rational (self, numerator, denominator) |
def | _init_by_int_Rational (self, numerator, denominator) |
def | _init_by_Rational_float (self, numerator, denominator) |
def | _init_by_float_float (self, numerator, denominator) |
def | _init_by_int_float (self, numerator, denominator) |
def | _init_by_Rational_int (self, numerator, denominator) |
def | _init_by_float_int (self, numerator, denominator) |
def | _init_by_int_int (self, numerator, denominator) |
Static Private Attributes | |
def | __div__ = __truediv__ |
def | __floordiv__ = __truediv__ |
def | __rdiv__ = __rtruediv__ |
def | __rfloordiv__ = __rtruediv__ |
def | __int__ = __long__ |
Rational is the class of rational numbers.
Definition at line 10 of file rational.py.
def nzmath.rational.Rational.__init__ | ( | self, | |
numerator, | |||
denominator = 1 |
|||
) |
Create a rational from: * integers, * float, or * Rational. Other objects can be converted if they have toRational methods. Otherwise raise TypeError.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 15 of file rational.py.
References nzmath.rational.continued_fraction_expansion().
def nzmath.rational.Rational.__abs__ | ( | self | ) |
Definition at line 302 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__add__ | ( | self, | |
other | |||
) |
self + other If other is a rational or an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 68 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__eq__ | ( | self, | |
other | |||
) |
Equality test.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 270 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.isIntegerObject().
Referenced by nzmath.ring.Ring.__ne__(), nzmath.real.RealField.__ne__(), and nzmath.ring.Ideal.__ne__().
def nzmath.rational.Rational.__float__ | ( | self | ) |
Definition at line 417 of file rational.py.
References nzmath.rational.Rational.decimalString().
def nzmath.rational.Rational.__ge__ | ( | self, | |
other | |||
) |
Definition at line 289 of file rational.py.
References nzmath.rational.Rational.compare().
def nzmath.rational.Rational.__gt__ | ( | self, | |
other | |||
) |
Definition at line 286 of file rational.py.
References nzmath.rational.Rational.compare().
def nzmath.rational.Rational.__hash__ | ( | self | ) |
a==b => hash(a)==hash(b)
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 322 of file rational.py.
References nzmath.matrix.Matrix.__class__, nzmath.matrix.RingMatrix.__class__, nzmath.matrix.RingSquareMatrix.__class__, nzmath.matrix.FieldMatrix.__class__, nzmath.matrix.MatrixRing.__class__, nzmath.matrix.Subspace.__class__, nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__le__ | ( | self, | |
other | |||
) |
Definition at line 267 of file rational.py.
References nzmath.rational.Rational.compare().
def nzmath.rational.Rational.__long__ | ( | self | ) |
Definition at line 305 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__lt__ | ( | self, | |
other | |||
) |
Definition at line 264 of file rational.py.
References nzmath.rational.Rational.compare().
def nzmath.rational.Rational.__mul__ | ( | self, | |
other | |||
) |
self * other If other is a rational or an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 116 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__ne__ | ( | self, | |
other | |||
) |
Inequality test.
Reimplemented from nzmath.ring.RingElement.
Definition at line 283 of file rational.py.
References nzmath.rational.Rational.compare().
def nzmath.rational.Rational.__neg__ | ( | self | ) |
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 299 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__nonzero__ | ( | self | ) |
Definition at line 316 of file rational.py.
References nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__pos__ | ( | self | ) |
Definition at line 292 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__pow__ | ( | self, | |
index | |||
) |
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 253 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__radd__ | ( | self, | |
other | |||
) |
other + self If other is an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Definition at line 171 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__repr__ | ( | self | ) |
Definition at line 313 of file rational.py.
References nzmath.matrix.Matrix.__class__, nzmath.matrix.RingMatrix.__class__, nzmath.matrix.RingSquareMatrix.__class__, nzmath.matrix.FieldMatrix.__class__, nzmath.matrix.MatrixRing.__class__, nzmath.matrix.Subspace.__class__, nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__rmul__ | ( | self, | |
other | |||
) |
other * self If other is an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Definition at line 209 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__rsub__ | ( | self, | |
other | |||
) |
other - self If other is an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 190 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__rtruediv__ | ( | self, | |
other | |||
) |
other / self other // self If other is an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 228 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__str__ | ( | self | ) |
Definition at line 310 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.__sub__ | ( | self, | |
other | |||
) |
self - other If other is a rational or an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 92 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
def nzmath.rational.Rational.__truediv__ | ( | self, | |
other | |||
) |
self / other self // other If other is a rational or an integer, the result will be a rational. If other is a kind of float the result is an instance of other's type. Otherwise, other would do the computation.
Reimplemented from nzmath.ring.QuotientFieldElement.
Definition at line 140 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
|
private |
Initialize by a float numbers.
Definition at line 474 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initialize by a float number and an integer.
Definition at line 500 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initialize by a float number and a rational number.
Definition at line 449 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initailize by an integer and a float
Definition at line 484 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initailize by an integers.
Definition at line 509 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initailize by an integer and a rational number.
Definition at line 458 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initialize by a rational number and a float.
Definition at line 465 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initialize by a rational number and integer.
Definition at line 493 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Initialize by a rational numbers.
Definition at line 442 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
|
private |
Definition at line 409 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
def nzmath.rational.Rational.compare | ( | self, | |
other | |||
) |
Definition at line 397 of file rational.py.
References nzmath.compatibility.cmp, nzmath.rational.Rational.compare(), nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.toFloat().
Referenced by nzmath.rational.Rational.__ge__(), nzmath.rational.Rational.__gt__(), nzmath.rational.Rational.__le__(), nzmath.rational.Rational.__lt__(), nzmath.rational.Rational.__ne__(), and nzmath.rational.Rational.compare().
def nzmath.rational.Rational.decimalString | ( | self, | |
N | |||
) |
Return a string of the number to N decimal places.
Definition at line 423 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
Referenced by nzmath.rational.Rational.__float__().
def nzmath.rational.Rational.expand | ( | self, | |
base, | |||
limit | |||
) |
r.expand(k, limit) returns the nearest rational number whose denominator is a power of k and at most limit, if k > 0. if k==0, it returns the nearest rational number whose denominator is at most limit, i.e. r.expand(0, limit) == r.trim(limit).
Definition at line 334 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, nzmath.rational.isIntegerObject(), nzmath.rational.Rational.numerator, and nzmath.rational.Rational.trim().
def nzmath.rational.Rational.getRing | ( | self | ) |
getRing returns an object of a subclass of Ring, to which the element belongs.
Reimplemented from nzmath.ring.RingElement.
Definition at line 406 of file rational.py.
Referenced by nzmath.ring.QuotientFieldElement.__add__(), nzmath.ring.QuotientFieldElement.__eq__(), nzmath.ring.QuotientFieldElement.__rsub__(), nzmath.ring.QuotientFieldElement.__rtruediv__(), nzmath.ring.QuotientFieldElement.__sub__(), nzmath.ring.QuotientFieldElement.__truediv__(), nzmath.poly.uniutil.PrimeCharacteristicFunctionsProvider._small_index_mod_pow(), nzmath.ring.CommutativeRingElement.exact_division(), nzmath.poly.uniutil.DivisionProvider.extgcd(), nzmath.poly.uniutil.PrimeCharacteristicFunctionsProvider.factor(), nzmath.poly.uniutil.DivisionProvider.mod_pow(), nzmath.poly.uniutil.PrimeCharacteristicFunctionsProvider.mod_pow(), nzmath.poly.uniutil.PseudoDivisionProvider.monic_pow(), nzmath.ring.CommutativeRingElement.mul_module_action(), and nzmath.poly.uniutil.SubresultantGcdProvider.subresultant_gcd().
def nzmath.rational.Rational.toFloat | ( | self | ) |
Definition at line 420 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
Referenced by nzmath.rational.Rational.__add__(), nzmath.rational.Rational.__mul__(), nzmath.rational.Rational.__radd__(), nzmath.rational.Rational.__rmul__(), nzmath.rational.Rational.__rsub__(), nzmath.rational.Rational.__rtruediv__(), nzmath.rational.Rational.__sub__(), nzmath.rational.Rational.__truediv__(), and nzmath.rational.Rational.compare().
def nzmath.rational.Rational.trim | ( | self, | |
max_denominator | |||
) |
Definition at line 370 of file rational.py.
References nzmath.rational.Rational.denominator, nzmath.module.Module.denominator, and nzmath.rational.Rational.numerator.
Referenced by nzmath.rational.Rational.expand().
|
staticprivate |
Definition at line 168 of file rational.py.
|
staticprivate |
Definition at line 169 of file rational.py.
|
staticprivate |
Definition at line 308 of file rational.py.
|
staticprivate |
Definition at line 250 of file rational.py.
|
staticprivate |
Definition at line 251 of file rational.py.
nzmath.rational.Rational.denominator |
Definition at line 60 of file rational.py.
Referenced by nzmath.rational.Rational.__abs__(), nzmath.rational.Rational.__add__(), nzmath.ring.QuotientFieldElement.__add__(), nzmath.round2.ModuleWithDenominator.__add__(), nzmath.poly.ratfunc.RationalFunction.__call__(), nzmath.rational.Rational.__eq__(), nzmath.ring.QuotientFieldElement.__eq__(), nzmath.rational.Rational.__hash__(), nzmath.ring.QuotientFieldElement.__hash__(), nzmath.poly.ratfunc.RationalFunction.__init__(), nzmath.rational.Rational.__long__(), nzmath.rational.Rational.__mul__(), nzmath.ring.QuotientFieldElement.__mul__(), nzmath.round2.ModuleWithDenominator.__mul__(), nzmath.rational.Rational.__neg__(), nzmath.ring.QuotientFieldElement.__neg__(), nzmath.rational.Rational.__pos__(), nzmath.rational.Rational.__pow__(), nzmath.ring.QuotientFieldElement.__pow__(), nzmath.rational.Rational.__radd__(), nzmath.poly.ratfunc.RationalFunction.__repr__(), nzmath.rational.Rational.__repr__(), nzmath.rational.Rational.__rmul__(), nzmath.rational.Rational.__rsub__(), nzmath.ring.QuotientFieldElement.__rsub__(), nzmath.rational.Rational.__rtruediv__(), nzmath.ring.QuotientFieldElement.__rtruediv__(), nzmath.poly.ratfunc.RationalFunction.__str__(), nzmath.rational.Rational.__str__(), nzmath.rational.Rational.__sub__(), nzmath.ring.QuotientFieldElement.__sub__(), nzmath.rational.Rational.__truediv__(), nzmath.ring.QuotientFieldElement.__truediv__(), nzmath.round2.ModuleWithDenominator.__truediv__(), nzmath.rational.Rational._init_by_float_float(), nzmath.rational.Rational._init_by_float_int(), nzmath.rational.Rational._init_by_float_Rational(), nzmath.rational.Rational._init_by_int_float(), nzmath.rational.Rational._init_by_int_int(), nzmath.rational.Rational._init_by_int_Rational(), nzmath.rational.Rational._init_by_Rational_float(), nzmath.rational.Rational._init_by_Rational_int(), nzmath.rational.Rational._init_by_Rational_Rational(), nzmath.rational.Rational._reduce(), nzmath.rational.Rational.compare(), nzmath.rational.Rational.decimalString(), nzmath.round2.ModuleWithDenominator.determinant(), nzmath.rational.Rational.expand(), nzmath.round2.ModuleWithDenominator.get_polynomials(), nzmath.round2.ModuleWithDenominator.get_rationals(), nzmath.ring.QuotientFieldElement.inverse(), nzmath.rational.Rational.toFloat(), and nzmath.rational.Rational.trim().
nzmath.rational.Rational.numerator |
Definition at line 273 of file rational.py.
Referenced by nzmath.rational.Rational.__abs__(), nzmath.rational.Rational.__add__(), nzmath.ring.QuotientFieldElement.__add__(), nzmath.poly.ratfunc.RationalFunction.__call__(), nzmath.ring.QuotientFieldElement.__eq__(), nzmath.rational.Rational.__hash__(), nzmath.ring.QuotientFieldElement.__hash__(), nzmath.poly.ratfunc.RationalFunction.__init__(), nzmath.rational.Rational.__long__(), nzmath.rational.Rational.__mul__(), nzmath.ring.QuotientFieldElement.__mul__(), nzmath.rational.Rational.__neg__(), nzmath.ring.QuotientFieldElement.__neg__(), nzmath.rational.Rational.__nonzero__(), nzmath.rational.Rational.__pos__(), nzmath.rational.Rational.__pow__(), nzmath.ring.QuotientFieldElement.__pow__(), nzmath.rational.Rational.__radd__(), nzmath.poly.ratfunc.RationalFunction.__repr__(), nzmath.rational.Rational.__repr__(), nzmath.rational.Rational.__rmul__(), nzmath.rational.Rational.__rsub__(), nzmath.ring.QuotientFieldElement.__rsub__(), nzmath.rational.Rational.__rtruediv__(), nzmath.ring.QuotientFieldElement.__rtruediv__(), nzmath.poly.ratfunc.RationalFunction.__str__(), nzmath.rational.Rational.__str__(), nzmath.rational.Rational.__sub__(), nzmath.ring.QuotientFieldElement.__sub__(), nzmath.rational.Rational.__truediv__(), nzmath.ring.QuotientFieldElement.__truediv__(), nzmath.rational.Rational._init_by_float_float(), nzmath.rational.Rational._init_by_float_int(), nzmath.rational.Rational._init_by_float_Rational(), nzmath.rational.Rational._init_by_int_float(), nzmath.rational.Rational._init_by_int_int(), nzmath.rational.Rational._init_by_int_Rational(), nzmath.rational.Rational._init_by_Rational_float(), nzmath.rational.Rational._init_by_Rational_int(), nzmath.rational.Rational._init_by_Rational_Rational(), nzmath.rational.Rational._reduce(), nzmath.rational.Rational.compare(), nzmath.rational.Rational.decimalString(), nzmath.rational.Rational.expand(), nzmath.poly.ratfunc.RationalFunction.getRing(), nzmath.ring.QuotientFieldElement.inverse(), nzmath.rational.Rational.toFloat(), and nzmath.rational.Rational.trim().