HE_Mesh
5.1.2
|
Static Public Member Functions | |
static WB_DoubleDouble | valueOf (final String str) throws NumberFormatException |
static WB_DoubleDouble | valueOf (final double x) |
static WB_DoubleDouble | copy (final WB_DoubleDouble dd) |
static WB_DoubleDouble | sqr (final double x) |
static WB_DoubleDouble | sqrt (final double x) |
static WB_DoubleDouble | parse (final String str) throws NumberFormatException |
Static Public Attributes | |
static final WB_DoubleDouble | PI |
static final WB_DoubleDouble | TWO_PI |
static final WB_DoubleDouble | PI_2 |
static final WB_DoubleDouble | E |
static final WB_DoubleDouble | NaN |
static final double | EPS = 1.23259516440783e-32 |
static final WB_DoubleDouble | ZERO = new WB_DoubleDouble(0.0, 0.0) |
Private Member Functions | |
void | init (final double x) |
void | init (final double hi, final double lo) |
void | init (final WB_DoubleDouble dd) |
WB_DoubleDouble | selfAdd (final double yhi, final double ylo) |
WB_DoubleDouble | selfMultiply (final double yhi, final double ylo) |
WB_DoubleDouble | selfDivide (final double yhi, final double ylo) |
String | extractSignificantDigits (final boolean insertDecimalPoint, final int[] magnitude) |
String | getSpecialNumberString () |
Static Private Member Functions | |
static WB_DoubleDouble | createNaN () |
static String | stringOfChar (final char ch, final int len) |
static int | magnitude (final double x) |
Private Attributes | |
double | hi = 0.0 |
double | lo = 0.0 |
Static Private Attributes | |
static final long | serialVersionUID = -2751466014056438637L |
static final double | SPLIT = 134217729.0D |
static final int | MAX_PRINT_DIGITS = 32 |
static final WB_DoubleDouble | TEN = WB_DoubleDouble.valueOf(10.0) |
static final WB_DoubleDouble | ONE = WB_DoubleDouble.valueOf(1.0) |
static final String | SCI_NOT_EXPONENT_CHAR = "E" |
static final String | SCI_NOT_ZERO = "0.0E0" |
Implements extended-precision floating-point numbers which maintain 106 bits (approximately 30 decimal digits) of precision.
A DoubleDouble uses a representation containing two double-precision values. A number x is represented as a pair of doubles, x.hi and x.lo, such that the number represented by x is x.hi + x.lo, where
|x.lo| <= 0.5*ulp(x.hi)
and ulp(y) means "unit in the last place of y". The basic arithmetic operations are implemented using convenient properties of IEEE-754 floating-point arithmetic.
The range of values which can be represented is the same as in IEEE-754. The precision of the representable numbers is twice as great as IEEE-754 double precision.
The correctness of the arithmetic algorithms relies on operations being performed with standard IEEE-754 double precision and rounding. This is the Java standard arithmetic model, but for performance reasons Java implementations are not constrained to using this standard by default. Some processors (notably the Intel Pentium architecure) perform floating point operations in (non-IEEE-754-standard) extended-precision. A JVM implementation may choose to use the non-standard extended-precision as its default arithmetic mode. To prevent this from happening, this code uses the Java strictfp
modifier, which forces all operations to take place in the standard IEEE-754 rounding model.
The API provides both a set of value-oriented operations and a set of mutating operations. Value-oriented operations treat DoubleDouble values as immutable; operations on them return new objects carrying the result of the operation. This provides a simple and safe semantics for writing DoubleDouble expressions. However, there is a performance penalty for the object allocations required. The mutable interface updates object values in-place. It provides optimum memory performance, but requires care to ensure that aliasing errors are not created and constant values are not changed.
This implementation uses algorithms originally designed variously by Knuth, Kahan, Dekker, and Linnainmaa. Douglas Priest developed the first C implementation of these techniques. Other more recent C++ implementation are due to Keith M. Briggs and David Bailey et al.
wblut.math.WB_DoubleDouble.WB_DoubleDouble | ( | ) |
Creates a new DoubleDouble with value 0.0.
wblut.math.WB_DoubleDouble.WB_DoubleDouble | ( | final double | x | ) |
Creates a new DoubleDouble with value x.
x | the value to initialize |
wblut.math.WB_DoubleDouble.WB_DoubleDouble | ( | final double | hi, |
final double | lo | ||
) |
Creates a new DoubleDouble with value (hi, lo).
hi | the high-order component |
lo | the high-order component |
wblut.math.WB_DoubleDouble.WB_DoubleDouble | ( | final WB_DoubleDouble | dd | ) |
Creates a new DoubleDouble with value equal to the argument.
dd | the value to initialize |
wblut.math.WB_DoubleDouble.WB_DoubleDouble | ( | final String | str | ) | throws NumberFormatException |
Creates a new DoubleDouble with value equal to the argument.
str | the value to initialize by |
NumberFormatException | if str is not a valid representation of a number |
WB_DoubleDouble wblut.math.WB_DoubleDouble.abs | ( | ) |
Returns the absolute value of this value. Special cases:
WB_DoubleDouble wblut.math.WB_DoubleDouble.add | ( | final WB_DoubleDouble | y | ) |
Returns a DoubleDouble whose value is (this + y)
.
y | the addend |
(this + y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.add | ( | final double | y | ) |
Returns a DoubleDouble whose value is (this + y)
.
y | the addend |
(this + y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.ceil | ( | ) |
Returns the smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer. Special cases:
Object wblut.math.WB_DoubleDouble.clone | ( | ) |
Creates and returns a copy of this value.
int wblut.math.WB_DoubleDouble.compareTo | ( | final Object | o | ) |
Compares two DoubleDouble objects numerically.
o | the o |
o
|
static |
Creates a new DoubleDouble with the value of the argument.
dd | the DoubleDouble value to copy |
|
staticprivate |
Creates the na n.
WB_DoubleDouble wblut.math.WB_DoubleDouble.divide | ( | final WB_DoubleDouble | y | ) |
Computes a new DoubleDouble whose value is (this / y)
.
y | the divisor |
(this / y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.divide | ( | final double | y | ) |
Computes a new DoubleDouble whose value is (this / y)
.
y | the divisor |
(this / y)
double wblut.math.WB_DoubleDouble.doubleValue | ( | ) |
Converts this value to the nearest double-precision number.
String wblut.math.WB_DoubleDouble.dump | ( | ) |
Dumps the components of this number to a string.
boolean wblut.math.WB_DoubleDouble.equals | ( | final WB_DoubleDouble | y | ) |
Tests whether this value is equal to another DoubleDouble
value.
y | a DoubleDouble value |
|
private |
Extracts the significant digits in the decimal representation of the argument. A decimal point may be optionally inserted in the string of digits (as long as its position lies within the extracted digits - if not, the caller must prepend or append the appropriate zeroes and decimal point).
insertDecimalPoint | the insert decimal point |
magnitude | the magnitude |
This should never happen, due to heuristic checks on remainder below
If a negative remainder is encountered, simply terminate the extraction. This is robust, but maybe slightly inaccurate. My current hypothesis is that negative remainders only occur for very small lo components, so the inaccuracy is tolerable
Heuristic check: if the remaining portion of y is non-positive, assume that output is complete
Check if remaining digits will be 0, and if so don't output them. Do this by comparing the magnitude of the remainder with the expected precision.
WB_DoubleDouble wblut.math.WB_DoubleDouble.floor | ( | ) |
Returns the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer. Special cases:
boolean wblut.math.WB_DoubleDouble.ge | ( | final WB_DoubleDouble | y | ) |
Tests whether this value is greater than or equals to another DoubleDouble
value.
y | a DoubleDouble value |
|
private |
Returns the string for this value if it has a known representation. (E.g. NaN or 0.0)
boolean wblut.math.WB_DoubleDouble.gt | ( | final WB_DoubleDouble | y | ) |
Tests whether this value is greater than another DoubleDouble
value.
y | a DoubleDouble value |
|
private |
Inits the.
x | the x |
|
private |
Inits the.
hi | the hi |
lo | the lo |
|
private |
Inits the.
dd | the dd |
int wblut.math.WB_DoubleDouble.intValue | ( | ) |
Converts this value to the nearest integer.
boolean wblut.math.WB_DoubleDouble.isNaN | ( | ) |
Tests whether this value is NaN.
boolean wblut.math.WB_DoubleDouble.isNegative | ( | ) |
Tests whether this value is less than 0.
boolean wblut.math.WB_DoubleDouble.isPositive | ( | ) |
Tests whether this value is greater than 0.
boolean wblut.math.WB_DoubleDouble.isZero | ( | ) |
Tests whether this value is equal to 0.
boolean wblut.math.WB_DoubleDouble.le | ( | final WB_DoubleDouble | y | ) |
Tests whether this value is less than or equal to another DoubleDouble
value.
y | a DoubleDouble value |
boolean wblut.math.WB_DoubleDouble.lt | ( | final WB_DoubleDouble | y | ) |
Tests whether this value is less than another DoubleDouble
value.
y | a DoubleDouble value |
|
staticprivate |
Determines the decimal magnitude of a number. The magnitude is the exponent of the greatest power of 10 which is less than or equal to the number.
x | the number to find the magnitude of |
Since log computation is inexact, there may be an off-by-one error in the computed magnitude. Following tests that magnitude is correct, and adjusts it if not
WB_DoubleDouble wblut.math.WB_DoubleDouble.multiply | ( | final WB_DoubleDouble | y | ) |
Returns a new DoubleDouble whose value is (this * y)
.
y | the multiplicand |
(this * y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.multiply | ( | final double | y | ) |
Returns a new DoubleDouble whose value is (this * y)
.
y | the multiplicand |
(this * y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.negate | ( | ) |
Returns a DoubleDouble whose value is -this
.
-this
|
static |
Converts a string representation of a real number into a DoubleDouble value. The format accepted is similar to the standard Java real number syntax. It is defined by the following regular expression:
[+
|-
] {digit} [.
{digit} ] [ (e
|E
) [+
|-
] {digit}+
str | the string to parse |
NumberFormatException | if str is not a valid representation of a number |
WB_DoubleDouble wblut.math.WB_DoubleDouble.pow | ( | final int | exp | ) |
Computes the value of this number raised to an integral power. Follows semantics of Java Math.pow as closely as possible.
exp | the integer exponent |
WB_DoubleDouble wblut.math.WB_DoubleDouble.reciprocal | ( | ) |
Returns a DoubleDouble whose value is 1 / this
.
WB_DoubleDouble wblut.math.WB_DoubleDouble.rint | ( | ) |
Rounds this value to the nearest integer. The value is rounded to an integer by adding 1/2 and taking the floor of the result. Special cases:
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfAdd | ( | final WB_DoubleDouble | y | ) |
Adds the argument to the value of this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the addend |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfAdd | ( | final double | y | ) |
Adds the argument to the value of this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the addend |
|
private |
Self add.
yhi | the yhi |
ylo | the ylo |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfDivide | ( | final WB_DoubleDouble | y | ) |
Divides this object by the argument, returning this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the value to divide by |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfDivide | ( | final double | y | ) |
Divides this object by the argument, returning this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the value to divide by |
|
private |
Self divide.
yhi | the yhi |
ylo | the ylo |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfMultiply | ( | final WB_DoubleDouble | y | ) |
Multiplies this object by the argument, returning this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the value to multiply by |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfMultiply | ( | final double | y | ) |
Multiplies this object by the argument, returning this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the value to multiply by |
|
private |
Self multiply.
yhi | the yhi |
ylo | the ylo |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfSubtract | ( | final WB_DoubleDouble | y | ) |
Subtracts the argument from the value of this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the addend |
WB_DoubleDouble wblut.math.WB_DoubleDouble.selfSubtract | ( | final double | y | ) |
Subtracts the argument from the value of this
. To prevent altering constants, this method must only be used on values known to be newly created.
y | the addend |
int wblut.math.WB_DoubleDouble.signum | ( | ) |
Returns an integer indicating the sign of this value.
WB_DoubleDouble wblut.math.WB_DoubleDouble.sqr | ( | ) |
Computes the square of this value.
|
static |
Computes the square of this value.
x | the x |
WB_DoubleDouble wblut.math.WB_DoubleDouble.sqrt | ( | ) |
Computes the positive square root of this value. If the number is NaN or negative, NaN is returned.
|
static |
Sqrt.
x | the x |
|
staticprivate |
Creates a string of a given length containing the given character.
ch | the character to be repeated |
len | the len of the desired string |
WB_DoubleDouble wblut.math.WB_DoubleDouble.subtract | ( | final WB_DoubleDouble | y | ) |
Computes a new DoubleDouble object whose value is (this - y)
.
y | the subtrahend |
(this - y)
WB_DoubleDouble wblut.math.WB_DoubleDouble.subtract | ( | final double | y | ) |
Computes a new DoubleDouble object whose value is (this - y)
.
y | the subtrahend |
(this - y)
String wblut.math.WB_DoubleDouble.toSciNotation | ( | ) |
Returns the string representation of this value in scientific notation.
String wblut.math.WB_DoubleDouble.toStandardNotation | ( | ) |
Returns the string representation of this value in standard notation.
String wblut.math.WB_DoubleDouble.toString | ( | ) |
Returns a string representation of this number, in either standard or scientific notation. If the magnitude of the number is in the range [ 10-3, 108 ] standard notation will be used. Otherwise, scientific notation will be used.
WB_DoubleDouble wblut.math.WB_DoubleDouble.trunc | ( | ) |
Returns the integer which is largest in absolute value and not further from zero than this value. Special cases:
|
static |
Converts the string argument to a DoubleDouble number.
str | a string containing a representation of a numeric value |
NumberFormatException | if s is not a valid representation of a number |
|
static |
Converts the double
argument to a DoubleDouble number.
x | a numeric value |
|
static |
The value nearest to the constant e (the natural logarithm base).
|
static |
The smallest representable relative difference between two {link @ DoubleDouble} values.
|
private |
The high-order component of the double-double precision value.
|
private |
The low-order component of the double-double precision value.
|
staticprivate |
The Constant MAX_PRINT_DIGITS.
|
static |
A value representing the result of an operation which does not return a valid number.
|
staticprivate |
The Constant ONE.
|
static |
The value nearest to the constant Pi.
|
static |
The value nearest to the constant Pi / 2.
|
staticprivate |
The Constant SCI_NOT_EXPONENT_CHAR.
|
staticprivate |
The Constant SCI_NOT_ZERO.
|
staticprivate |
The Constant serialVersionUID.
|
staticprivate |
The value to split a double-precision value on during multiplication.
|
staticprivate |
The Constant TEN.
|
static |
The value nearest to the constant 2 * Pi.
|
static |
The Constant ZERO.