Package apron

Class MpfrScalar

All Implemented Interfaces:
Serializable, Cloneable

public class MpfrScalar extends Scalar implements Cloneable, Serializable
Class of Scalar objects backed up by a Mpfr multi-precision floating-point number.
See Also:
  • Field Summary

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

    Constructors
    Constructor
    Description
    Creates a new Mpfr Scalar set to NaN.
    MpfrScalar(double x, int round)
    Creates a new Mpfr Scalar holding a copy of x.
    MpfrScalar(int prec)
    Creates a new Mpfr Scalar with the given precision, set to NaN.
    Creates a copy of x.
    Creates a new Mpfr Scalar holding a copy of x.
  • 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 Mpfr.
    int
    Returns a hash of the value of this.
    void
    inv()
    Inverts this (with rounding).
    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(double x, int round)
    Copies the value of x into this.
    void
    set(int x)
    Sets this to x.
    void
    Copies the value of x into this.
    void
    set(Mpfr x)
    Copies the value of x into this.
    void
    set(Mpfr x, int round)
    Copies the value of x into this.
    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 (exact).
    int
    toMpq(Mpq r, int round)
    Copies the value of this into r (exact, except if NaN)
    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 Mpfr val
      The (mutable) scalar value.
  • Constructor Details

    • MpfrScalar

      public MpfrScalar()
      Creates a new Mpfr Scalar set to NaN.
    • MpfrScalar

      public MpfrScalar(int prec)
      Creates a new Mpfr Scalar with the given precision, set to NaN.
    • MpfrScalar

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

      public MpfrScalar(Mpfr x)
      Creates a new Mpfr Scalar holding a copy of x.
    • MpfrScalar

      public MpfrScalar(double x, int round)
      Creates a new Mpfr Scalar holding a copy of x.

      x is rounded to the default Mpfr precision (see gmp.Mpfr.setDefaultPrec) in the direction specified by round.

  • Method Details

    • copy

      public MpfrScalar 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(MpfrScalar x)
      Copies the value of x into this.

      The precision of this is changed to match that of x.

    • set

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

      The precision of this is changed to match that of x.

    • set

      public void set(Mpfr x, int round)
      Copies the value of x into this.

      this retains its precision and x is rounded.

    • set

      public void set(double x, int round)
      Copies the value of x into this.

      this retains its precision and x is rounded.

    • set

      public void set(int x)
      Sets this to x.
      Specified by:
      set in class Scalar
    • 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 Mpfr get()
      Returns the underlying Mpfr.
    • toMpq

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

      public int toMpfr(Mpfr r, int round)
      Copies the value of this into r (exact).
      Specified by:
      toMpfr in class Scalar
      Returns:
      0.
    • 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(MpfrScalar x)
      Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    • 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
    • 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
    • isEqual

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

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

      public boolean isEqual(Scalar 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 (with rounding).
      Specified by:
      inv in class Scalar
    • clone

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