SciLib.Math
Class math

java.lang.Object
  extended by SciLib.Math.math

public final class math
extends java.lang.Object

This class contains some useful computation methods.


Field Summary
static double Pi
          The constant value Pi = 3.141592
 
Constructor Summary
math()
           
 
Method Summary
static double cuberoot(double x)
          Compute cuberoot of a double x
static double decibel(double x)
          Compute decibel value of a double x.
static double decibelToNumber(double x)
          Compute the number from its decibel
static double degreesToRadians(double theta)
          convert the degrees to radians of an angle theta.
static int gcd(int a, int b)
          Compute the greatest common divisor of a and b computed using iterative version of Euclid's algorithm
static int GrayCode(int n)
          Compute the Gray code of an integer n
static int GrayCodeInv(int n)
          Compute the inverse of Gray code n
static boolean isPrime(int x)
          Check if an integer number x is a prime number
static int lcm(int a, int b)
          Compute the least common multiple of a and b
static double log10(double x)
          Compute log10(x)
static double log2(double x)
          Compute log2(x)
static int nextPrime(int x)
          Compute the least prime number > x
static double polynomial(double[] coef, double x)
          Compute the value of a polynomial at a point x
static double radiansToDegrees(double theta)
          convert the radians to degrees of an angle theta.
static double random(double a, double b)
          Compute a random number between a and b, a<=r
static double random(double a, double b, int n)
          Compute a random number between a and b, a<=r
static double roundUp(double x)
          RoundUp a double x to integer
static double roundUp(double x, int n)
          RoundUp a double x to a double with n decimal digits
static int sgn(double x)
          Compute the signum of a double x
static double sigmoid(double x)
          Compute the value of a sigmoid function at a point x sigmoid(x) = 1 / (1 + exp(-x))
static double sigmoid2(double x)
          Compute the value of a sigmoid function of type 2 at a point x sigmoid2(x) = 2*sigmoid(x) - 1
static double sinc(double x)
          Compute sinc(x)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Pi

public static final double Pi
The constant value Pi = 3.141592

See Also:
Constant Field Values
Constructor Detail

math

public math()
Method Detail

decibel

public static double decibel(double x)
Compute decibel value of a double x.

Parameters:
x - A double value
Returns:
A double value

decibelToNumber

public static double decibelToNumber(double x)
Compute the number from its decibel

Parameters:
x - A double value
Returns:
A double value

degreesToRadians

public static double degreesToRadians(double theta)
convert the degrees to radians of an angle theta.

Parameters:
theta - A double value
Returns:
A double value

radiansToDegrees

public static double radiansToDegrees(double theta)
convert the radians to degrees of an angle theta.

Parameters:
theta - A double value
Returns:
A double value

log10

public static double log10(double x)
Compute log10(x)

Parameters:
x - A double value
Returns:
A double value

log2

public static double log2(double x)
Compute log2(x)

Returns:
A double value

polynomial

public static double polynomial(double[] coef,
                                double x)
Compute the value of a polynomial at a point x

Parameters:
coef - The array that contains all coefficients of the polynomial
x - The value of variable
Returns:
A double value

roundUp

public static double roundUp(double x)
RoundUp a double x to integer

Parameters:
x - A double value
Returns:
A double value

roundUp

public static double roundUp(double x,
                             int n)
RoundUp a double x to a double with n decimal digits

Parameters:
x - A double value
n - The number of decimal digits
Returns:
A double value

sinc

public static double sinc(double x)
Compute sinc(x)

Parameters:
x - A double value
Returns:
A double value

isPrime

public static boolean isPrime(int x)
Check if an integer number x is a prime number

Parameters:
x - An integer value
Returns:
A boolean value

nextPrime

public static int nextPrime(int x)
Compute the least prime number > x

Parameters:
x - An integer value
Returns:
A integer value

gcd

public static int gcd(int a,
                      int b)
Compute the greatest common divisor of a and b computed using iterative version of Euclid's algorithm

Parameters:
a - An integer value, a > 0
b - An integer value, b > 0
Returns:
An integer value

lcm

public static int lcm(int a,
                      int b)
Compute the least common multiple of a and b

Parameters:
a - An integer value, a > 0
b - An integer value, b > 0
Returns:
An integer value

GrayCode

public static int GrayCode(int n)
Compute the Gray code of an integer n

Parameters:
n - An integer value
Returns:
An integer value

GrayCodeInv

public static int GrayCodeInv(int n)
Compute the inverse of Gray code n

Parameters:
n - An integer value
Returns:
An integer value

random

public static double random(double a,
                            double b)
Compute a random number between a and b, a<=r
Parameters:
a - A double value
b - A double value
Returns:
A double value

random

public static double random(double a,
                            double b,
                            int n)
Compute a random number between a and b, a<=r
Parameters:
a - A double value
b - A double value
n - An integer
Returns:
A double value

sigmoid

public static double sigmoid(double x)
Compute the value of a sigmoid function at a point x sigmoid(x) = 1 / (1 + exp(-x))

Parameters:
x - A double value
Returns:
A double value

sigmoid2

public static double sigmoid2(double x)
Compute the value of a sigmoid function of type 2 at a point x sigmoid2(x) = 2*sigmoid(x) - 1

Parameters:
x - A double value
Returns:
A double value

cuberoot

public static double cuberoot(double x)
Compute cuberoot of a double x

Parameters:
x - A double value
Returns:
A double value

sgn

public static int sgn(double x)
Compute the signum of a double x

Parameters:
x - A double value
Returns:
An integer value