Package gnu.math
Class RealNum
- java.lang.Object
-
- java.lang.Number
-
- gnu.math.Numeric
-
- gnu.math.Quantity
-
- gnu.math.Quaternion
-
- gnu.math.Complex
-
- gnu.math.RealNum
-
- All Implemented Interfaces:
Serializable
,Comparable
public abstract class RealNum extends Complex implements Comparable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description RealNum()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Numeric
abs()
static RealNum
add(RealNum x, RealNum y, int k)
abstract Numeric
add(Object obj, int k)
Return this + k * obj.RealNum
angle()
BigDecimal
asBigDecimal()
static RealNum
asRealNumOrNull(Object value)
int
classifyFinite()
Check if value is finite, infinite, or NaN.int
compareTo(Object o)
Implements the Comparable interface.Quaternion
conjugate()
RealNum
cos()
abstract Numeric
div(Object obj)
static RealNum
divide(RealNum x, RealNum y)
Complex
exp()
RealNum
im()
The value of the imaginary component, as a RealNum.abstract boolean
isNegative()
static boolean
isReal(Object value)
boolean
isZero()
Complex
log()
RealNum
max(RealNum x)
RealNum
min(RealNum x)
abstract Numeric
mul(Object obj)
RealNum
re()
The value of the real component, as a RealNum.RealNum
rneg()
abstract int
sign()
Return 1 if>0
; 0 if==0
; -1 if<0
; -2 ifNaN
.RealNum
sin()
Complex
sqrt()
RealNum
tan()
static RealNum
times(RealNum x, RealNum y)
RatNum
toExact()
Convert to an exact number.static IntNum
toExactInt(double value)
Converts an integral double (such as a toInt result) to an IntNum.static IntNum
toExactInt(double value, int rounding_mode)
Converts real to an exact integer, with specified rounding mode.IntNum
toExactInt(int rounding_mode)
Converts to an exact integer, with specified rounding mode.RealNum
toInexact()
static double
toInt(double d, int rounding_mode)
Converts a real to an integer, according to a specified rounding mode.RealNum
toInt(int rounding_mode)
Converts a real to an integer, according to a specified rounding mode.static IntNum
toScaledInt(double f, int k)
Convert double to (rounded) integer, after multiplying by 10**k.IntNum
toScaledInt(int k)
Convert this to (rounded) integer, after multiplying by 10**k.static IntNum
toScaledInt(RatNum r, int k)
Convert rational to (rounded) integer, after multiplying by 10**k.static String
toStringDecimal(String dstr)
static String
toStringScientific(double d)
static String
toStringScientific(float d)
static String
toStringScientific(String dstr)
Convert result of Double.toString or Float.toString to scientific notation.static int
toStringScientific(String dstr, StringBuffer sbuf)
Quaternion
unitQuaternion()
Quaternion
unitVector()
Quaternion
vectorPart()
-
Methods inherited from class gnu.math.Complex
add, addReversed, colatitude, compare, compare, complexPart, divide, divReversed, equals, equals, imMinusOne, imOne, isExact, jm, km, longitude, make, make, mulReversed, neg, neg, polar, polar, power, times, toString
-
Methods inherited from class gnu.math.Quaternion
add, compare, divide, doubleImagValue, doubleJmagValue, doubleKmagValue, doubleRealValue, doubleValue, equals, jmMinusOne, jmOne, kmMinusOne, kmOne, longValue, make, make, neg, number, polar, polar, power, times
-
Methods inherited from class gnu.math.Quantity
add, compare, compareReversed, dimensions, divide, imValue, jmValue, kmValue, make, make, make, reValue, times, unit
-
Methods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, floatValue, geq, grt, intValue, mul_ident, power, sub, toString
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
re
public final RealNum re()
Description copied from class:Quantity
The value of the real component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true real component.
-
im
public final RealNum im()
Description copied from class:Quantity
The value of the imaginary component, as a RealNum. The unit() is not factored in, so you actually need to multiply by unit() to get the true imaginary component.
-
vectorPart
public final Quaternion vectorPart()
- Overrides:
vectorPart
in classComplex
-
unitVector
public final Quaternion unitVector()
- Overrides:
unitVector
in classComplex
-
unitQuaternion
public final Quaternion unitQuaternion()
- Overrides:
unitQuaternion
in classComplex
-
conjugate
public final Quaternion conjugate()
-
isReal
public static boolean isReal(Object value)
-
isNegative
public abstract boolean isNegative()
-
classifyFinite
public int classifyFinite()
Description copied from class:Complex
Check if value is finite, infinite, or NaN.- Overrides:
classifyFinite
in classComplex
- Returns:
- 1 if finite; 0 if infinite; -1 if NaN.
-
sign
public abstract int sign()
Return 1 if>0
; 0 if==0
; -1 if<0
; -2 ifNaN
.
-
add
public abstract Numeric add(Object obj, int k)
Description copied from class:Numeric
Return this + k * obj.
-
rneg
public RealNum rneg()
-
toExact
public RatNum toExact()
Convert to an exact number. Implements the Schemeinexact->exact
(for real numbers).
-
toInt
public static double toInt(double d, int rounding_mode)
Converts a real to an integer, according to a specified rounding mode. Note an inexact argument gives an inexact result, following Scheme. See also RatNum.toExactInt.
-
toInt
public RealNum toInt(int rounding_mode)
Converts a real to an integer, according to a specified rounding mode. Note an inexact argument gives an inexact result, following Scheme. See also toExactInt.
-
toExactInt
public IntNum toExactInt(int rounding_mode)
Converts to an exact integer, with specified rounding mode.
-
toExactInt
public static IntNum toExactInt(double value, int rounding_mode)
Converts real to an exact integer, with specified rounding mode.
-
toExactInt
public static IntNum toExactInt(double value)
Converts an integral double (such as a toInt result) to an IntNum.
-
toScaledInt
public static IntNum toScaledInt(double f, int k)
Convert double to (rounded) integer, after multiplying by 10**k.
-
toScaledInt
public static IntNum toScaledInt(RatNum r, int k)
Convert rational to (rounded) integer, after multiplying by 10**k.
-
toScaledInt
public IntNum toScaledInt(int k)
Convert this to (rounded) integer, after multiplying by 10**k.
-
compareTo
public int compareTo(Object o)
Implements the Comparable interface. This ordering isn't fully consistent with equals, since say it returns 0 when comparing 1.5 and 3/2, though they are not equals.- Specified by:
compareTo
in interfaceComparable
-
asBigDecimal
public BigDecimal asBigDecimal()
-
toStringScientific
public static String toStringScientific(float d)
-
toStringScientific
public static String toStringScientific(double d)
-
toStringScientific
public static String toStringScientific(String dstr)
Convert result of Double.toString or Float.toString to scientific notation. Does not validate the input.
-
toStringScientific
public static int toStringScientific(String dstr, StringBuffer sbuf)
-
-