Package apron
Class Scalar
java.lang.Object
apron.Coeff
apron.Scalar
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
DoubleScalar
,MpfrScalar
,MpqScalar
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 -
Method Summary
Modifier and TypeMethodDescriptionabstract 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
copy()
Creates a copy of the Scalar, of the same kind.static Scalar
create()
Creates a double Scalar initialized to 0.abstract int
hashCode()
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
isInfty()
Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.boolean
isScalar()
Whether this represents a singleton.abstract boolean
isZero()
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
Copies the value of this into r.abstract int
Copies the value of this into r.abstract String
toString()
Returns a string representation of the Scalar value.
-
Constructor Details
-
Scalar
public Scalar()
-
-
Method Details
-
create
Creates a double Scalar initialized to 0. -
copy
Creates a copy of the Scalar, of the same kind. -
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
Copies the value of this into r.- Returns:
- -1, 0, 1 if the result is lower, exact, or greater than this.
-
toMpfr
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
Returns a string representation of the Scalar value. -
hashCode
public abstract int hashCode()Returns a hash of the value of this. -
inf
Returns a reference to the lower bound of this, i.e., this itself. -
sup
Returns a reference to the upper bound of this, i.e., this itself. -
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. -
sgn
public abstract int sgn()Returns the sign of this. -
cmp
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
Whether this and x have the same value. -
isEqual
public abstract boolean isEqual(int x) Whether this and x have the same value. -
isScalar
public boolean isScalar()Whether this represents a singleton.Always true.
-
isEqual
Whether this equals x. -
cmp
Compare this and x for inclusion. -
neg
public abstract void neg()Negates this. -
inv
public abstract void inv()Inverts this.
-