02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Basics<br />

Max - This method returns maximum value from enumerable collection. The input to this<br />

function can be a one, two, or three dimensional array or an IEnumerator iter.<br />

int[ ] intArray = new int[4]{1,5,3,2};<br />

Algorithm.Max(intArray);<br />

// result is 5<br />

Min - This method returns minimum value from enumerable collection. The input to this<br />

function can be a one, two, or three dimensional array or an IEnumerator.<br />

int[ ] intArray = new int[4]{1,5,3,2};<br />

Algorithm.Min(intArray);<br />

// result is 1<br />

NarrowToInterval – This function narrows an object to fit an interval. Here the object<br />

could be an Index2, Index3, or any T. This returns an object narrowed inside the<br />

interval [low, high].<br />

Algorithm.NarrowToInterval(5, 1,4);<br />

// result is 4<br />

Index2 i1 = new Index2(-1, 5);<br />

Index2 iLow = new Index2(0, 1);<br />

Index2 iHigh = new Index2(3, 4);<br />

Algorithm.NarrowToInterval(i1, iLow, iHigh);<br />

// result is Index2 (0,4)<br />

LargerMultiple – This method takes two integer arguments, m and n, and computes<br />

the larger (round away from 0) increment of n after m. We compute the multiples of “n”<br />

and find that which is closest to the value for “m” but not between 0 and “m”. Consider an<br />

“m” value of 3 and an “n” value of 2. The multiples of 2 are 0, 2, 4, 6, 8, ... The multiple<br />

that is beyond the “m” value of 3 is 4. Likewise if we use an “m” value of -3 the result<br />

would be -4. The value for “n” must be greater than 0.<br />

Algorithm.LargerMultiple(3, 2);<br />

// result is 4<br />

Algorithm.LargerMultiple(10, 20);<br />

// result is 20<br />

Algorithm.LargerMultiple(-8, 5);<br />

// result is -10<br />

<strong>Schlumberger</strong> Private<br />

<strong>Ocean</strong> Services 4-129

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

Saved successfully!

Ooh no, something went wrong!