org.encog.mathutil
Class EncogMath
- java.lang.Object
-
- org.encog.mathutil.EncogMath
-
public final class EncogMath extends java.lang.ObjectSeveral useful math functions for Encog.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doubledeg2rad(double deg)Convert degrees to radians.static booleandoubleEquals(double d1, double d2)Determine if one double equals another, within the default percision.static doublefactorial(int x)Calculate x!.static doublehypot(double a, double b)sqrt(a^2 + b^2) without under/overflow.static intmaxIndex(double[] array)Get the index to the greatest number in a double array.static intminIndex(double[] array)Get the index to the smallest number in a double array.static doublerad2deg(double rad)Convert radians to degrees.static intsign(double value)Determine the sign of the value.static doublesquare(double d)static intthirds(double value)Transform a number in the range (-1,1) to a tri-state value indicated by -1, 0 or 1.
-
-
-
Method Detail
-
deg2rad
public static double deg2rad(double deg)
Convert degrees to radians.- Parameters:
deg- Degrees.- Returns:
- Radians.
-
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.
-
rad2deg
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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG