NetTopologySuite
|
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 More...
Public Member Functions | |
DD (double x) | |
Creates a new DD with value x. More... | |
DD (double hi, double lo) | |
Creates a new DD with value (hi, lo). More... | |
DD (DD dd) | |
Creates a DD with a value equal to the argument More... | |
DD (String str) | |
Object | Clone () |
Creates and returns a copy of this value. More... | |
DD | Add (DD y) |
Returns a DD whose value is (this + y ) More... | |
DD | Add (double y) |
Returns a DD whose value is (this + y) . More... | |
DD | Subtract (DD y) |
Computes a new DD object whose value is (this - y) . More... | |
DD | Subtract (double y) |
Computes a new DD object whose value is (this - y) . More... | |
DD | Negate () |
Returns a DD whose value is -this . More... | |
DD | Multiply (DD y) |
DD | Multiply (double y) |
DD | Divide (DD y) |
Computes a new DD whose value is (this / y) . More... | |
DD | Divide (double y) |
Computes a new DD whose value is (this / y) . More... | |
DD | Reciprocal () |
DD | Min (DD x) |
Computes the minimum of this and another DD number. More... | |
DD | Max (DD x) |
Computes the maximum of this and another DD number. More... | |
DD | Floor () |
DD | Ceiling () |
int | Signum () |
Returns an integer indicating the sign of this value. More... | |
DD | 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:
| |
DD | Truncate () |
Returns the integer which is largest in absolute value and not further from zero than this value. Special cases:
| |
DD | Abs () |
Returns the absolute value of this value. Special cases:
| |
DD | Sqr () |
Computes the square of this value. More... | |
DD | Sqrt () |
DD | Pow (int exp) |
Computes the value of this number raised to an integral power. Follows semantics of .Net Math.Pow as closely as possible. More... | |
double | ToDoubleValue () |
int | ToIntValue () |
bool | IsPositive () |
Gets a value indicating whether this object is positive or not More... | |
bool | Equals (DD y) |
bool | GreaterThan (DD y) |
bool | GreaterOrEqualThan (DD y) |
bool | LessThan (DD y) |
Tests whether this value is less than another DoubleDouble value. More... | |
bool | LessOrEqualThan (DD y) |
int | CompareTo (DD other) |
int | CompareTo (Object o) |
String | Dump () |
Dumps the components of this number to a string. More... | |
override String | 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. More... | |
String | ToStandardNotation () |
Returns the string representation of this value in standard notation. More... | |
String | ToSciNotation () |
Returns the string representation of this value in scientific notation. More... | |
override bool | Equals (object obj) |
override int | GetHashCode () |
Static Public Member Functions | |
static DD | ValueOf (String str) |
Converts the string argument to a DoubleDouble number. More... | |
static | operator DD (String val) |
static DD | ValueOf (double x) |
static implicit | operator DD (Double val) |
static DD | Copy (DD dd) |
Creates a new DD with the value of the argument. More... | |
static DD | operator+ (DD lhs, DD rhs) |
Returns the sum of lhs and rhs . More... | |
static DD | operator+ (DD lhs, Double rhs) |
Returns the sum of lhs and rhs . More... | |
static DD | operator- (DD lhs, DD rhs) |
Returns the difference of lhs and rhs . More... | |
static DD | operator- (DD lhs, Double rhs) |
Returns the difference of lhs and rhs . More... | |
static DD | operator* (DD lhs, Double rhs) |
static DD | operator* (DD lhs, DD rhs) |
static DD | operator/ (DD lhs, Double rhs) |
static DD | operator/ (DD lhs, DD rhs) |
static DD | Sqr (double x) |
Computes the square of this value. More... | |
static DD | Sqrt (double x) |
static bool | IsNaN (DD value) |
Gets a value indicating whether this object is positive or not More... | |
static bool | operator== (DD lhs, DD rhs) |
static bool | operator!= (DD rhs, DD lhs) |
static DD | Parse (String str) |
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: More... | |
Static Public Attributes | |
static readonly DD | PI |
The value nearest to the constant Pi. More... | |
static readonly DD | TwoPi |
The value nearest to the constant 2 * Pi. More... | |
static readonly DD | PiHalf |
The value nearest to the constant Pi / 2. More... | |
static readonly DD | E |
The value nearest to the constant e (the natural logarithm base). More... | |
static readonly DD | NaN = new DD(Double.NaN, Double.NaN) |
A value representing the result of an operation which does not return a valid number. More... | |
static readonly double | Epsilon = 1.23259516440783e-32 |
The smallest representable relative difference between two DD values More... | |
Properties | |
bool | IsZero [get] |
Gets a value indicating whether this object is zero (0) or not More... | |
bool | IsNegative [get] |
Gets a value indicating whether this object is negative or not More... | |
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.
http://crd.lbl.gov/~dhbailey/mpdist/index.html
<author>Martin Davis</author>
NetTopologySuite.Mathematics.DD.DD | ( | double | x | ) |
Creates a new DD with value x.
x | The initial value |
NetTopologySuite.Mathematics.DD.DD | ( | double | hi, |
double | lo | ||
) |
Creates a new DD with value (hi, lo).
hi | The high order component |
lo | The low order component |
NetTopologySuite.Mathematics.DD.DD | ( | DD | dd | ) |
Creates a DD with a value equal to the argument
dd | The initial value |
NetTopologySuite.Mathematics.DD.DD | ( | String | str | ) |
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 |
DD NetTopologySuite.Mathematics.DD.Abs | ( | ) |
Returns the absolute value of this value. Special cases:
Returns a DD whose value is (this + y )
y | The addende |
"/> <returns><c>(this + <paramref name="y"/>)
DD NetTopologySuite.Mathematics.DD.Add | ( | double | y | ) |
DD NetTopologySuite.Mathematics.DD.Ceiling | ( | ) |
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 NetTopologySuite.Mathematics.DD.Clone | ( | ) |
Creates and returns a copy of this value.
int NetTopologySuite.Mathematics.DD.CompareTo | ( | DD | other | ) |
Compares two DoubleDouble objects numerically.
o
DD NetTopologySuite.Mathematics.DD.Divide | ( | double | y | ) |
String NetTopologySuite.Mathematics.DD.Dump | ( | ) |
Dumps the components of this number to a string.
bool NetTopologySuite.Mathematics.DD.Equals | ( | DD | y | ) |
Tests whether this value is equal to another DoubleDouble
value.
y | a DoubleDouble value |
DD NetTopologySuite.Mathematics.DD.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:
bool NetTopologySuite.Mathematics.DD.GreaterOrEqualThan | ( | DD | y | ) |
Tests whether this value is greater than or equals to another DoubleDouble
value.
y | a DoubleDouble value |
bool NetTopologySuite.Mathematics.DD.GreaterThan | ( | DD | y | ) |
Tests whether this value is greater than another DoubleDouble
value.
y | a DoubleDouble value |
|
static |
Gets a value indicating whether this object is positive or not
bool NetTopologySuite.Mathematics.DD.IsPositive | ( | ) |
Gets a value indicating whether this object is positive or not
bool NetTopologySuite.Mathematics.DD.LessOrEqualThan | ( | DD | y | ) |
Tests whether this value is less than or equal to another DoubleDouble
value.
y | a DoubleDouble value |
bool NetTopologySuite.Mathematics.DD.LessThan | ( | DD | y | ) |
Tests whether this value is less than another DoubleDouble
value.
y | A DoubleDouble value |
true
if this value is < y Returns a new DoubleDouble whose value is (this * y)
.
y | the multiplicand |
(this * y)
DD NetTopologySuite.Mathematics.DD.Multiply | ( | double | y | ) |
Returns a new DoubleDouble whose value is (this * y)
.
y | the multiplicand |
(this * y)
DD NetTopologySuite.Mathematics.DD.Negate | ( | ) |
Returns a DD whose value is -this
.
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 |
this
. To prevent altering constants, this method must only be used on values known to be newly created.y | the addend |
-this
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 |
this
. To prevent altering constants, this method must only be used on values known to be newly created.y | the value to multiply by |
Returns the sum of lhs and rhs .
lhs | The left hand side |
rhs | The right hand side |
Returns the sum of lhs and rhs .
lhs | The left hand side |
rhs | The right hand side |
Returns the difference of lhs and rhs .
lhs | The left hand side |
rhs | The right hand side |
Returns the difference of lhs and rhs .
lhs | The left hand side |
rhs | The right hand side |
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 |
|
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 |
FormatException | Thrown if str is not a valid representation of a number |
DD NetTopologySuite.Mathematics.DD.Pow | ( | int | exp | ) |
Computes the value of this number raised to an integral power. Follows semantics of .Net Math.Pow as closely as possible.
exp | The integer exponent |
DD NetTopologySuite.Mathematics.DD.Reciprocal | ( | ) |
Returns a DoubleDouble whose value is 1 / this
.
DD NetTopologySuite.Mathematics.DD.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:
int NetTopologySuite.Mathematics.DD.Signum | ( | ) |
Returns an integer indicating the sign of this value.
DD NetTopologySuite.Mathematics.DD.Sqr | ( | ) |
Computes the square of this value.
|
static |
Computes the square of this value.
DD NetTopologySuite.Mathematics.DD.Sqrt | ( | ) |
Computes the positive square root of this value. If the number is NaN or negative, NaN is returned.
DD NetTopologySuite.Mathematics.DD.Subtract | ( | double | y | ) |
double NetTopologySuite.Mathematics.DD.ToDoubleValue | ( | ) |
Converts this value to the nearest double-precision number.
int NetTopologySuite.Mathematics.DD.ToIntValue | ( | ) |
Converts this value to the nearest integer.
String NetTopologySuite.Mathematics.DD.ToSciNotation | ( | ) |
Returns the string representation of this value in scientific notation.
String NetTopologySuite.Mathematics.DD.ToStandardNotation | ( | ) |
Returns the string representation of this value in standard notation.
override String NetTopologySuite.Mathematics.DD.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.
DD NetTopologySuite.Mathematics.DD.Truncate | ( | ) |
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 |
FormatException | Thrown if str 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 DD values
A value representing the result of an operation which does not return a valid number.
|
static |
The value nearest to the constant Pi.
|
static |
The value nearest to the constant Pi / 2.
|
static |
The value nearest to the constant 2 * Pi.
|
get |
Gets a value indicating whether this object is negative or not
|
get |
Gets a value indicating whether this object is zero (0) or not