02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Basics<br />

Formula: ||x|-|y||/(1 + (|x|+|y|)/2) less than eps.<br />

Algorithm.AlmostEqual(2, 2)<br />

// result is true<br />

Algorithm.AlmostEqual(2.001, 2.002)<br />

// result is false<br />

Algorithm.AlmostEqual(2.001, 2.002, 0.01)<br />

// result is true<br />

GreatestCommonDivisor - This method computes the largest common divisor.<br />

Algorithm.GreatestCommonDivisor(2, 4)<br />

// result is 2<br />

Hasher - This method generates hash code for a variable number of arguments. Apply<br />

scatterer to avoid clustering. The hash scatterer will spread groups of integers that are<br />

close through the entire range of an int.<br />

int[ ] intArgs = new int[4]{0,3,1,6};<br />

int hc = Algorithm.Hasher(intArgs);<br />

Hypotenuse - This method uses Pythagoras' equation to calculate the hypotenuse. It<br />

returns the distance along the hypotenuse.<br />

Algorithm.Hypotenuse(1.1, 3.1)<br />

// result is 3.28937684067971<br />

InsideInterval - This method tests if an object is within an interval. Returns true if x<br />

is inside the interval [low, high].<br />

Algorithm.InsideInterval(4, 3, 5)<br />

// result is true<br />

Range1 intRange = new Range1(3, 5);<br />

Algorithm.InsideInterval(3, intRange)<br />

// result is true<br />

Algorithm.InsideInterval(2, intRange)<br />

// result is false<br />

4-128 <strong>Ocean</strong> Application Development Framework 2008.1<br />

<strong>Schlumberger</strong> Private

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!