Mercurial > hg > de.mpg.mpiwg.itgroup.digilib.core
view libs/commons-math-2.1/docs/apidocs/org/apache/commons/math/util/MathUtils.html @ 32:d7a43156a79b default tip
new tabs
author | dwinter |
---|---|
date | Mon, 10 Oct 2011 17:52:22 +0200 |
parents | 878723cc40fb |
children |
line wrap: on
line source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!--NewPage--> <HTML> <HEAD> <!-- Generated by javadoc (build 1.6.0_17) on Sat Mar 27 22:46:17 EDT 2010 --> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <TITLE> MathUtils (Commons Math 2.1 API) </TITLE> <META NAME="date" CONTENT="2010-03-27"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="MathUtils (Commons Math 2.1 API)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= START OF TOP NAVBAR ======= --> <A NAME="navbar_top"><!-- --></A> <A HREF="#skip-navbar_top" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_top_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/MathUtils.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../org/apache/commons/math/util/DoubleArray.html" title="interface in org.apache.commons.math.util"><B>PREV CLASS</B></A> <A HREF="../../../../../org/apache/commons/math/util/NumberTransformer.html" title="interface in org.apache.commons.math.util"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/commons/math/util/MathUtils.html" target="_top"><B>FRAMES</B></A> <A HREF="MathUtils.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> org.apache.commons.math.util</FONT> <BR> Class MathUtils</H2> <PRE> <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.commons.math.util.MathUtils</B> </PRE> <HR> <DL> <DT><PRE>public final class <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.30"><B>MathUtils</B></A><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL> </PRE> <P> Some useful additions to the built-in functions in <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Math.html?is-external=true" title="class or interface in java.lang"><CODE>Math</CODE></A>. <P> <P> <DL> <DT><B>Version:</B></DT> <DD>$Revision: 927249 $ $Date: 2010-03-24 21:06:51 -0400 (Wed, 24 Mar 2010) $</DD> </DL> <HR> <P> <!-- =========== FIELD SUMMARY =========== --> <A NAME="field_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Field Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#EPSILON">EPSILON</A></B></CODE> <BR> Smallest positive number such that 1 - EPSILON is not numerically equal to 1.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#SAFE_MIN">SAFE_MIN</A></B></CODE> <BR> Safe minimum, such that 1 / SAFE_MIN does not overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#TWO_PI">TWO_PI</A></B></CODE> <BR> 2 π.</TD> </TR> </TABLE> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_summary"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> <B>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#addAndCheck(int, int)">addAndCheck</A></B>(int x, int y)</CODE> <BR> Add two integers, checking for overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#addAndCheck(long, long)">addAndCheck</A></B>(long a, long b)</CODE> <BR> Add two long integers, checking for overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#binomialCoefficient(int, int)">binomialCoefficient</A></B>(int n, int k)</CODE> <BR> 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.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#binomialCoefficientDouble(int, int)">binomialCoefficientDouble</A></B>(int n, int k)</CODE> <BR> 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.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#binomialCoefficientLog(int, int)">binomialCoefficientLog</A></B>(int n, int k)</CODE> <BR> 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.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static void</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#checkOrder(double[], int, boolean)">checkOrder</A></B>(double[] val, int dir, boolean strict)</CODE> <BR> Checks that the given array is sorted.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#compareTo(double, double, double)">compareTo</A></B>(double x, double y, double eps)</CODE> <BR> Compares two numbers given some amount of allowed error.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#cosh(double)">cosh</A></B>(double x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html"> hyperbolic cosine</a> of x.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distance(double[], double[])">distance</A></B>(double[] p1, double[] p2)</CODE> <BR> Calculates the L<sub>2</sub> (Euclidean) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distance(int[], int[])">distance</A></B>(int[] p1, int[] p2)</CODE> <BR> Calculates the L<sub>2</sub> (Euclidean) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distance1(double[], double[])">distance1</A></B>(double[] p1, double[] p2)</CODE> <BR> Calculates the L<sub>1</sub> (sum of abs) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distance1(int[], int[])">distance1</A></B>(int[] p1, int[] p2)</CODE> <BR> Calculates the L<sub>1</sub> (sum of abs) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distanceInf(double[], double[])">distanceInf</A></B>(double[] p1, double[] p2)</CODE> <BR> Calculates the L<sub>∞</sub> (max of abs) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#distanceInf(int[], int[])">distanceInf</A></B>(int[] p1, int[] p2)</CODE> <BR> Calculates the L<sub>∞</sub> (max of abs) distance between two points.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double[], double[])">equals</A></B>(double[] x, double[] y)</CODE> <BR> Returns true iff both arguments are null or have same dimensions and all their elements are <A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double)"><CODE>equals</CODE></A></TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double)">equals</A></B>(double x, double y)</CODE> <BR> Returns true iff both arguments are NaN or neither is NaN and they are equal</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double, double)">equals</A></B>(double x, double y, double eps)</CODE> <BR> Returns true iff both arguments are equal or within the range of allowed error (inclusive).</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static boolean</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double, int)">equals</A></B>(double x, double y, int maxUlps)</CODE> <BR> Returns true iff both arguments are equal or within the range of allowed error (inclusive).</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#factorial(int)">factorial</A></B>(int n)</CODE> <BR> Returns n!.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#factorialDouble(int)">factorialDouble</A></B>(int n)</CODE> <BR> Returns n!.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#factorialLog(int)">factorialLog</A></B>(int n)</CODE> <BR> Returns the natural logarithm of n!.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#gcd(int, int)">gcd</A></B>(int p, int q)</CODE> <BR> Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#gcd(long, long)">gcd</A></B>(long p, long q)</CODE> <BR> Gets the greatest common divisor of the absolute value of two numbers, using the "binary gcd" method which avoids division and modulo operations.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#hash(double)">hash</A></B>(double value)</CODE> <BR> Returns an integer hash code representing the given double value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#hash(double[])">hash</A></B>(double[] value)</CODE> <BR> Returns an integer hash code representing the given double array.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(byte)">indicator</A></B>(byte x)</CODE> <BR> For a byte value x, this method returns (byte)(+1) if x >= 0 and (byte)(-1) if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(double)">indicator</A></B>(double x)</CODE> <BR> For a double precision value x, this method returns +1.0 if x >= 0 and -1.0 if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static float</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(float)">indicator</A></B>(float x)</CODE> <BR> For a float value x, this method returns +1.0F if x >= 0 and -1.0F if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(int)">indicator</A></B>(int x)</CODE> <BR> For an int value x, this method returns +1 if x >= 0 and -1 if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(long)">indicator</A></B>(long x)</CODE> <BR> For a long value x, this method returns +1L if x >= 0 and -1L if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static short</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#indicator(short)">indicator</A></B>(short x)</CODE> <BR> For a short value x, this method returns (short)(+1) if x >= 0 and (short)(-1) if x < 0.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#lcm(int, int)">lcm</A></B>(int a, int b)</CODE> <BR> 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>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#lcm(long, long)">lcm</A></B>(long a, long b)</CODE> <BR> 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>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#log(double, double)">log</A></B>(double base, double x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Logarithm.html">logarithm</a> for base <code>b</code> of <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#mulAndCheck(int, int)">mulAndCheck</A></B>(int x, int y)</CODE> <BR> Multiply two integers, checking for overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#mulAndCheck(long, long)">mulAndCheck</A></B>(long a, long b)</CODE> <BR> Multiply two long integers, checking for overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#nextAfter(double, double)">nextAfter</A></B>(double d, double direction)</CODE> <BR> Get the next machine representable number after a number, moving in the direction of another number.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#normalizeAngle(double, double)">normalizeAngle</A></B>(double a, double center)</CODE> <BR> Normalize an angle in a 2&pi wide interval around a center value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double[]</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#normalizeArray(double[], double)">normalizeArray</A></B>(double[] values, double normalizedSum)</CODE> <BR> Normalizes an array to make it sum to a specified value.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(java.math.BigInteger, java.math.BigInteger)">pow</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> e)</CODE> <BR> Raise a BigInteger to a BigInteger power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(java.math.BigInteger, int)">pow</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, int e)</CODE> <BR> Raise a BigInteger to an int power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(java.math.BigInteger, long)">pow</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, long e)</CODE> <BR> Raise a BigInteger to a long power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(int, int)">pow</A></B>(int k, int e)</CODE> <BR> Raise an int to an int power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(int, long)">pow</A></B>(int k, long e)</CODE> <BR> Raise an int to a long power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(long, int)">pow</A></B>(long k, int e)</CODE> <BR> Raise a long to an int power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#pow(long, long)">pow</A></B>(long k, long e)</CODE> <BR> Raise a long to a long power.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#round(double, int)">round</A></B>(double x, int scale)</CODE> <BR> Round the given value to the specified number of decimal places.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#round(double, int, int)">round</A></B>(double x, int scale, int roundingMethod)</CODE> <BR> Round the given value to the specified number of decimal places.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static float</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#round(float, int)">round</A></B>(float x, int scale)</CODE> <BR> Round the given value to the specified number of decimal places.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static float</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#round(float, int, int)">round</A></B>(float x, int scale, int roundingMethod)</CODE> <BR> Round the given value to the specified number of decimal places.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#scalb(double, int)">scalb</A></B>(double d, int scaleFactor)</CODE> <BR> Scale a number by 2<sup>scaleFactor</sup>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(byte)">sign</A></B>(byte x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for byte value <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(double)">sign</A></B>(double x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for double precision <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static float</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(float)">sign</A></B>(float x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for float value <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(int)">sign</A></B>(int x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for int value <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(long)">sign</A></B>(long x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for long value <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static short</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sign(short)">sign</A></B>(short x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/Sign.html"> sign</a> for short value <code>x</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static double</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#sinh(double)">sinh</A></B>(double x)</CODE> <BR> Returns the <a href="http://mathworld.wolfram.com/HyperbolicSine.html"> hyperbolic sine</a> of x.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#subAndCheck(int, int)">subAndCheck</A></B>(int x, int y)</CODE> <BR> Subtract two integers, checking for overflow.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static long</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#subAndCheck(long, long)">subAndCheck</A></B>(long a, long b)</CODE> <BR> Subtract two long integers, checking for overflow.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> </TR> </TABLE> <P> <!-- ============ FIELD DETAIL =========== --> <A NAME="field_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Field Detail</B></FONT></TH> </TR> </TABLE> <A NAME="EPSILON"><!-- --></A><H3> EPSILON</H3> <PRE> public static final double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.33"><B>EPSILON</B></A></PRE> <DL> <DD>Smallest positive number such that 1 - EPSILON is not numerically equal to 1. <P> <DL> <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.commons.math.util.MathUtils.EPSILON">Constant Field Values</A></DL> </DL> <HR> <A NAME="SAFE_MIN"><!-- --></A><H3> SAFE_MIN</H3> <PRE> public static final double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.39"><B>SAFE_MIN</B></A></PRE> <DL> <DD>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> <P> <DL> <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.commons.math.util.MathUtils.SAFE_MIN">Constant Field Values</A></DL> </DL> <HR> <A NAME="TWO_PI"><!-- --></A><H3> TWO_PI</H3> <PRE> public static final double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.45"><B>TWO_PI</B></A></PRE> <DL> <DD>2 π. <P> <DL> <DT><B>Since:</B></DT> <DD>2.1</DD> <DT><B>See Also:</B><DD><A HREF="../../../../../constant-values.html#org.apache.commons.math.util.MathUtils.TWO_PI">Constant Field Values</A></DL> </DL> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="addAndCheck(int, int)"><!-- --></A><H3> addAndCheck</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.98"><B>addAndCheck</B></A>(int x, int y)</PRE> <DL> <DD>Add two integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - an addend<DD><CODE>y</CODE> - an addend <DT><B>Returns:</B><DD>the sum <code>x+y</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an int<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="addAndCheck(long, long)"><!-- --></A><H3> addAndCheck</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.116"><B>addAndCheck</B></A>(long a, long b)</PRE> <DL> <DD>Add two long integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - an addend<DD><CODE>b</CODE> - an addend <DT><B>Returns:</B><DD>the sum <code>a+b</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an long<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="binomialCoefficient(int, int)"><!-- --></A><H3> binomialCoefficient</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.191"><B>binomialCoefficient</B></A>(int n, int k)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - the size of the set<DD><CODE>k</CODE> - the size of the subsets to be counted <DT><B>Returns:</B><DD><code>n choose k</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if preconditions are not met. <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result is too large to be represented by a long integer.</DL> </DD> </DL> <HR> <A NAME="binomialCoefficientDouble(int, int)"><!-- --></A><H3> binomialCoefficientDouble</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.267"><B>binomialCoefficientDouble</B></A>(int n, int k)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - the size of the set<DD><CODE>k</CODE> - the size of the subsets to be counted <DT><B>Returns:</B><DD><code>n choose k</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if preconditions are not met.</DL> </DD> </DL> <HR> <A NAME="binomialCoefficientLog(int, int)"><!-- --></A><H3> binomialCoefficientLog</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.308"><B>binomialCoefficientLog</B></A>(int n, int k)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - the size of the set<DD><CODE>k</CODE> - the size of the subsets to be counted <DT><B>Returns:</B><DD><code>n choose k</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if preconditions are not met.</DL> </DD> </DL> <HR> <A NAME="compareTo(double, double, double)"><!-- --></A><H3> compareTo</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.385"><B>compareTo</B></A>(double x, double y, double eps)</PRE> <DL> <DD>Compares two numbers given some amount of allowed error. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the first number<DD><CODE>y</CODE> - the second number<DD><CODE>eps</CODE> - the amount of error to allow when checking for equality <DT><B>Returns:</B><DD><ul><li>0 if <A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double, double)"><CODE>equals(x, y, eps)</CODE></A></li> <li>< 0 if !<A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double, double)"><CODE>equals(x, y, eps)</CODE></A> && x < y</li> <li>> 0 if !<A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double, double)"><CODE>equals(x, y, eps)</CODE></A> && x > y</li></ul></DL> </DD> </DL> <HR> <A NAME="cosh(double)"><!-- --></A><H3> cosh</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.401"><B>cosh</B></A>(double x)</PRE> <DL> <DD>Returns the <a href="http://mathworld.wolfram.com/HyperbolicCosine.html"> hyperbolic cosine</a> of x. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - double value for which to find the hyperbolic cosine <DT><B>Returns:</B><DD>hyperbolic cosine of x</DL> </DD> </DL> <HR> <A NAME="equals(double, double)"><!-- --></A><H3> equals</H3> <PRE> public static boolean <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.413"><B>equals</B></A>(double x, double y)</PRE> <DL> <DD>Returns true iff both arguments are NaN or neither is NaN and they are equal <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - first value<DD><CODE>y</CODE> - second value <DT><B>Returns:</B><DD>true if the values are equal or both are NaN</DL> </DD> </DL> <HR> <A NAME="equals(double, double, double)"><!-- --></A><H3> equals</H3> <PRE> public static boolean <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.429"><B>equals</B></A>(double x, double y, double eps)</PRE> <DL> <DD>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. </p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - first value<DD><CODE>y</CODE> - second value<DD><CODE>eps</CODE> - the amount of absolute error to allow <DT><B>Returns:</B><DD>true if the values are equal or within range of each other</DL> </DD> </DL> <HR> <A NAME="equals(double, double, int)"><!-- --></A><H3> equals</H3> <PRE> public static boolean <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.447"><B>equals</B></A>(double x, double y, int maxUlps)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - first value<DD><CODE>y</CODE> - second value<DD><CODE>maxUlps</CODE> - <code>(maxUlps - 1)</code> is the number of floating point values between <code>x</code> and <code>y</code>. <DT><B>Returns:</B><DD><code>true</code> if there are less than <code>maxUlps</code> floating point values between <code>x</code> and <code>y</code></DL> </DD> </DL> <HR> <A NAME="equals(double[], double[])"><!-- --></A><H3> equals</H3> <PRE> public static boolean <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.476"><B>equals</B></A>(double[] x, double[] y)</PRE> <DL> <DD>Returns true iff both arguments are null or have same dimensions and all their elements are <A HREF="../../../../../org/apache/commons/math/util/MathUtils.html#equals(double, double)"><CODE>equals</CODE></A> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - first array<DD><CODE>y</CODE> - second array <DT><B>Returns:</B><DD>true if the values are both null or have same dimension and equal elements<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="factorial(int)"><!-- --></A><H3> factorial</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.513"><B>factorial</B></A>(int n)</PRE> <DL> <DD>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> </p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - argument <DT><B>Returns:</B><DD><code>n!</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result is too large to be represented by a long integer. <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if n < 0</DL> </DD> </DL> <HR> <A NAME="factorialDouble(int)"><!-- --></A><H3> factorialDouble</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.546"><B>factorialDouble</B></A>(int n)</PRE> <DL> <DD>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> </p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - argument <DT><B>Returns:</B><DD><code>n!</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if n < 0</DL> </DD> </DL> <HR> <A NAME="factorialLog(int)"><!-- --></A><H3> factorialLog</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.571"><B>factorialLog</B></A>(int n)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>n</CODE> - argument <DT><B>Returns:</B><DD><code>n!</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if preconditions are not met.</DL> </DD> </DL> <HR> <A NAME="gcd(int, int)"><!-- --></A><H3> gcd</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.616"><B>gcd</B></A>(int p, int q)</PRE> <DL> <DD><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). </p> 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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p</CODE> - any number<DD><CODE>q</CODE> - any number <DT><B>Returns:</B><DD>the greatest common divisor, never negative <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result cannot be represented as a nonnegative int value<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="gcd(long, long)"><!-- --></A><H3> gcd</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.705"><B>gcd</B></A>(long p, long q)</PRE> <DL> <DD><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). </p> 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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p</CODE> - any number<DD><CODE>q</CODE> - any number <DT><B>Returns:</B><DD>the greatest common divisor, never negative <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result cannot be represented as a nonnegative long value<DT><B>Since:</B></DT> <DD>2.1</DD> </DL> </DD> </DL> <HR> <A NAME="hash(double)"><!-- --></A><H3> hash</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.771"><B>hash</B></A>(double value)</PRE> <DL> <DD>Returns an integer hash code representing the given double value. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>value</CODE> - the value to be hashed <DT><B>Returns:</B><DD>the hash code</DL> </DD> </DL> <HR> <A NAME="hash(double[])"><!-- --></A><H3> hash</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.782"><B>hash</B></A>(double[] value)</PRE> <DL> <DD>Returns an integer hash code representing the given double array. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>value</CODE> - the value to be hashed (may be null) <DT><B>Returns:</B><DD>the hash code<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="indicator(byte)"><!-- --></A><H3> indicator</H3> <PRE> public static byte <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.793"><B>indicator</B></A>(byte x)</PRE> <DL> <DD>For a byte value x, this method returns (byte)(+1) if x >= 0 and (byte)(-1) if x < 0. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a byte <DT><B>Returns:</B><DD>(byte)(+1) or (byte)(-1), depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="indicator(double)"><!-- --></A><H3> indicator</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.805"><B>indicator</B></A>(double x)</PRE> <DL> <DD>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>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a double <DT><B>Returns:</B><DD>+1.0 or -1.0, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="indicator(float)"><!-- --></A><H3> indicator</H3> <PRE> public static float <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.819"><B>indicator</B></A>(float x)</PRE> <DL> <DD>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>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a float <DT><B>Returns:</B><DD>+1.0F or -1.0F, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="indicator(int)"><!-- --></A><H3> indicator</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.832"><B>indicator</B></A>(int x)</PRE> <DL> <DD>For an int value x, this method returns +1 if x >= 0 and -1 if x < 0. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, an int <DT><B>Returns:</B><DD>+1 or -1, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="indicator(long)"><!-- --></A><H3> indicator</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.842"><B>indicator</B></A>(long x)</PRE> <DL> <DD>For a long value x, this method returns +1L if x >= 0 and -1L if x < 0. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a long <DT><B>Returns:</B><DD>+1L or -1L, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="indicator(short)"><!-- --></A><H3> indicator</H3> <PRE> public static short <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.853"><B>indicator</B></A>(short x)</PRE> <DL> <DD>For a short value x, this method returns (short)(+1) if x >= 0 and (short)(-1) if x < 0. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a short <DT><B>Returns:</B><DD>(short)(+1) or (short)(-1), depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="lcm(int, int)"><!-- --></A><H3> lcm</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.880"><B>lcm</B></A>(int a, int b)</PRE> <DL> <DD><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>. </p> 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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - any number<DD><CODE>b</CODE> - any number <DT><B>Returns:</B><DD>the least common multiple, never negative <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result cannot be represented as a nonnegative int value<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="lcm(long, long)"><!-- --></A><H3> lcm</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.915"><B>lcm</B></A>(long a, long b)</PRE> <DL> <DD><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>. </p> 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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - any number<DD><CODE>b</CODE> - any number <DT><B>Returns:</B><DD>the least common multiple, never negative <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result cannot be represented as a nonnegative long value<DT><B>Since:</B></DT> <DD>2.1</DD> </DL> </DD> </DL> <HR> <A NAME="log(double, double)"><!-- --></A><H3> log</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.944"><B>log</B></A>(double base, double x)</PRE> <DL> <DD><p>Returns the <a href="http://mathworld.wolfram.com/Logarithm.html">logarithm</a> for base <code>b</code> of <code>x</code>. </p> <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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>base</CODE> - the base of the logarithm, must be greater than 0<DD><CODE>x</CODE> - argument, must be greater than 0 <DT><B>Returns:</B><DD>the value of the logarithm - the number y such that base^y = x.<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="mulAndCheck(int, int)"><!-- --></A><H3> mulAndCheck</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.958"><B>mulAndCheck</B></A>(int x, int y)</PRE> <DL> <DD>Multiply two integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - a factor<DD><CODE>y</CODE> - a factor <DT><B>Returns:</B><DD>the product <code>x*y</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an int<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="mulAndCheck(long, long)"><!-- --></A><H3> mulAndCheck</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.976"><B>mulAndCheck</B></A>(long a, long b)</PRE> <DL> <DD>Multiply two long integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - first value<DD><CODE>b</CODE> - second value <DT><B>Returns:</B><DD>the product <code>a * b</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an long<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="nextAfter(double, double)"><!-- --></A><H3> nextAfter</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1038"><B>nextAfter</B></A>(double d, double direction)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>d</CODE> - base number<DD><CODE>direction</CODE> - (the only important thing is whether direction is greater or smaller than d) <DT><B>Returns:</B><DD>the next machine representable number in the specified direction<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="scalb(double, int)"><!-- --></A><H3> scalb</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1087"><B>scalb</B></A>(double d, int scaleFactor)</PRE> <DL> <DD>Scale a number by 2<sup>scaleFactor</sup>. <p>If <code>d</code> is 0 or NaN or Infinite, it is returned unchanged.</p> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>d</CODE> - base number<DD><CODE>scaleFactor</CODE> - power of two by which d sould be multiplied <DT><B>Returns:</B><DD>d × 2<sup>scaleFactor</sup><DT><B>Since:</B></DT> <DD>2.0</DD> </DL> </DD> </DL> <HR> <A NAME="normalizeAngle(double, double)"><!-- --></A><H3> normalizeAngle</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1124"><B>normalizeAngle</B></A>(double a, double center)</PRE> <DL> <DD>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π:<br/> <code>a = MathUtils.normalizeAngle(a, Math.PI);</code></li> <li>normalize an angle between -π and +π<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 π 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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - angle to normalize<DD><CODE>center</CODE> - center of the desired 2π interval for the result <DT><B>Returns:</B><DD>a-2kπ with integer k and center-π <= a-2kπ <= center+π<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="normalizeArray(double[], double)"><!-- --></A><H3> normalizeArray</H3> <PRE> public static double[] <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1149"><B>normalizeArray</B></A>(double[] values, double normalizedSum) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD><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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>values</CODE> - input array to be normalized<DD><CODE>normalizedSum</CODE> - target sum for the normalized array <DT><B>Returns:</B><DD>normalized array <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the input array contains infinite elements or sums to zero <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the target sum is infinite or NaN<DT><B>Since:</B></DT> <DD>2.1</DD> </DL> </DD> </DL> <HR> <A NAME="round(double, int)"><!-- --></A><H3> round</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1194"><B>round</B></A>(double x, int scale)</PRE> <DL> <DD>Round the given value to the specified number of decimal places. The value is rounded using the <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true#ROUND_HALF_UP" title="class or interface in java.math"><CODE>BigDecimal.ROUND_HALF_UP</CODE></A> method. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to round.<DD><CODE>scale</CODE> - the number of digits to the right of the decimal point. <DT><B>Returns:</B><DD>the rounded value.<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="round(double, int, int)"><!-- --></A><H3> round</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1210"><B>round</B></A>(double x, int scale, int roundingMethod)</PRE> <DL> <DD>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 <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><CODE>BigDecimal</CODE></A>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to round.<DD><CODE>scale</CODE> - the number of digits to the right of the decimal point.<DD><CODE>roundingMethod</CODE> - the rounding method as defined in <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><CODE>BigDecimal</CODE></A>. <DT><B>Returns:</B><DD>the rounded value.<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="round(float, int)"><!-- --></A><H3> round</H3> <PRE> public static float <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1234"><B>round</B></A>(float x, int scale)</PRE> <DL> <DD>Round the given value to the specified number of decimal places. The value is rounding using the <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true#ROUND_HALF_UP" title="class or interface in java.math"><CODE>BigDecimal.ROUND_HALF_UP</CODE></A> method. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to round.<DD><CODE>scale</CODE> - the number of digits to the right of the decimal point. <DT><B>Returns:</B><DD>the rounded value.<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="round(float, int, int)"><!-- --></A><H3> round</H3> <PRE> public static float <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1250"><B>round</B></A>(float x, int scale, int roundingMethod)</PRE> <DL> <DD>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 <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><CODE>BigDecimal</CODE></A>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value to round.<DD><CODE>scale</CODE> - the number of digits to the right of the decimal point.<DD><CODE>roundingMethod</CODE> - the rounding method as defined in <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html?is-external=true" title="class or interface in java.math"><CODE>BigDecimal</CODE></A>. <DT><B>Returns:</B><DD>the rounded value.<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="sign(byte)"><!-- --></A><H3> sign</H3> <PRE> public static byte <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1360"><B>sign</B></A>(byte x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a byte <DT><B>Returns:</B><DD>(byte)(+1), (byte)(0), or (byte)(-1), depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sign(double)"><!-- --></A><H3> sign</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1376"><B>sign</B></A>(double x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a double <DT><B>Returns:</B><DD>+1.0, 0.0, or -1.0, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sign(float)"><!-- --></A><H3> sign</H3> <PRE> public static float <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1394"><B>sign</B></A>(float x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a float <DT><B>Returns:</B><DD>+1.0F, 0.0F, or -1.0F, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sign(int)"><!-- --></A><H3> sign</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1411"><B>sign</B></A>(int x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, an int <DT><B>Returns:</B><DD>+1, 0, or -1, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sign(long)"><!-- --></A><H3> sign</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1425"><B>sign</B></A>(long x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a long <DT><B>Returns:</B><DD>+1L, 0L, or -1L, depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sign(short)"><!-- --></A><H3> sign</H3> <PRE> public static short <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1440"><B>sign</B></A>(short x)</PRE> <DL> <DD>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> <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the value, a short <DT><B>Returns:</B><DD>(short)(+1), (short)(0), or (short)(-1), depending on the sign of x</DL> </DD> </DL> <HR> <A NAME="sinh(double)"><!-- --></A><H3> sinh</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1451"><B>sinh</B></A>(double x)</PRE> <DL> <DD>Returns the <a href="http://mathworld.wolfram.com/HyperbolicSine.html"> hyperbolic sine</a> of x. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - double value for which to find the hyperbolic sine <DT><B>Returns:</B><DD>hyperbolic sine of x</DL> </DD> </DL> <HR> <A NAME="subAndCheck(int, int)"><!-- --></A><H3> subAndCheck</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1465"><B>subAndCheck</B></A>(int x, int y)</PRE> <DL> <DD>Subtract two integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>x</CODE> - the minuend<DD><CODE>y</CODE> - the subtrahend <DT><B>Returns:</B><DD>the difference <code>x-y</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an int<DT><B>Since:</B></DT> <DD>1.1</DD> </DL> </DD> </DL> <HR> <A NAME="subAndCheck(long, long)"><!-- --></A><H3> subAndCheck</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1483"><B>subAndCheck</B></A>(long a, long b)</PRE> <DL> <DD>Subtract two long integers, checking for overflow. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - first value<DD><CODE>b</CODE> - second value <DT><B>Returns:</B><DD>the difference <code>a-b</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ArithmeticException.html?is-external=true" title="class or interface in java.lang">ArithmeticException</A></CODE> - if the result can not be represented as an long<DT><B>Since:</B></DT> <DD>1.2</DD> </DL> </DD> </DL> <HR> <A NAME="pow(int, int)"><!-- --></A><H3> pow</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1506"><B>pow</B></A>(int k, int e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise an int to an int power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(int, long)"><!-- --></A><H3> pow</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1536"><B>pow</B></A>(int k, long e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise an int to a long power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(long, int)"><!-- --></A><H3> pow</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1566"><B>pow</B></A>(long k, int e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise a long to an int power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(long, long)"><!-- --></A><H3> pow</H3> <PRE> public static long <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1596"><B>pow</B></A>(long k, long e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise a long to a long power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(java.math.BigInteger, int)"><!-- --></A><H3> pow</H3> <PRE> public static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1626"><B>pow</B></A>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, int e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise a BigInteger to an int power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(java.math.BigInteger, long)"><!-- --></A><H3> pow</H3> <PRE> public static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1646"><B>pow</B></A>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, long e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise a BigInteger to a long power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="pow(java.math.BigInteger, java.math.BigInteger)"><!-- --></A><H3> pow</H3> <PRE> public static <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1676"><B>pow</B></A>(<A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> k, <A HREF="http://java.sun.com/javase/6/docs/api/java/math/BigInteger.html?is-external=true" title="class or interface in java.math">BigInteger</A> e) throws <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></PRE> <DL> <DD>Raise a BigInteger to a BigInteger power. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>k</CODE> - number to raise<DD><CODE>e</CODE> - exponent (must be positive or null) <DT><B>Returns:</B><DD>k<sup>e</sup> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if e is negative</DL> </DD> </DL> <HR> <A NAME="distance1(double[], double[])"><!-- --></A><H3> distance1</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1706"><B>distance1</B></A>(double[] p1, double[] p2)</PRE> <DL> <DD>Calculates the L<sub>1</sub> (sum of abs) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>1</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="distance1(int[], int[])"><!-- --></A><H3> distance1</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1721"><B>distance1</B></A>(int[] p1, int[] p2)</PRE> <DL> <DD>Calculates the L<sub>1</sub> (sum of abs) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>1</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="distance(double[], double[])"><!-- --></A><H3> distance</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1736"><B>distance</B></A>(double[] p1, double[] p2)</PRE> <DL> <DD>Calculates the L<sub>2</sub> (Euclidean) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>2</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="distance(int[], int[])"><!-- --></A><H3> distance</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1752"><B>distance</B></A>(int[] p1, int[] p2)</PRE> <DL> <DD>Calculates the L<sub>2</sub> (Euclidean) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>2</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="distanceInf(double[], double[])"><!-- --></A><H3> distanceInf</H3> <PRE> public static double <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1768"><B>distanceInf</B></A>(double[] p1, double[] p2)</PRE> <DL> <DD>Calculates the L<sub>∞</sub> (max of abs) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>∞</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="distanceInf(int[], int[])"><!-- --></A><H3> distanceInf</H3> <PRE> public static int <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1783"><B>distanceInf</B></A>(int[] p1, int[] p2)</PRE> <DL> <DD>Calculates the L<sub>∞</sub> (max of abs) distance between two points. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>p1</CODE> - the first point<DD><CODE>p2</CODE> - the second point <DT><B>Returns:</B><DD>the L<sub>∞</sub> distance between the two points</DL> </DD> </DL> <HR> <A NAME="checkOrder(double[], int, boolean)"><!-- --></A><H3> checkOrder</H3> <PRE> public static void <A HREF="../../../../../src-html/org/apache/commons/math/util/MathUtils.html#line.1799"><B>checkOrder</B></A>(double[] val, int dir, boolean strict)</PRE> <DL> <DD>Checks that the given array is sorted. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>val</CODE> - Values<DD><CODE>dir</CODE> - Order direction (-1 for decreasing, 1 for increasing)<DD><CODE>strict</CODE> - Whether the order should be strict <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if the array is not sorted.</DL> </DD> </DL> <!-- ========= END OF CLASS DATA ========= --> <HR> <!-- ======= START OF BOTTOM NAVBAR ====== --> <A NAME="navbar_bottom"><!-- --></A> <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> <TR> <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A NAME="navbar_bottom_firstrow"><!-- --></A> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/MathUtils.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR> </TABLE> </TD> <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../org/apache/commons/math/util/DoubleArray.html" title="interface in org.apache.commons.math.util"><B>PREV CLASS</B></A> <A HREF="../../../../../org/apache/commons/math/util/NumberTransformer.html" title="interface in org.apache.commons.math.util"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../../index.html?org/apache/commons/math/util/MathUtils.html" target="_top"><B>FRAMES</B></A> <A HREF="MathUtils.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--> </SCRIPT> <NOSCRIPT> <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A> </NOSCRIPT> </FONT></TD> </TR> <TR> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> </TR> </TABLE> <A NAME="skip-navbar_bottom"></A> <!-- ======== END OF BOTTOM NAVBAR ======= --> <HR> Copyright © 2003-2010 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved. </BODY> </HTML>