org.encog.mathutil

## Class EncogMath

• ```public final class EncogMath
extends Object```
Several useful math functions for Encog.
• ### Method Summary

Methods
Modifier and Type Method and Description
`static double` `deg2rad(double deg)`
Convert degrees to radians.
`static boolean` ```doubleEquals(double d1, double d2)```
Determine if one double equals another, within the default percision.
`static double` `factorial(int x)`
Calculate x!.
`static double` ```hypot(double a, double b)```
sqrt(a^2 + b^2) without under/overflow.
`static int` `maxIndex(double[] array)`
Get the index to the greatest number in a double array.
`static int` `minIndex(double[] array)`
Get the index to the smallest number in a double array.
`static double` `rad2deg(double rad)`
Convert radians to degrees.
`static int` `sign(double value)`
Determine the sign of the value.
`static double` `square(double d)`
`static int` `thirds(double value)`
Transform a number in the range (-1,1) to a tri-state value indicated by -1, 0 or 1.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Method Detail

`public static double deg2rad(double deg)`
Convert degrees to radians.
Parameters:
`deg` - Degrees.
Returns:
• #### doubleEquals

```public static boolean doubleEquals(double d1,
double d2)```
Determine if one double equals another, within the default percision.
Parameters:
`d1` - The first number.
`d2` - The second number.
Returns:
True if the two doubles are equal.
• #### hypot

```public static double hypot(double a,
double b)```
sqrt(a^2 + b^2) without under/overflow.
Parameters:
`a` - First param.
`b` - Second param.
Returns:
The result.
• #### maxIndex

`public static int maxIndex(double[] array)`
Get the index to the greatest number in a double array.
Parameters:
`array` - The array to search.
Returns:
The index of the greatest value, or -1 if empty.
• #### minIndex

`public static int minIndex(double[] array)`
Get the index to the smallest number in a double array.
Parameters:
`array` - The array to search.
Returns:
The index of the smallest value, or -1 if empty.

`public static double rad2deg(double rad)`
Convert radians to degrees.
Parameters:
`rad` - Radians
Returns:
Degrees.
• #### factorial

`public static double factorial(int x)`
Calculate x!.
Parameters:
`x` - The number to calculate for.
Returns:
The factorial of x.
• #### square

`public static double square(double d)`
• #### sign

`public static int sign(double value)`
Determine the sign of the value.
Parameters:
`value` - The value to check.
Returns:
-1 if less than zero, 1 if greater, or 0 if zero.
• #### thirds

`public static int thirds(double value)`
Transform a number in the range (-1,1) to a tri-state value indicated by -1, 0 or 1.
Parameters:
`value` - The value to consider.
Returns:
-1 if the value is below 1/3, 1 if above 1/3, zero otherwise.