NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
NetTopologySuite.Mathematics.DD Struct Reference

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...

Inheritance diagram for NetTopologySuite.Mathematics.DD:

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:

  • If this value is NaN, returns NaN.
More...
 
DD Truncate ()
 Returns the integer which is largest in absolute value and not further from zero than this value. Special cases:

  • If this value is NaN, returns NaN.
More...
 
DD Abs ()
 Returns the absolute value of this value. Special cases:

  • if this value is NaN, it is returned.
More...
 
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...
 

Detailed Description

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.

References

  • Priest, D., Algorithms for Arbitrary Precision Floating Point Arithmetic, in P. Kornerup and D. Matula, Eds., Proc. 10th Symposium on Computer Arithmetic, IEEE Computer Society Press, Los Alamitos, Calif., 1991.
  • Yozo Hida, Xiaoye S. Li and David H. Bailey, Quad-Double Arithmetic: Algorithms, Implementation, and Application, manuscript, Oct 2000; Lawrence Berkeley National Laboratory Report BNL-46996.
  • David Bailey, High Precision Software Directory; http://crd.lbl.gov/~dhbailey/mpdist/index.html

<author>Martin Davis</author>

Constructor & Destructor Documentation

NetTopologySuite.Mathematics.DD.DD ( double  x)

Creates a new DD with value x.

Parameters
xThe initial value
NetTopologySuite.Mathematics.DD.DD ( double  hi,
double  lo 
)

Creates a new DD with value (hi, lo).

Parameters
hiThe high order component
loThe low order component
NetTopologySuite.Mathematics.DD.DD ( DD  dd)

Creates a DD with a value equal to the argument

Parameters
ddThe initial value
NetTopologySuite.Mathematics.DD.DD ( String  str)

Creates a new DoubleDouble with value equal to the argument.

Parameters
strthe value to initialize by
Exceptions
NumberFormatExceptionif str is not a valid representation of a number

Member Function Documentation

DD NetTopologySuite.Mathematics.DD.Abs ( )

Returns the absolute value of this value. Special cases:

  • if this value is NaN, it is returned.

Returns
The absolute value of this value
DD NetTopologySuite.Mathematics.DD.Add ( DD  y)

Returns a DD whose value is (this + y )

Parameters
yThe addende

"/> <returns><c>(this + <paramref name="y"/>)

DD NetTopologySuite.Mathematics.DD.Add ( double  y)

Returns a DD whose value is (this + y).

Parameters
yThe addend
Returns
(this + 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:

  • If this value is NaN, returns NaN.
Returns
the smallest (closest to negative infinity) value that is not less than the argument and is equal to a mathematical integer.
Object NetTopologySuite.Mathematics.DD.Clone ( )

Creates and returns a copy of this value.

Returns
Acopy of this value
int NetTopologySuite.Mathematics.DD.CompareTo ( DD  other)

Compares two DoubleDouble objects numerically.

Returns
-1,0 or 1 depending on whether this value is less than, equal to or greater than the value of o
static DD NetTopologySuite.Mathematics.DD.Copy ( DD  dd)
static

Creates a new DD with the value of the argument.

Parameters
ddThe value to copy
Returns
A copy of dd
DD NetTopologySuite.Mathematics.DD.Divide ( DD  y)

Computes a new DD whose value is (this / y).

Parameters
yThe divisor
Returns
A new DD with the value (this / y)
DD NetTopologySuite.Mathematics.DD.Divide ( double  y)

Computes a new DD whose value is (this / y).

Parameters
yThe divisor
Returns
A new DD with the value (this / y)
String NetTopologySuite.Mathematics.DD.Dump ( )

Dumps the components of this number to a string.

Returns
A string showing the components of the number
bool NetTopologySuite.Mathematics.DD.Equals ( DD  y)

Tests whether this value is equal to another DoubleDouble value.

Parameters
ya DoubleDouble value
Returns
true if this value = y
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:

  • If this value is NaN, returns NaN.
Returns
the largest (closest to positive infinity) value that is not greater than the argument and is equal to a mathematical integer.
bool NetTopologySuite.Mathematics.DD.GreaterOrEqualThan ( DD  y)

Tests whether this value is greater than or equals to another DoubleDouble value.

Parameters
ya DoubleDouble value
Returns
true if this value >= y
bool NetTopologySuite.Mathematics.DD.GreaterThan ( DD  y)

Tests whether this value is greater than another DoubleDouble value.

Parameters
ya DoubleDouble value
Returns
true if this value > y
static bool NetTopologySuite.Mathematics.DD.IsNaN ( DD  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.

Parameters
ya DoubleDouble value
Returns
true if this value <= y
bool NetTopologySuite.Mathematics.DD.LessThan ( DD  y)

Tests whether this value is less than another DoubleDouble value.

Parameters
yA DoubleDouble value
Returns
true if this value is < y
DD NetTopologySuite.Mathematics.DD.Max ( DD  x)

Computes the maximum of this and another DD number.

Parameters
xA DD number
Returns
The maximum of the two numbers
DD NetTopologySuite.Mathematics.DD.Min ( DD  x)

Computes the minimum of this and another DD number.

Parameters
xA DD number
Returns
The minimum of the two numbers
DD NetTopologySuite.Mathematics.DD.Multiply ( DD  y)

Returns a new DoubleDouble whose value is (this * y).

Parameters
ythe multiplicand
Returns
(this * y)
DD NetTopologySuite.Mathematics.DD.Multiply ( double  y)

Returns a new DoubleDouble whose value is (this * y).

Parameters
ythe multiplicand
Returns
(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.

Parameters
ythe addend
Returns
this object, decreased by 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.
Parameters
ythe addend
Returns
this object, decreased by y
Returns
-this
static DD NetTopologySuite.Mathematics.DD.operator* ( DD  lhs,
Double  rhs 
)
static

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.

Parameters
ythe value to multiply by
Returns
this object, multiplied by 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.
Parameters
ythe value to multiply by
Returns
this object, multiplied by y
static DD NetTopologySuite.Mathematics.DD.operator+ ( DD  lhs,
DD  rhs 
)
static

Returns the sum of lhs and rhs .

Parameters
lhsThe left hand side
rhsThe right hand side
Returns
The sum of lhs and rhs
static DD NetTopologySuite.Mathematics.DD.operator+ ( DD  lhs,
Double  rhs 
)
static

Returns the sum of lhs and rhs .

Parameters
lhsThe left hand side
rhsThe right hand side
Returns
The sum of lhs and rhs
static DD NetTopologySuite.Mathematics.DD.operator- ( DD  lhs,
DD  rhs 
)
static

Returns the difference of lhs and rhs .

Parameters
lhsThe left hand side
rhsThe right hand side
Returns
The difference of lhs and rhs
static DD NetTopologySuite.Mathematics.DD.operator- ( DD  lhs,
Double  rhs 
)
static

Returns the difference of lhs and rhs .

Parameters
lhsThe left hand side
rhsThe right hand side
Returns
The difference of lhs and rhs
static DD NetTopologySuite.Mathematics.DD.operator/ ( DD  lhs,
Double  rhs 
)
static

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.

Parameters
ythe value to divide by
Returns
this object, divided by y
static DD NetTopologySuite.Mathematics.DD.Parse ( String  str)
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}+
Parameters
strThe string to parse
Returns
The value of the parsed number
Exceptions
FormatExceptionThrown 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.

Parameters
expThe integer exponent
Returns
x raised to the integral power exp
DD NetTopologySuite.Mathematics.DD.Reciprocal ( )

Returns a DoubleDouble whose value is 1 / this.

Returns
the reciprocal of this value
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:

  • If this value is NaN, returns NaN.

Returns
This value rounded to the nearest integer
int NetTopologySuite.Mathematics.DD.Signum ( )

Returns an integer indicating the sign of this value.

  • if this value is > 0, returns 1
  • if this value is < 0, returns -1
  • if this value is = 0, returns 0
  • if this value is NaN, returns 0
Returns
An integer indicating the sign of this value
DD NetTopologySuite.Mathematics.DD.Sqr ( )

Computes the square of this value.

Returns
The square of this value
static DD NetTopologySuite.Mathematics.DD.Sqr ( double  x)
static

Computes the square of this value.

Returns
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.

Returns
the positive square root of this number. If the argument is NaN or less than zero, the result is NaN.
DD NetTopologySuite.Mathematics.DD.Subtract ( DD  y)

Computes a new DD object whose value is (this - y).

Parameters
yThe subtrahend
Returns
(this - y)
DD NetTopologySuite.Mathematics.DD.Subtract ( double  y)

Computes a new DD object whose value is (this - y).

Parameters
yThe subtrahend
Returns
(this - y)
double NetTopologySuite.Mathematics.DD.ToDoubleValue ( )

Converts this value to the nearest double-precision number.

Returns
the nearest double-precision number to this value
int NetTopologySuite.Mathematics.DD.ToIntValue ( )

Converts this value to the nearest integer.

Returns
the nearest integer to this value
String NetTopologySuite.Mathematics.DD.ToSciNotation ( )

Returns the string representation of this value in scientific notation.

Returns
The string representation in scientific notation
String NetTopologySuite.Mathematics.DD.ToStandardNotation ( )

Returns the string representation of this value in standard notation.

Returns
The string representation 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.

Returns
A string representation of this number
DD NetTopologySuite.Mathematics.DD.Truncate ( )

Returns the integer which is largest in absolute value and not further from zero than this value. Special cases:

  • If this value is NaN, returns NaN.

Returns
The integer which is largest in absolute value and not further from zero than this value
static DD NetTopologySuite.Mathematics.DD.ValueOf ( String  str)
static

Converts the string argument to a DoubleDouble number.

Parameters
strA string containing a representation of a numeric value
Returns
The extended precision version of the value
Exceptions
FormatExceptionThrown if str is not a valid representation of a number
static DD NetTopologySuite.Mathematics.DD.ValueOf ( double  x)
static

Converts the double argument to a DoubleDouble number.

Parameters
xa numeric value
Returns
the extended precision version of the value

Member Data Documentation

readonly DD NetTopologySuite.Mathematics.DD.E
static
Initial value:
= new DD(
2.718281828459045091e+00,
1.445646891729250158e-16)

The value nearest to the constant e (the natural logarithm base).

readonly double NetTopologySuite.Mathematics.DD.Epsilon = 1.23259516440783e-32
static

The smallest representable relative difference between two DD values

readonly DD NetTopologySuite.Mathematics.DD.NaN = new DD(Double.NaN, Double.NaN)
static

A value representing the result of an operation which does not return a valid number.

readonly DD NetTopologySuite.Mathematics.DD.PI
static
Initial value:
= new DD(
3.141592653589793116e+00,
1.224646799147353207e-16)

The value nearest to the constant Pi.

readonly DD NetTopologySuite.Mathematics.DD.PiHalf
static
Initial value:
= new DD(
1.570796326794896558e+00,
6.123233995736766036e-17)

The value nearest to the constant Pi / 2.

readonly DD NetTopologySuite.Mathematics.DD.TwoPi
static
Initial value:
= new DD(
6.283185307179586232e+00,
2.449293598294706414e-16)

The value nearest to the constant 2 * Pi.

Property Documentation

bool NetTopologySuite.Mathematics.DD.IsNegative
get

Gets a value indicating whether this object is negative or not

bool NetTopologySuite.Mathematics.DD.IsZero
get

Gets a value indicating whether this object is zero (0) or not


The documentation for this struct was generated from the following file: