public abstract class Scalar extends Coeff implements java.lang.Cloneable, java.io.Serializable
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.
Constructor and Description |
---|
Scalar() |
Modifier and Type | Method and Description |
---|---|
int |
cmp(Coeff x)
Compare this and x for inclusion.
|
abstract int |
cmp(int x)
Returns -1, 0, 1 if this is respectively strictly smaller, equal, or
strictly greater than x.
|
abstract int |
cmp(Scalar x)
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.
|
Scalar |
inf()
Returns a reference to the lower bound of this, i.e., this itself.
|
abstract void |
inv()
Inverts this.
|
boolean |
isEqual(Coeff x)
Whether this equals x.
|
abstract boolean |
isEqual(int x)
Whether this and x have the same value.
|
abstract boolean |
isEqual(Scalar x)
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.
|
Scalar |
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 java.lang.String |
toString()
Returns a string representation of the Scalar value.
|
public static Scalar create()
public abstract Scalar copy()
public abstract void setInfty(int sign)
The result is +oo if sign is strictly positive, -oo if sign is strictly negative, 0 if sign is null.
public abstract void set(int i)
public abstract int toMpq(Mpq r, int round)
public abstract int toMpfr(Mpfr r, int round)
public abstract int toDouble(double[] r, int round)
public abstract java.lang.String toString()
public abstract int hashCode()
public Scalar inf()
public Scalar sup()
public abstract int isInfty()
public abstract int sgn()
public abstract int cmp(Scalar x)
public abstract int cmp(int x)
public abstract boolean isEqual(Scalar x)
public abstract boolean isEqual(int x)
public boolean isScalar()
Always true.
public int cmp(Coeff x)
cmp
in class Coeff
Interval.cmp(Interval)
public abstract void inv()