Package apron

Class Scalar

All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
DoubleScalar, MpfrScalar, MpqScalar

public abstract class Scalar extends Coeff implements Cloneable, Serializable
Abstract class of coefficients that represent scalar real numbers.

A Scalar object may be an arbitrary-precision fraction (stored into a MpqScalar), a double (stored in a DoubleScalar), or an arbitrary-precision float (stored in a MpfrScalar). The Scalar class provides methods to manipulate them independently from the underlying representation. It is also a specialisation of the more general Coeff class to coefficients that are singleton.

All kinds of Scalar can also represent +oo and -oo.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract int
    cmp(int x)
    Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    int
    Compare this and x for inclusion.
    abstract int
    Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.
    abstract Scalar
    Creates a copy of the Scalar, of the same kind.
    static Scalar
    Creates a double Scalar initialized to 0.
    abstract int
    Returns a hash of the value of this.
    inf()
    Returns a reference to the lower bound of this, i.e., this itself.
    abstract void
    inv()
    Inverts this.
    abstract boolean
    isEqual(int x)
    Whether this and x have the same value.
    boolean
    Whether this equals x.
    abstract boolean
    Whether this and x have the same value.
    abstract int
    Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.
    boolean
    Whether this represents a singleton.
    abstract boolean
    Whether this equals 0.
    abstract void
    neg()
    Negates this.
    abstract void
    set(int i)
    Sets the scalar to an integer, without changing its kind.
    abstract void
    setInfty(int sign)
    Sets the scalar to +oo or -oo.
    abstract int
    sgn()
    Returns the sign of this.
    sup()
    Returns a reference to the upper bound of this, i.e., this itself.
    abstract int
    toDouble(double[] r, int round)
    Copies the value of this into r[0].
    abstract int
    toMpfr(Mpfr r, int round)
    Copies the value of this into r.
    abstract int
    toMpq(Mpq r, int round)
    Copies the value of this into r.
    abstract String
    Returns a string representation of the Scalar value.

    Methods inherited from class apron.Coeff

    equals

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Scalar

      public Scalar()
  • Method Details

    • create

      public static Scalar create()
      Creates a double Scalar initialized to 0.
    • copy

      public abstract Scalar copy()
      Creates a copy of the Scalar, of the same kind.
      Specified by:
      copy in class Coeff
    • setInfty

      public abstract 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.

    • set

      public abstract void set(int i)
      Sets the scalar to an integer, without changing its kind.
    • toMpq

      public abstract int toMpq(Mpq r, int round)
      Copies the value of this into r.
      Returns:
      -1, 0, 1 if the result is lower, exact, or greater than this.
    • toMpfr

      public abstract int toMpfr(Mpfr r, int round)
      Copies the value of this into r.
      Returns:
      -1, 0, 1 if the result is lower, exact, or greater than this.
    • toDouble

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

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

      public abstract int hashCode()
      Returns a hash of the value of this.
      Specified by:
      hashCode in class Coeff
    • inf

      public Scalar inf()
      Returns a reference to the lower bound of this, i.e., this itself.
      Specified by:
      inf in class Coeff
    • sup

      public Scalar sup()
      Returns a reference to the upper bound of this, i.e., this itself.
      Specified by:
      sup in class Coeff
    • isInfty

      public abstract int isInfty()
      Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.
    • isZero

      public abstract boolean isZero()
      Whether this equals 0.
      Specified by:
      isZero in class Coeff
    • sgn

      public abstract int sgn()
      Returns the sign of this.
    • cmp

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

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

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

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

      public boolean isScalar()
      Whether this represents a singleton.

      Always true.

      Specified by:
      isScalar in class Coeff
    • isEqual

      public boolean isEqual(Coeff x)
      Whether this equals x.
      Specified by:
      isEqual in class Coeff
    • cmp

      public int cmp(Coeff x)
      Compare this and x for inclusion.
      Specified by:
      cmp in class Coeff
      See Also:
    • neg

      public abstract void neg()
      Negates this.
      Specified by:
      neg in class Coeff
    • inv

      public abstract void inv()
      Inverts this.