blob: 696a263ccecd2d31feba5b86ab1c312e02c06333 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>MathUtils</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="MathUtils";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9,"i3":9,"i4":9,"i5":9,"i6":9,"i7":9,"i8":9,"i9":9,"i10":9,"i11":9,"i12":9,"i13":9,"i14":9,"i15":9,"i16":9,"i17":9,"i18":9,"i19":9,"i20":9,"i21":9,"i22":9,"i23":9,"i24":9,"i25":9,"i26":9,"i27":9,"i28":9,"i29":9,"i30":9,"i31":9,"i32":9,"i33":9,"i34":9,"i35":9,"i36":9,"i37":9,"i38":9,"i39":9,"i40":9,"i41":9,"i42":9,"i43":9,"i44":9,"i45":9,"i46":9,"i47":9,"i48":9,"i49":9,"i50":9,"i51":9,"i52":9,"i53":9,"i54":9,"i55":9,"i56":9,"i57":9,"i58":9,"i59":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/openejb/math/util/DoubleArray.html" title="interface in org.apache.openejb.math.util"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/openejb/math/util/ResizableDoubleArray.html" title="class in org.apache.openejb.math.util"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/openejb/math/util/MathUtils.html" target="_top">Frames</a></li>
<li><a href="MathUtils.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.openejb.math.util</div>
<h2 title="Class MathUtils" class="title">Class MathUtils</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.openejb.math.util.MathUtils</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public final class <span class="typeNameLabel">MathUtils</span>
extends java.lang.Object</pre>
<div class="block">Some useful additions to the built-in functions in <code>Math</code>.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.summary">
<!-- -->
</a>
<h3>Field Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#EPSILON">EPSILON</a></span></code>
<div class="block">Smallest positive number such that 1 - EPSILON is not numerically equal to 1.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#SAFE_MIN">SAFE_MIN</a></span></code>
<div class="block">Safe minimum, such that 1 / SAFE_MIN does not overflow.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#TWO_PI">TWO_PI</a></span></code>
<div class="block">2 &pi;.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#addAndCheck-int-int-">addAndCheck</a></span>(int&nbsp;x,
int&nbsp;y)</code>
<div class="block">Add two integers, checking for overflow.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#addAndCheck-long-long-">addAndCheck</a></span>(long&nbsp;a,
long&nbsp;b)</code>
<div class="block">Add two long integers, checking for overflow.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#binomialCoefficient-int-int-">binomialCoefficient</a></span>(int&nbsp;n,
int&nbsp;k)</code>
<div class="block">Returns an exact representation of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.</div>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#binomialCoefficientDouble-int-int-">binomialCoefficientDouble</a></span>(int&nbsp;n,
int&nbsp;k)</code>
<div class="block">Returns a <code>double</code> representation of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#binomialCoefficientLog-int-int-">binomialCoefficientLog</a></span>(int&nbsp;n,
int&nbsp;k)</code>
<div class="block">Returns the natural <code>log</code> of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>static void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#checkOrder-double:A-int-boolean-">checkOrder</a></span>(double[]&nbsp;val,
int&nbsp;dir,
boolean&nbsp;strict)</code>
<div class="block">Checks that the given array is sorted.</div>
</td>
</tr>
<tr id="i6" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#compareTo-double-double-double-">compareTo</a></span>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Compares two numbers given some amount of allowed error.</div>
</td>
</tr>
<tr id="i7" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#cosh-double-">cosh</a></span>(double&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
hyperbolic cosine</a> of x.</div>
</td>
</tr>
<tr id="i8" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distance-double:A-double:A-">distance</a></span>(double[]&nbsp;p1,
double[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>2</sub> (Euclidean) distance between two points.</div>
</td>
</tr>
<tr id="i9" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distance-int:A-int:A-">distance</a></span>(int[]&nbsp;p1,
int[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>2</sub> (Euclidean) distance between two points.</div>
</td>
</tr>
<tr id="i10" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distance1-double:A-double:A-">distance1</a></span>(double[]&nbsp;p1,
double[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>1</sub> (sum of abs) distance between two points.</div>
</td>
</tr>
<tr id="i11" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distance1-int:A-int:A-">distance1</a></span>(int[]&nbsp;p1,
int[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>1</sub> (sum of abs) distance between two points.</div>
</td>
</tr>
<tr id="i12" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distanceInf-double:A-double:A-">distanceInf</a></span>(double[]&nbsp;p1,
double[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>&infin;</sub> (max of abs) distance between two points.</div>
</td>
</tr>
<tr id="i13" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#distanceInf-int:A-int:A-">distanceInf</a></span>(int[]&nbsp;p1,
int[]&nbsp;p2)</code>
<div class="block">Calculates the L<sub>&infin;</sub> (max of abs) distance between two points.</div>
</td>
</tr>
<tr id="i14" class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double:A-double:A-">equals</a></span>(double[]&nbsp;x,
double[]&nbsp;y)</code>
<div class="block">Returns true iff both arguments are null or have same dimensions
and all their elements are <a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-"><code>equals</code></a></div>
</td>
</tr>
<tr id="i15" class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-">equals</a></span>(double&nbsp;x,
double&nbsp;y)</code>
<div class="block">Returns true iff both arguments are NaN or neither is NaN and they are
equal</div>
</td>
</tr>
<tr id="i16" class="altColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-double-">equals</a></span>(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</code>
<div class="block">Returns true iff both arguments are equal or within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr id="i17" class="rowColor">
<td class="colFirst"><code>static boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-int-">equals</a></span>(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</code>
<div class="block">Returns true iff both arguments are equal or within the range of allowed
error (inclusive).</div>
</td>
</tr>
<tr id="i18" class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#factorial-int-">factorial</a></span>(int&nbsp;n)</code>
<div class="block">Returns n!.</div>
</td>
</tr>
<tr id="i19" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#factorialDouble-int-">factorialDouble</a></span>(int&nbsp;n)</code>
<div class="block">Returns n!.</div>
</td>
</tr>
<tr id="i20" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#factorialLog-int-">factorialLog</a></span>(int&nbsp;n)</code>
<div class="block">Returns the natural logarithm of n!.</div>
</td>
</tr>
<tr id="i21" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#gcd-int-int-">gcd</a></span>(int&nbsp;p,
int&nbsp;q)</code>
<div class="block">
Gets the greatest common divisor of the absolute value of two numbers,
using the "binary gcd" method which avoids division and modulo
operations.</div>
</td>
</tr>
<tr id="i22" class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#gcd-long-long-">gcd</a></span>(long&nbsp;p,
long&nbsp;q)</code>
<div class="block">
Gets the greatest common divisor of the absolute value of two numbers,
using the "binary gcd" method which avoids division and modulo
operations.</div>
</td>
</tr>
<tr id="i23" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#hash-double-">hash</a></span>(double&nbsp;value)</code>
<div class="block">Returns an integer hash code representing the given double value.</div>
</td>
</tr>
<tr id="i24" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#hash-double:A-">hash</a></span>(double[]&nbsp;value)</code>
<div class="block">Returns an integer hash code representing the given double array.</div>
</td>
</tr>
<tr id="i25" class="rowColor">
<td class="colFirst"><code>static byte</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-byte-">indicator</a></span>(byte&nbsp;x)</code>
<div class="block">For a byte value x, this method returns (byte)(+1) if x >= 0 and
(byte)(-1) if x < 0.</div>
</td>
</tr>
<tr id="i26" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-double-">indicator</a></span>(double&nbsp;x)</code>
<div class="block">For a double precision value x, this method returns +1.0 if x >= 0 and
-1.0 if x < 0.</div>
</td>
</tr>
<tr id="i27" class="rowColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-float-">indicator</a></span>(float&nbsp;x)</code>
<div class="block">For a float value x, this method returns +1.0F if x >= 0 and -1.0F if x <
0.</div>
</td>
</tr>
<tr id="i28" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-int-">indicator</a></span>(int&nbsp;x)</code>
<div class="block">For an int value x, this method returns +1 if x >= 0 and -1 if x < 0.</div>
</td>
</tr>
<tr id="i29" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-long-">indicator</a></span>(long&nbsp;x)</code>
<div class="block">For a long value x, this method returns +1L if x >= 0 and -1L if x < 0.</div>
</td>
</tr>
<tr id="i30" class="altColor">
<td class="colFirst"><code>static short</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#indicator-short-">indicator</a></span>(short&nbsp;x)</code>
<div class="block">For a short value x, this method returns (short)(+1) if x >= 0 and
(short)(-1) if x < 0.</div>
</td>
</tr>
<tr id="i31" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#lcm-int-int-">lcm</a></span>(int&nbsp;a,
int&nbsp;b)</code>
<div class="block">
Returns the least common multiple of the absolute value of two numbers,
using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.</div>
</td>
</tr>
<tr id="i32" class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#lcm-long-long-">lcm</a></span>(long&nbsp;a,
long&nbsp;b)</code>
<div class="block">
Returns the least common multiple of the absolute value of two numbers,
using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.</div>
</td>
</tr>
<tr id="i33" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#log-double-double-">log</a></span>(double&nbsp;base,
double&nbsp;x)</code>
<div class="block">Returns the
<a href="http://mathworld.wolfram.com/Logarithm.html">logarithm</a>
for base <code>b</code> of <code>x</code>.</div>
</td>
</tr>
<tr id="i34" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#mulAndCheck-int-int-">mulAndCheck</a></span>(int&nbsp;x,
int&nbsp;y)</code>
<div class="block">Multiply two integers, checking for overflow.</div>
</td>
</tr>
<tr id="i35" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#mulAndCheck-long-long-">mulAndCheck</a></span>(long&nbsp;a,
long&nbsp;b)</code>
<div class="block">Multiply two long integers, checking for overflow.</div>
</td>
</tr>
<tr id="i36" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#nextAfter-double-double-">nextAfter</a></span>(double&nbsp;d,
double&nbsp;direction)</code>
<div class="block">Get the next machine representable number after a number, moving
in the direction of another number.</div>
</td>
</tr>
<tr id="i37" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#normalizeAngle-double-double-">normalizeAngle</a></span>(double&nbsp;a,
double&nbsp;center)</code>
<div class="block">Normalize an angle in a 2&pi wide interval around a center value.</div>
</td>
</tr>
<tr id="i38" class="altColor">
<td class="colFirst"><code>static double[]</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#normalizeArray-double:A-double-">normalizeArray</a></span>(double[]&nbsp;values,
double&nbsp;normalizedSum)</code>
<div class="block">Normalizes an array to make it sum to a specified value.</div>
</td>
</tr>
<tr id="i39" class="rowColor">
<td class="colFirst"><code>static java.math.BigInteger</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-java.math.BigInteger-java.math.BigInteger-">pow</a></span>(java.math.BigInteger&nbsp;k,
java.math.BigInteger&nbsp;e)</code>
<div class="block">Raise a BigInteger to a BigInteger power.</div>
</td>
</tr>
<tr id="i40" class="altColor">
<td class="colFirst"><code>static java.math.BigInteger</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-java.math.BigInteger-int-">pow</a></span>(java.math.BigInteger&nbsp;k,
int&nbsp;e)</code>
<div class="block">Raise a BigInteger to an int power.</div>
</td>
</tr>
<tr id="i41" class="rowColor">
<td class="colFirst"><code>static java.math.BigInteger</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-java.math.BigInteger-long-">pow</a></span>(java.math.BigInteger&nbsp;k,
long&nbsp;e)</code>
<div class="block">Raise a BigInteger to a long power.</div>
</td>
</tr>
<tr id="i42" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-int-int-">pow</a></span>(int&nbsp;k,
int&nbsp;e)</code>
<div class="block">Raise an int to an int power.</div>
</td>
</tr>
<tr id="i43" class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-int-long-">pow</a></span>(int&nbsp;k,
long&nbsp;e)</code>
<div class="block">Raise an int to a long power.</div>
</td>
</tr>
<tr id="i44" class="altColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-long-int-">pow</a></span>(long&nbsp;k,
int&nbsp;e)</code>
<div class="block">Raise a long to an int power.</div>
</td>
</tr>
<tr id="i45" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#pow-long-long-">pow</a></span>(long&nbsp;k,
long&nbsp;e)</code>
<div class="block">Raise a long to a long power.</div>
</td>
</tr>
<tr id="i46" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#round-double-int-">round</a></span>(double&nbsp;x,
int&nbsp;scale)</code>
<div class="block">Round the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr id="i47" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#round-double-int-int-">round</a></span>(double&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</code>
<div class="block">Round the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr id="i48" class="altColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#round-float-int-">round</a></span>(float&nbsp;x,
int&nbsp;scale)</code>
<div class="block">Round the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr id="i49" class="rowColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#round-float-int-int-">round</a></span>(float&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</code>
<div class="block">Round the given value to the specified number of decimal places.</div>
</td>
</tr>
<tr id="i50" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#scalb-double-int-">scalb</a></span>(double&nbsp;d,
int&nbsp;scaleFactor)</code>
<div class="block">Scale a number by 2<sup>scaleFactor</sup>.</div>
</td>
</tr>
<tr id="i51" class="rowColor">
<td class="colFirst"><code>static byte</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-byte-">sign</a></span>(byte&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for byte value <code>x</code>.</div>
</td>
</tr>
<tr id="i52" class="altColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-double-">sign</a></span>(double&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for double precision <code>x</code>.</div>
</td>
</tr>
<tr id="i53" class="rowColor">
<td class="colFirst"><code>static float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-float-">sign</a></span>(float&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for float value <code>x</code>.</div>
</td>
</tr>
<tr id="i54" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-int-">sign</a></span>(int&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for int value <code>x</code>.</div>
</td>
</tr>
<tr id="i55" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-long-">sign</a></span>(long&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for long value <code>x</code>.</div>
</td>
</tr>
<tr id="i56" class="altColor">
<td class="colFirst"><code>static short</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sign-short-">sign</a></span>(short&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for short value <code>x</code>.</div>
</td>
</tr>
<tr id="i57" class="rowColor">
<td class="colFirst"><code>static double</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#sinh-double-">sinh</a></span>(double&nbsp;x)</code>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
hyperbolic sine</a> of x.</div>
</td>
</tr>
<tr id="i58" class="altColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#subAndCheck-int-int-">subAndCheck</a></span>(int&nbsp;x,
int&nbsp;y)</code>
<div class="block">Subtract two integers, checking for overflow.</div>
</td>
</tr>
<tr id="i59" class="rowColor">
<td class="colFirst"><code>static long</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/openejb/math/util/MathUtils.html#subAndCheck-long-long-">subAndCheck</a></span>(long&nbsp;a,
long&nbsp;b)</code>
<div class="block">Subtract two long integers, checking for overflow.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field.detail">
<!-- -->
</a>
<h3>Field Detail</h3>
<a name="EPSILON">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>EPSILON</h4>
<pre>public static final&nbsp;double EPSILON</pre>
<div class="block">Smallest positive number such that 1 - EPSILON is not numerically equal to 1.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.apache.openejb.math.util.MathUtils.EPSILON">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="SAFE_MIN">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SAFE_MIN</h4>
<pre>public static final&nbsp;double SAFE_MIN</pre>
<div class="block">Safe minimum, such that 1 / SAFE_MIN does not overflow.
<p>In IEEE 754 arithmetic, this is also the smallest normalized
number 2<sup>-1022</sup>.</p></div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.apache.openejb.math.util.MathUtils.SAFE_MIN">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="TWO_PI">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>TWO_PI</h4>
<pre>public static final&nbsp;double TWO_PI</pre>
<div class="block">2 &pi;.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../../../constant-values.html#org.apache.openejb.math.util.MathUtils.TWO_PI">Constant Field Values</a></dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="addAndCheck-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addAndCheck</h4>
<pre>public static&nbsp;int&nbsp;addAndCheck(int&nbsp;x,
int&nbsp;y)</pre>
<div class="block">Add two integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - an addend</dd>
<dd><code>y</code> - an addend</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the sum <code>x+y</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
int</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="addAndCheck-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>addAndCheck</h4>
<pre>public static&nbsp;long&nbsp;addAndCheck(long&nbsp;a,
long&nbsp;b)</pre>
<div class="block">Add two long integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - an addend</dd>
<dd><code>b</code> - an addend</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the sum <code>a+b</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
long</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="binomialCoefficient-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficient</h4>
<pre>public static&nbsp;long&nbsp;binomialCoefficient(int&nbsp;n,
int&nbsp;k)</pre>
<div class="block">Returns an exact representation of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>0 <= k <= n </code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
<li> The result is small enough to fit into a <code>long</code>. The
largest value of <code>n</code> for which all coefficients are
<code> < Long.MAX_VALUE</code> is 66. If the computed value exceeds
<code>Long.MAX_VALUE</code> an <code>ArithMeticException</code> is
thrown.</li>
</ul></p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - the size of the set</dd>
<dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n choose k</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if preconditions are not met.</dd>
<dd><code>java.lang.ArithmeticException</code> - if the result is too large to be represented
by a long integer.</dd>
</dl>
</li>
</ul>
<a name="binomialCoefficientDouble-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficientDouble</h4>
<pre>public static&nbsp;double&nbsp;binomialCoefficientDouble(int&nbsp;n,
int&nbsp;k)</pre>
<div class="block">Returns a <code>double</code> representation of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>0 <= k <= n </code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
<li> The result is small enough to fit into a <code>double</code>. The
largest value of <code>n</code> for which all coefficients are <
Double.MAX_VALUE is 1029. If the computed value exceeds Double.MAX_VALUE,
Double.POSITIVE_INFINITY is returned</li>
</ul></p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - the size of the set</dd>
<dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n choose k</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if preconditions are not met.</dd>
</dl>
</li>
</ul>
<a name="binomialCoefficientLog-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>binomialCoefficientLog</h4>
<pre>public static&nbsp;double&nbsp;binomialCoefficientLog(int&nbsp;n,
int&nbsp;k)</pre>
<div class="block">Returns the natural <code>log</code> of the <a
href="http://mathworld.wolfram.com/BinomialCoefficient.html"> Binomial
Coefficient</a>, "<code>n choose k</code>", the number of
<code>k</code>-element subsets that can be selected from an
<code>n</code>-element set.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>0 <= k <= n </code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
</ul></p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - the size of the set</dd>
<dd><code>k</code> - the size of the subsets to be counted</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n choose k</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if preconditions are not met.</dd>
</dl>
</li>
</ul>
<a name="compareTo-double-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>compareTo</h4>
<pre>public static&nbsp;int&nbsp;compareTo(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Compares two numbers given some amount of allowed error.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the first number</dd>
<dd><code>y</code> - the second number</dd>
<dd><code>eps</code> - the amount of error to allow when checking for equality</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><ul><li>0 if <a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-double-"><code>equals(x, y, eps)</code></a></li>
<li>&lt; 0 if !<a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-double-"><code>equals(x, y, eps)</code></a> &amp;&amp; x &lt; y</li&gt;
<li>> 0 if !<a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-double-"><code>equals(x, y, eps)</code></a> &amp;&amp; x > y</li></ul></dd>
</dl>
</li>
</ul>
<a name="cosh-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>cosh</h4>
<pre>public static&nbsp;double&nbsp;cosh(double&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html">
hyperbolic cosine</a> of x.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - double value for which to find the hyperbolic cosine</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>hyperbolic cosine of x</dd>
</dl>
</li>
</ul>
<a name="equals-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y)</pre>
<div class="block">Returns true iff both arguments are NaN or neither is NaN and they are
equal</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - first value</dd>
<dd><code>y</code> - second value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the values are equal or both are NaN</dd>
</dl>
</li>
</ul>
<a name="equals-double-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y,
double&nbsp;eps)</pre>
<div class="block">Returns true iff both arguments are equal or within the range of allowed
error (inclusive).
<p>
Two NaNs are considered equals, as are two infinities with same sign.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - first value</dd>
<dd><code>y</code> - second value</dd>
<dd><code>eps</code> - the amount of absolute error to allow</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the values are equal or within range of each other</dd>
</dl>
</li>
</ul>
<a name="equals-double-double-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double&nbsp;x,
double&nbsp;y,
int&nbsp;maxUlps)</pre>
<div class="block">Returns true iff both arguments are equal or within the range of allowed
error (inclusive).
Adapted from <a
href="http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm">
Bruce Dawson</a></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - first value</dd>
<dd><code>y</code> - second value</dd>
<dd><code>maxUlps</code> - <code>(maxUlps - 1)</code> is the number of floating point
values between <code>x</code> and <code>y</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>true</code> if there are less than <code>maxUlps</code> floating
point values between <code>x</code> and <code>y</code></dd>
</dl>
</li>
</ul>
<a name="equals-double:A-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public static&nbsp;boolean&nbsp;equals(double[]&nbsp;x,
double[]&nbsp;y)</pre>
<div class="block">Returns true iff both arguments are null or have same dimensions
and all their elements are <a href="../../../../../org/apache/openejb/math/util/MathUtils.html#equals-double-double-"><code>equals</code></a></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - first array</dd>
<dd><code>y</code> - second array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>true if the values are both null or have same dimension
and equal elements</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="factorial-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorial</h4>
<pre>public static&nbsp;long&nbsp;factorial(int&nbsp;n)</pre>
<div class="block">Returns n!. Shorthand for <code>n</code> <a
href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the
product of the numbers <code>1,...,n</code>.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>n >= 0</code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
<li> The result is small enough to fit into a <code>long</code>. The
largest value of <code>n</code> for which <code>n!</code> <
Long.MAX_VALUE</code> is 20. If the computed value exceeds <code>Long.MAX_VALUE</code>
an <code>ArithMeticException </code> is thrown.</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - argument</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n!</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result is too large to be represented
by a long integer.</dd>
<dd><code>java.lang.IllegalArgumentException</code> - if n < 0</dd>
</dl>
</li>
</ul>
<a name="factorialDouble-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorialDouble</h4>
<pre>public static&nbsp;double&nbsp;factorialDouble(int&nbsp;n)</pre>
<div class="block">Returns n!. Shorthand for <code>n</code> <a
href="http://mathworld.wolfram.com/Factorial.html"> Factorial</a>, the
product of the numbers <code>1,...,n</code> as a <code>double</code>.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>n >= 0</code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
<li> The result is small enough to fit into a <code>double</code>. The
largest value of <code>n</code> for which <code>n!</code> <
Double.MAX_VALUE</code> is 170. If the computed value exceeds
Double.MAX_VALUE, Double.POSITIVE_INFINITY is returned</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - argument</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n!</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if n < 0</dd>
</dl>
</li>
</ul>
<a name="factorialLog-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>factorialLog</h4>
<pre>public static&nbsp;double&nbsp;factorialLog(int&nbsp;n)</pre>
<div class="block">Returns the natural logarithm of n!.
<p>
<Strong>Preconditions</strong>:
<ul>
<li> <code>n >= 0</code> (otherwise
<code>IllegalArgumentException</code> is thrown)</li>
</ul></p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>n</code> - argument</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd><code>n!</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if preconditions are not met.</dd>
</dl>
</li>
</ul>
<a name="gcd-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>gcd</h4>
<pre>public static&nbsp;int&nbsp;gcd(int&nbsp;p,
int&nbsp;q)</pre>
<div class="block"><p>
Gets the greatest common divisor of the absolute value of two numbers,
using the "binary gcd" method which avoids division and modulo
operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef
Stein (1961).
Special cases:
<ul>
<li>The invocations
<code>gcd(Integer.MIN_VALUE, Integer.MIN_VALUE)</code>,
<code>gcd(Integer.MIN_VALUE, 0)</code> and
<code>gcd(0, Integer.MIN_VALUE)</code> throw an
<code>ArithmeticException</code>, because the result would be 2^31, which
is too large for an int value.</li>
<li>The result of <code>gcd(x, x)</code>, <code>gcd(0, x)</code> and
<code>gcd(x, 0)</code> is the absolute value of <code>x</code>, except
for the special cases above.
<li>The invocation <code>gcd(0, 0)</code> is the only one which returns
<code>0</code>.</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p</code> - any number</dd>
<dd><code>q</code> - any number</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the greatest common divisor, never negative</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result cannot be represented as a
nonnegative int value</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="gcd-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>gcd</h4>
<pre>public static&nbsp;long&nbsp;gcd(long&nbsp;p,
long&nbsp;q)</pre>
<div class="block"><p>
Gets the greatest common divisor of the absolute value of two numbers,
using the "binary gcd" method which avoids division and modulo
operations. See Knuth 4.5.2 algorithm B. This algorithm is due to Josef
Stein (1961).
Special cases:
<ul>
<li>The invocations
<code>gcd(Long.MIN_VALUE, Long.MIN_VALUE)</code>,
<code>gcd(Long.MIN_VALUE, 0L)</code> and
<code>gcd(0L, Long.MIN_VALUE)</code> throw an
<code>ArithmeticException</code>, because the result would be 2^63, which
is too large for a long value.</li>
<li>The result of <code>gcd(x, x)</code>, <code>gcd(0L, x)</code> and
<code>gcd(x, 0L)</code> is the absolute value of <code>x</code>, except
for the special cases above.
<li>The invocation <code>gcd(0L, 0L)</code> is the only one which returns
<code>0L</code>.</li>
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p</code> - any number</dd>
<dd><code>q</code> - any number</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the greatest common divisor, never negative</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result cannot be represented as a nonnegative long
value</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="hash-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hash</h4>
<pre>public static&nbsp;int&nbsp;hash(double&nbsp;value)</pre>
<div class="block">Returns an integer hash code representing the given double value.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - the value to be hashed</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the hash code</dd>
</dl>
</li>
</ul>
<a name="hash-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>hash</h4>
<pre>public static&nbsp;int&nbsp;hash(double[]&nbsp;value)</pre>
<div class="block">Returns an integer hash code representing the given double array.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>value</code> - the value to be hashed (may be null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the hash code</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="indicator-byte-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;byte&nbsp;indicator(byte&nbsp;x)</pre>
<div class="block">For a byte value x, this method returns (byte)(+1) if x >= 0 and
(byte)(-1) if x < 0.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a byte</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>(byte)(+1) or (byte)(-1), depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="indicator-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;double&nbsp;indicator(double&nbsp;x)</pre>
<div class="block">For a double precision value x, this method returns +1.0 if x >= 0 and
-1.0 if x < 0. Returns <code>NaN</code> if <code>x</code> is
<code>NaN</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a double</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1.0 or -1.0, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="indicator-float-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;float&nbsp;indicator(float&nbsp;x)</pre>
<div class="block">For a float value x, this method returns +1.0F if x >= 0 and -1.0F if x <
0. Returns <code>NaN</code> if <code>x</code> is <code>NaN</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a float</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1.0F or -1.0F, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="indicator-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;int&nbsp;indicator(int&nbsp;x)</pre>
<div class="block">For an int value x, this method returns +1 if x >= 0 and -1 if x < 0.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, an int</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1 or -1, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="indicator-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;long&nbsp;indicator(long&nbsp;x)</pre>
<div class="block">For a long value x, this method returns +1L if x >= 0 and -1L if x < 0.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a long</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1L or -1L, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="indicator-short-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>indicator</h4>
<pre>public static&nbsp;short&nbsp;indicator(short&nbsp;x)</pre>
<div class="block">For a short value x, this method returns (short)(+1) if x >= 0 and
(short)(-1) if x < 0.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a short</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>(short)(+1) or (short)(-1), depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="lcm-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lcm</h4>
<pre>public static&nbsp;int&nbsp;lcm(int&nbsp;a,
int&nbsp;b)</pre>
<div class="block"><p>
Returns the least common multiple of the absolute value of two numbers,
using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.
Special cases:
<ul>
<li>The invocations <code>lcm(Integer.MIN_VALUE, n)</code> and
<code>lcm(n, Integer.MIN_VALUE)</code>, where <code>abs(n)</code> is a
power of 2, throw an <code>ArithmeticException</code>, because the result
would be 2^31, which is too large for an int value.</li>
<li>The result of <code>lcm(0, x)</code> and <code>lcm(x, 0)</code> is
<code>0</code> for any <code>x</code>.
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - any number</dd>
<dd><code>b</code> - any number</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the least common multiple, never negative</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result cannot be represented as a nonnegative int
value</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="lcm-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>lcm</h4>
<pre>public static&nbsp;long&nbsp;lcm(long&nbsp;a,
long&nbsp;b)</pre>
<div class="block"><p>
Returns the least common multiple of the absolute value of two numbers,
using the formula <code>lcm(a,b) = (a / gcd(a,b)) * b</code>.
Special cases:
<ul>
<li>The invocations <code>lcm(Long.MIN_VALUE, n)</code> and
<code>lcm(n, Long.MIN_VALUE)</code>, where <code>abs(n)</code> is a
power of 2, throw an <code>ArithmeticException</code>, because the result
would be 2^63, which is too large for an int value.</li>
<li>The result of <code>lcm(0L, x)</code> and <code>lcm(x, 0L)</code> is
<code>0L</code> for any <code>x</code>.
</ul></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - any number</dd>
<dd><code>b</code> - any number</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the least common multiple, never negative</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result cannot be represented as a nonnegative long
value</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="log-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>log</h4>
<pre>public static&nbsp;double&nbsp;log(double&nbsp;base,
double&nbsp;x)</pre>
<div class="block"><p>Returns the
<a href="http://mathworld.wolfram.com/Logarithm.html">logarithm</a>
for base <code>b</code> of <code>x</code>.
<p>Returns <code>NaN<code> if either argument is negative. If
<code>base</code> is 0 and <code>x</code> is positive, 0 is returned.
If <code>base</code> is positive and <code>x</code> is 0,
<code>Double.NEGATIVE_INFINITY</code> is returned. If both arguments
are 0, the result is <code>NaN</code>.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>base</code> - the base of the logarithm, must be greater than 0</dd>
<dd><code>x</code> - argument, must be greater than 0</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the value of the logarithm - the number y such that base^y = x.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="mulAndCheck-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mulAndCheck</h4>
<pre>public static&nbsp;int&nbsp;mulAndCheck(int&nbsp;x,
int&nbsp;y)</pre>
<div class="block">Multiply two integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - a factor</dd>
<dd><code>y</code> - a factor</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the product <code>x*y</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
int</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="mulAndCheck-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>mulAndCheck</h4>
<pre>public static&nbsp;long&nbsp;mulAndCheck(long&nbsp;a,
long&nbsp;b)</pre>
<div class="block">Multiply two long integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - first value</dd>
<dd><code>b</code> - second value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the product <code>a * b</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
long</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="nextAfter-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>nextAfter</h4>
<pre>public static&nbsp;double&nbsp;nextAfter(double&nbsp;d,
double&nbsp;direction)</pre>
<div class="block">Get the next machine representable number after a number, moving
in the direction of another number.
<p>
If <code>direction</code> is greater than or equal to<code>d</code>,
the smallest machine representable number strictly greater than
<code>d</code> is returned; otherwise the largest representable number
strictly less than <code>d</code> is returned.</p>
<p>
If <code>d</code> is NaN or Infinite, it is returned unchanged.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>d</code> - base number</dd>
<dd><code>direction</code> - (the only important thing is whether
direction is greater or smaller than d)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the next machine representable number in the specified direction</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="scalb-double-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>scalb</h4>
<pre>public static&nbsp;double&nbsp;scalb(double&nbsp;d,
int&nbsp;scaleFactor)</pre>
<div class="block">Scale a number by 2<sup>scaleFactor</sup>.
<p>If <code>d</code> is 0 or NaN or Infinite, it is returned unchanged.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>d</code> - base number</dd>
<dd><code>scaleFactor</code> - power of two by which d sould be multiplied</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>d &times; 2<sup>scaleFactor</sup></dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.0</dd>
</dl>
</li>
</ul>
<a name="normalizeAngle-double-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>normalizeAngle</h4>
<pre>public static&nbsp;double&nbsp;normalizeAngle(double&nbsp;a,
double&nbsp;center)</pre>
<div class="block">Normalize an angle in a 2&pi wide interval around a center value.
<p>This method has three main uses:</p>
<ul>
<li>normalize an angle between 0 and 2&pi;:<br/>
<code>a = MathUtils.normalizeAngle(a, Math.PI);</code></li>
<li>normalize an angle between -&pi; and +&pi;<br/>
<code>a = MathUtils.normalizeAngle(a, 0.0);</code></li>
<li>compute the angle between two defining angular positions:<br>
<code>angle = MathUtils.normalizeAngle(end, start) - start;</code></li>
</ul>
<p>Note that due to numerical accuracy and since &pi; cannot be represented
exactly, the result interval is <em>closed</em>, it cannot be half-closed
as would be more satisfactory in a purely mathematical view.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - angle to normalize</dd>
<dd><code>center</code> - center of the desired 2&pi; interval for the result</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>a-2k&pi; with integer k and center-&pi; &lt;= a-2k&pi; &lt;= center+&pi;</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="normalizeArray-double:A-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>normalizeArray</h4>
<pre>public static&nbsp;double[]&nbsp;normalizeArray(double[]&nbsp;values,
double&nbsp;normalizedSum)
throws java.lang.ArithmeticException,
java.lang.IllegalArgumentException</pre>
<div class="block"><p>Normalizes an array to make it sum to a specified value.
Returns the result of the transformation <pre>
x |-> x * normalizedSum / sum
</pre>
applied to each non-NaN element x of the input array, where sum is the
sum of the non-NaN entries in the input array.</p>
<p>Throws IllegalArgumentException if <code>normalizedSum</code> is infinite
or NaN and ArithmeticException if the input array contains any infinite elements
or sums to 0</p>
<p>Ignores (i.e., copies unchanged to the output array) NaNs in the input array.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>values</code> - input array to be normalized</dd>
<dd><code>normalizedSum</code> - target sum for the normalized array</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>normalized array</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the input array contains infinite elements or sums to zero</dd>
<dd><code>java.lang.IllegalArgumentException</code> - if the target sum is infinite or NaN</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>2.1</dd>
</dl>
</li>
</ul>
<a name="round-double-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;double&nbsp;round(double&nbsp;x,
int&nbsp;scale)</pre>
<div class="block">Round the given value to the specified number of decimal places. The
value is rounded using the <code>BigDecimal.ROUND_HALF_UP</code> method.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value to round.</dd>
<dd><code>scale</code> - the number of digits to the right of the decimal point.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rounded value.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="round-double-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;double&nbsp;round(double&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</pre>
<div class="block">Round the given value to the specified number of decimal places. The
value is rounded using the given method which is any method defined in
<code>BigDecimal</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value to round.</dd>
<dd><code>scale</code> - the number of digits to the right of the decimal point.</dd>
<dd><code>roundingMethod</code> - the rounding method as defined in
<code>BigDecimal</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rounded value.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="round-float-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;float&nbsp;round(float&nbsp;x,
int&nbsp;scale)</pre>
<div class="block">Round the given value to the specified number of decimal places. The
value is rounding using the <code>BigDecimal.ROUND_HALF_UP</code> method.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value to round.</dd>
<dd><code>scale</code> - the number of digits to the right of the decimal point.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rounded value.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="round-float-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>round</h4>
<pre>public static&nbsp;float&nbsp;round(float&nbsp;x,
int&nbsp;scale,
int&nbsp;roundingMethod)</pre>
<div class="block">Round the given value to the specified number of decimal places. The
value is rounded using the given method which is any method defined in
<code>BigDecimal</code>.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value to round.</dd>
<dd><code>scale</code> - the number of digits to the right of the decimal point.</dd>
<dd><code>roundingMethod</code> - the rounding method as defined in
<code>BigDecimal</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the rounded value.</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="sign-byte-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;byte&nbsp;sign(byte&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for byte value <code>x</code>.
<p>
For a byte value x, this method returns (byte)(+1) if x > 0, (byte)(0) if
x = 0, and (byte)(-1) if x < 0.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a byte</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>(byte)(+1), (byte)(0), or (byte)(-1), depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="sign-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;double&nbsp;sign(double&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for double precision <code>x</code>.
<p>
For a double value <code>x</code>, this method returns
<code>+1.0</code> if <code>x > 0</code>, <code>0.0</code> if
<code>x = 0.0</code>, and <code>-1.0</code> if <code>x < 0</code>.
Returns <code>NaN</code> if <code>x</code> is <code>NaN</code>.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a double</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1.0, 0.0, or -1.0, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="sign-float-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;float&nbsp;sign(float&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for float value <code>x</code>.
<p>
For a float value x, this method returns +1.0F if x > 0, 0.0F if x =
0.0F, and -1.0F if x < 0. Returns <code>NaN</code> if <code>x</code>
is <code>NaN</code>.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a float</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1.0F, 0.0F, or -1.0F, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="sign-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;int&nbsp;sign(int&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for int value <code>x</code>.
<p>
For an int value x, this method returns +1 if x > 0, 0 if x = 0, and -1
if x < 0.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, an int</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1, 0, or -1, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="sign-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;long&nbsp;sign(long&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for long value <code>x</code>.
<p>
For a long value x, this method returns +1L if x > 0, 0L if x = 0, and
-1L if x < 0.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a long</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>+1L, 0L, or -1L, depending on the sign of x</dd>
</dl>
</li>
</ul>
<a name="sign-short-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sign</h4>
<pre>public static&nbsp;short&nbsp;sign(short&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a>
for short value <code>x</code>.
<p>
For a short value x, this method returns (short)(+1) if x > 0, (short)(0)
if x = 0, and (short)(-1) if x < 0.</p></div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the value, a short</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>(short)(+1), (short)(0), or (short)(-1), depending on the sign of
x</dd>
</dl>
</li>
</ul>
<a name="sinh-double-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>sinh</h4>
<pre>public static&nbsp;double&nbsp;sinh(double&nbsp;x)</pre>
<div class="block">Returns the <a href="http://mathworld.wolfram.com/HyperbolicSine.html">
hyperbolic sine</a> of x.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - double value for which to find the hyperbolic sine</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>hyperbolic sine of x</dd>
</dl>
</li>
</ul>
<a name="subAndCheck-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subAndCheck</h4>
<pre>public static&nbsp;int&nbsp;subAndCheck(int&nbsp;x,
int&nbsp;y)</pre>
<div class="block">Subtract two integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>x</code> - the minuend</dd>
<dd><code>y</code> - the subtrahend</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the difference <code>x-y</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
int</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.1</dd>
</dl>
</li>
</ul>
<a name="subAndCheck-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>subAndCheck</h4>
<pre>public static&nbsp;long&nbsp;subAndCheck(long&nbsp;a,
long&nbsp;b)</pre>
<div class="block">Subtract two long integers, checking for overflow.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>a</code> - first value</dd>
<dd><code>b</code> - second value</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the difference <code>a-b</code></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.ArithmeticException</code> - if the result can not be represented as an
long</dd>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>1.2</dd>
</dl>
</li>
</ul>
<a name="pow-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;int&nbsp;pow(int&nbsp;k,
int&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise an int to an int power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-int-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;int&nbsp;pow(int&nbsp;k,
long&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise an int to a long power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-long-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;long&nbsp;pow(long&nbsp;k,
int&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise a long to an int power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-long-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;long&nbsp;pow(long&nbsp;k,
long&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise a long to a long power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-java.math.BigInteger-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;java.math.BigInteger&nbsp;pow(java.math.BigInteger&nbsp;k,
int&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise a BigInteger to an int power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-java.math.BigInteger-long-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;java.math.BigInteger&nbsp;pow(java.math.BigInteger&nbsp;k,
long&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise a BigInteger to a long power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="pow-java.math.BigInteger-java.math.BigInteger-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>pow</h4>
<pre>public static&nbsp;java.math.BigInteger&nbsp;pow(java.math.BigInteger&nbsp;k,
java.math.BigInteger&nbsp;e)
throws java.lang.IllegalArgumentException</pre>
<div class="block">Raise a BigInteger to a BigInteger power.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>k</code> - number to raise</dd>
<dd><code>e</code> - exponent (must be positive or null)</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>k<sup>e</sup></dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if e is negative</dd>
</dl>
</li>
</ul>
<a name="distance1-double:A-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distance1</h4>
<pre>public static&nbsp;double&nbsp;distance1(double[]&nbsp;p1,
double[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>1</sub> (sum of abs) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>1</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="distance1-int:A-int:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distance1</h4>
<pre>public static&nbsp;int&nbsp;distance1(int[]&nbsp;p1,
int[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>1</sub> (sum of abs) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>1</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="distance-double:A-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distance</h4>
<pre>public static&nbsp;double&nbsp;distance(double[]&nbsp;p1,
double[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>2</sub> (Euclidean) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>2</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="distance-int:A-int:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distance</h4>
<pre>public static&nbsp;double&nbsp;distance(int[]&nbsp;p1,
int[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>2</sub> (Euclidean) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>2</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="distanceInf-double:A-double:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distanceInf</h4>
<pre>public static&nbsp;double&nbsp;distanceInf(double[]&nbsp;p1,
double[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>&infin;</sub> (max of abs) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>&infin;</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="distanceInf-int:A-int:A-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>distanceInf</h4>
<pre>public static&nbsp;int&nbsp;distanceInf(int[]&nbsp;p1,
int[]&nbsp;p2)</pre>
<div class="block">Calculates the L<sub>&infin;</sub> (max of abs) distance between two points.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>p1</code> - the first point</dd>
<dd><code>p2</code> - the second point</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the L<sub>&infin;</sub> distance between the two points</dd>
</dl>
</li>
</ul>
<a name="checkOrder-double:A-int-boolean-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>checkOrder</h4>
<pre>public static&nbsp;void&nbsp;checkOrder(double[]&nbsp;val,
int&nbsp;dir,
boolean&nbsp;strict)</pre>
<div class="block">Checks that the given array is sorted.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>val</code> - Values</dd>
<dd><code>dir</code> - Order direction (-1 for decreasing, 1 for increasing)</dd>
<dd><code>strict</code> - Whether the order should be strict</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalArgumentException</code> - if the array is not sorted.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/openejb/math/util/DoubleArray.html" title="interface in org.apache.openejb.math.util"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../../org/apache/openejb/math/util/ResizableDoubleArray.html" title="class in org.apache.openejb.math.util"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/openejb/math/util/MathUtils.html" target="_top">Frames</a></li>
<li><a href="MathUtils.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li><a href="#field.summary">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li><a href="#field.detail">Field</a>&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>