Package apron

Class MpqScalar

All Implemented Interfaces:
Serializable, Cloneable

public class MpqScalar extends Scalar implements Cloneable, Serializable
Class of Scalar objects backed up by a Mpq multi-precision rational.

Note: infinities are represented by using a null denominator. This may cause problems if manipulated by Mpq functions.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The (mutable) scalar value.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Mpq Scalar set to 0.
    MpqScalar(int x)
    Creates a new Mpq Scalar initialized to x.
    MpqScalar(int num, int den)
    Creates a new Mpq Scalar initialized to the fraction num/den.
    Creates a copy of x.
    Creates a new Mpq Scalar holding a copy of x.
    Creates a new Mpq Scalar holding a copy of x.
    MpqScalar(Mpz num, Mpz den)
    Creates a new Mpq Scalar initialized to the fraction num/den.
    Creates a new Mpq Scalar initialized to x.
    Creates a new Mpq Scalar initialized to the fraction num/den.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of this.
    int
    cmp(int x)
    Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    int
    Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    int
    Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    Creates a copy of the Scalar, of the same kind.
    get()
    Returns the underlying Mpq.
    int
    Returns a hash of the value of this.
    void
    inv()
    Inverts this (exact).
    boolean
    isEqual(int x)
    Whether this and x have the same value.
    boolean
    Whether this and x have the same value.
    boolean
    Whether this and x have the same value.
    int
    Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.
    boolean
    Whether this equals 0.
    void
    neg()
    Negates this (exact).
    void
    set(int x)
    Sets this to x.
    void
    set(int num, int den)
    Sets this to the fraction num/den.
    void
    Copies the value of x into this.
    void
    set(Mpq x)
    Copies the value of x into this.
    void
    set(Mpz x)
    Copies the value of x into this.
    void
    Sets this to x.
    void
    Sets this to the fraction num/den.
    void
    setInfty(int sign)
    Sets the scalar to +oo or -oo.
    int
    sgn()
    Returns the sign of this.
    int
    toDouble(double[] r, int round)
    Copies the value of this into r[0] (with rounding).
    int
    toMpfr(Mpfr r, int round)
    Copies the value of this into r (with rounding).
    int
    toMpq(Mpq r, int round)
    Copies the value of this into r (exact).
    Returns a string representation of the value of this.

    Methods inherited from class apron.Scalar

    cmp, create, inf, isEqual, isScalar, sup

    Methods inherited from class apron.Coeff

    equals

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • val

      public Mpq val
      The (mutable) scalar value.
  • Constructor Details

    • MpqScalar

      public MpqScalar()
      Creates a new Mpq Scalar set to 0.
    • MpqScalar

      public MpqScalar(MpqScalar x)
      Creates a copy of x.
    • MpqScalar

      public MpqScalar(Mpq x)
      Creates a new Mpq Scalar holding a copy of x.
    • MpqScalar

      public MpqScalar(Mpz x)
      Creates a new Mpq Scalar holding a copy of x.
    • MpqScalar

      public MpqScalar(int x)
      Creates a new Mpq Scalar initialized to x.
    • MpqScalar

      public MpqScalar(int num, int den)
      Creates a new Mpq Scalar initialized to the fraction num/den.
    • MpqScalar

      public MpqScalar(Mpz num, Mpz den)
      Creates a new Mpq Scalar initialized to the fraction num/den.
    • MpqScalar

      public MpqScalar(BigInteger x)
      Creates a new Mpq Scalar initialized to x.
    • MpqScalar

      public MpqScalar(BigInteger num, BigInteger den)
      Creates a new Mpq Scalar initialized to the fraction num/den.
  • Method Details

    • copy

      public MpqScalar copy()
      Description copied from class: Scalar
      Creates a copy of the Scalar, of the same kind.
      Specified by:
      copy in class Scalar
    • set

      public void set(MpqScalar x)
      Copies the value of x into this.
    • set

      public void set(Mpq x)
      Copies the value of x into this.
    • set

      public void set(Mpz x)
      Copies the value of x into this.
    • set

      public void set(int x)
      Sets this to x.
      Specified by:
      set in class Scalar
    • set

      public void set(int num, int den)
      Sets this to the fraction num/den.
    • set

      public void set(BigInteger x)
      Sets this to x.
    • set

      public void set(BigInteger num, BigInteger den)
      Sets this to the fraction num/den.
    • setInfty

      public void setInfty(int sign)
      Sets the scalar to +oo or -oo.

      The result is +oo if sign is strictly positive, -oo if sign is strictly negative, 0 if sign is null.

      Specified by:
      setInfty in class Scalar
    • get

      public Mpq get()
      Returns the underlying Mpq.
    • toMpq

      public int toMpq(Mpq r, int round)
      Copies the value of this into r (exact).
      Specified by:
      toMpq in class Scalar
      Returns:
      0.
    • toMpfr

      public int toMpfr(Mpfr r, int round)
      Copies the value of this into r (with rounding).
      Specified by:
      toMpfr in class Scalar
      Returns:
      -1, 0, 1 if the result is lower, exact, or greater than this.
    • toDouble

      public int toDouble(double[] r, int round)
      Copies the value of this into r[0] (with rounding).
      Specified by:
      toDouble in class Scalar
      Returns:
      -1, 0, 1 if the result is lower, exact, or greater than this.
    • toString

      public String toString()
      Returns a string representation of the value of this.
      Specified by:
      toString in class Scalar
    • hashCode

      public int hashCode()
      Returns a hash of the value of this.
      Specified by:
      hashCode in class Scalar
    • isInfty

      public int isInfty()
      Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.
      Specified by:
      isInfty in class Scalar
    • isZero

      public boolean isZero()
      Whether this equals 0.
      Specified by:
      isZero in class Scalar
    • cmp

      public int cmp(MpqScalar x)
      Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    • cmp

      public int cmp(Scalar x)
      Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
      Specified by:
      cmp in class Scalar
    • cmp

      public int cmp(int x)
      Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
      Specified by:
      cmp in class Scalar
    • isEqual

      public boolean isEqual(MpqScalar x)
      Whether this and x have the same value.
    • isEqual

      public boolean isEqual(Scalar x)
      Whether this and x have the same value.
      Specified by:
      isEqual in class Scalar
    • isEqual

      public boolean isEqual(int x)
      Whether this and x have the same value.
      Specified by:
      isEqual in class Scalar
    • sgn

      public int sgn()
      Returns the sign of this.
      Specified by:
      sgn in class Scalar
    • neg

      public void neg()
      Negates this (exact).
      Specified by:
      neg in class Scalar
    • inv

      public void inv()
      Inverts this (exact).
      Specified by:
      inv in class Scalar
    • clone

      public MpqScalar clone()
      Returns a copy of this.
      Overrides:
      clone in class Object