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 intcmp(int x) Returns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.intCompare this and x for inclusion.abstract intReturns -1, 0, 1 if this is respectively strictly smaller, equal, or strictly greater than x.abstract Scalarcopy()Creates a copy of the Scalar, of the same kind.static Scalarcreate()Creates a double Scalar initialized to 0.abstract inthashCode()Returns a hash of the value of this.inf()Returns a reference to the lower bound of this, i.e., this itself.abstract voidinv()Inverts this.abstract booleanisEqual(int x) Whether this and x have the same value.booleanWhether this equals x.abstract booleanWhether this and x have the same value.abstract intisInfty()Returns -1, 0 or 1 if this is respectively -oo, finite, or +oo.booleanisScalar()Whether this represents a singleton.abstract booleanisZero()Whether this equals 0.abstract voidneg()Negates this.abstract voidset(int i) Sets the scalar to an integer, without changing its kind.abstract voidsetInfty(int sign) Sets the scalar to +oo or -oo.abstract intsgn()Returns the sign of this.sup()Returns a reference to the upper bound of this, i.e., this itself.abstract inttoDouble(double[] r, int round) Copies the value of this into r[0].abstract intCopies the value of this into r.abstract intCopies the value of this into r.abstract StringtoString()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.
-