|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjava.lang.Number
com.numericalmethod.suanshu.number.Real
public class Real
This class represents an arbitrary precision real number.
This is simply a wrapper around BigDecimal and implements the Field interface.
This class is immutable.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.mathstructure.Field |
|---|
Field.InverseNonExistent |
| Field Summary | |
|---|---|
static Real |
ONE
a number representing 1 |
static Real |
ZERO
a number representing 0 |
| Constructor Summary | |
|---|---|
Real(java.math.BigDecimal value)
Construct a Real from a BigDecimal. |
|
Real(java.math.BigInteger value)
Construct a Real from a BigInteger. |
|
Real(double value)
Construct a Real from a double. |
|
Real(long value)
Construct a Real from an integer. |
|
Real(java.lang.String value)
Construct a Real from a String representation of a number. |
|
| Method Summary | |
|---|---|
Real |
add(Real that)
+ : G × G → G |
java.math.BigDecimal |
bigDecimal()
Construct a BigDecimal from this Real number. |
int |
compareTo(Real that)
|
Real |
divide(Real that)
/ : F × F → F
That is the same as
this.multiply(that.inverse()) |
Real |
divide(Real that,
int scale)
/ : R × R → R
Divide a Real number by another one. |
double |
doubleValue()
|
boolean |
equals(java.lang.Object obj)
|
float |
floatValue()
|
int |
hashCode()
|
int |
intValue()
|
Real |
inverse()
For each a in F, there exists an element b in F such that
a × b = b × a = 1
That is, it is the object such as
this.multiply(this.inverse()) == this.ONE |
long |
longValue()
|
Real |
minus(Real that)
- : G × G → G
- is not in the definition of of an additive group but can be deduced. |
Real |
multiply(Real that)
· : G × G → G |
Real |
ONE()
The multiplicative element 1 in the group such that for any elements a in the group,
the equation
1 × a = a × 1 = a
holds. |
Real |
opposite()
For each a in G, there exists an element b in G such that a + b = b + a = 0
That is, it is the object such as
this.add(this.opposite()) == this.ZERO |
java.lang.String |
toString()
|
Real |
ZERO()
The additive element 0 in the group, such that for all elements a in the group,
the equation 0 + a = a + 0 = a holds. |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final Real ZERO
0
public static final Real ONE
1
| Constructor Detail |
|---|
public Real(double value)
value is first converted to String and then to BigDecimal.
value - a double valuepublic Real(long value)
value - an integerpublic Real(java.math.BigDecimal value)
value - a BigDecimalpublic Real(java.math.BigInteger value)
value - a BigIntegerpublic Real(java.lang.String value)
value - a String representation of a number| Method Detail |
|---|
public int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic double doubleValue()
doubleValue in class java.lang.Numberpublic java.math.BigDecimal bigDecimal()
public Real add(Real that)
AbelianGroup+ : G × G → G
add in interface AbelianGroup<Real>that - the object to be added
this + thatpublic Real minus(Real that)
AbelianGroup- : G × G → G
- is not in the definition of of an additive group but can be deduced.
This function is provided for convenience purpose.
It is equivalent to
this.add(that.opposite())
minus in interface AbelianGroup<Real>that - the object to be subtracted (subtrahend)
this - thatpublic Real opposite()
AbelianGroupa + b = b + a = 0
That is, it is the object such as
this.add(this.opposite()) == this.ZERO
opposite in interface AbelianGroup<Real>-thispublic Real multiply(Real that)
Monoid· : G × G → G
multiply in interface Monoid<Real>that - the multiplicand
this × thatpublic Real divide(Real that)
Field/ : F × F → F
That is the same as
this.multiply(that.inverse())
divide in interface Field<Real>that - the denominator
this / that
public Real divide(Real that,
int scale)
/ : R × R → R
Divide a Real number by another one.
Rounding is performed with the specific scale.
that - another non-zero Real numberscale - scale as in BigDecimal
public Real inverse()
throws Field.InverseNonExistent
FieldF, there exists an element b in F such that
a × b = b × a = 1
That is, it is the object such as
this.multiply(this.inverse()) == this.ONE
inverse in interface Field<Real>1 / this if it exists
Field.InverseNonExistent - if the inverse does not existpublic Real ZERO()
AbelianGroupa in the group,
the equation 0 + a = a + 0 = a holds.
ZERO in interface AbelianGroup<Real>0public Real ONE()
Monoida in the group,
the equation
1 × a = a × 1 = a
holds.
ONE in interface Monoid<Real>1public int compareTo(Real that)
compareTo in interface java.lang.Comparable<Real>public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
SuanShu, a Java numerical and statistical library | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||