Class Rational<E>

    • Field Detail

      • ring

        public final Ring<E> ring
        The ring.
    • Constructor Detail

      • Rational

        public Rational​(Ring<E> ring,
                        E numerator)
      • Rational

        public Rational​(Ring<E> ring,
                        E numerator,
                        E denominator)
    • Method Detail

      • zero

        public static <E> Rational<E> zero​(Ring<E> ring)
        Constructs zero
      • one

        public static <E> Rational<E> one​(Ring<E> ring)
        Constructs one
      • isZero

        public boolean isZero()
        whether this rational is zero
      • isOne

        public boolean isOne()
        whether this rational is one
      • isIntegral

        public boolean isIntegral()
        whether this rational is integral
      • numerator

        public E numerator()
        Numerator of this rational
      • numeratorExact

        public E numeratorExact()
        Numerator of this rational
      • denominator

        public E denominator()
        Denominator of this rational
      • factorDenominator

        public FactorDecomposition<E> factorDenominator()
        Factor decomposition of denominator
      • factorNumerator

        public FactorDecomposition<E> factorNumerator()
        Factor decomposition of denominator
      • normal

        public Rational<E>[] normal()
        Reduces this rational to normal form by doing division with remainder, that is if numerator = div * denominator + rem then the array (div, rem/denominator) will be returned. If either div or rem is zero an singleton array with this instance will be returned.
      • signum

        public int signum()
        Signum of this rational
      • reciprocal

        public Rational<E> reciprocal()
        Reciprocal of this
      • multiply

        public Rational<E> multiply​(E oth)
        Multiply this by oth
      • divide

        public Rational<E> divide​(E oth)
        Divide this by oth
      • negate

        public Rational<E> negate()
        Negate this fraction
      • add

        public Rational<E> add​(E that)
        Add that to this
      • subtract

        public Rational<E> subtract​(E that)
        Subtract that from this
      • pow

        public Rational<E> pow​(int exponent)
        Raise this in a power exponent
        exponent - exponent
      • pow

        public Rational<E> pow​(long exponent)
        Raise this in a power exponent
        exponent - exponent
      • pow

        public Rational<E> pow​(BigInteger exponent)
        Raise this in a power exponent
        exponent - exponent
      • map

        public <O> Rational<O> map​(Ring<O> ring,
                                   Function<E,​O> function)
        Maps rational to a new ring
      • stream

        public Stream<E> stream()
        Stream of numerator and denominator
      • hashCode

        public int hashCode()
        hashCode in class Object