MOEA Framework 2.12
API Specification

org.moeaframework.util.tree
Class NumberArithmetic

java.lang.Object
  extended by org.moeaframework.util.tree.NumberArithmetic

public class NumberArithmetic
extends Object

Provides many arithmetic and trigonometric functions that operate on Numbers, performing any necessary implicit casting. An integer number remains an integer unless the specific function requires floating-point values. These methods favor Long and Double representations for integer and floating-point values, respectively.

The arithmetic functions provided herein support optional function protection, which is enabled by default. Function protection prevents values like Inf and NaN from appearing due to invalid inputs. For example, this protects against division-by-zero. To disable function protection, set the property org.moeaframework.util.tree.protected_functions = false in the file global.properties. Inf and NaN values can still occur with function protection enabled, so outputs should still be validated.


Method Summary
static Number abs(Number a)
          Returns the absolute value of the number.
static Number acos(Number a)
          Returns the arc cosine of the number.
static Number acosh(Number a)
          Returns the hyperbolic arc cosine of the number.
static Number add(Number a, Number b)
          Returns the value of adding the two numbers
static Number asin(Number a)
          Returns the arc sine of the number.
static Number asinh(Number a)
          Returns the hyperbolic arc sine of the number.
static Number atan(Number a)
          Returns the arc tangent of the number.
static Number atanh(Number a)
          Returns the hyperbolic arc tangent of the number.
static Number ceil(Number a)
          Returns the smallest integer value greater than or equal to the given number.
static Number cos(Number a)
          Returns the trigonometric cosine of the number.
static Number cosh(Number a)
          Returns the hyperbolic cosine of the number.
static Number div(Number a, Number b)
          Returns the value of dividing the first number by the second.
static boolean equals(Number a, Number b)
          Returns true if the two numbers are equal; false otherwise.
static Number exp(Number a)
          Returns the value from taking Euler's number e to the power of the given number.
static Number floor(Number a)
          Returns the largest integer value less than or equal to the given number.
static boolean greaterThan(Number a, Number b)
          Returns true if the first number is greater than the second; false otherwise.
static boolean greaterThanOrEqual(Number a, Number b)
          Returns true if the first number is greater than or equal to the second; false otherwise.
static boolean isFloatingPoint(Number a)
          Returns true if the number is a floating-point value; false otherwise.
static boolean lessThan(Number a, Number b)
          Returns true if the first number is less than the second; false otherwise.
static boolean lessThanOrEqual(Number a, Number b)
          Returns true if the first number is less than or equal to the second; false otherwise.
static Number log(Number a)
          Returns the natural logarithm of the number.
static Number log10(Number a)
          Returns the base-10 logarithm of the number.
static Number max(Number a, Number b)
          Returns the maximum value of two numbers.
static Number min(Number a, Number b)
          Returns the minimum value of two numbers.
static Number mod(Number a, Number b)
          Returns the remainder from dividing the first number by the second.
static Number mul(Number a, Number b)
          Returns the value of multiplying the two numbers.
static Number pow(Number a, Number b)
          Returns the value of the first number to the power of the second.
static Number round(Number a)
          Returns the value of the number rounded to the nearest integer.
static Number sign(Number a)
          Returns the sign of the number.
static Number sin(Number a)
          Returns the trigonometric sine of the number.
static Number sinh(Number a)
          Returns the hyperbolic sine of the number.
static Number sqrt(Number a)
          Returns the square root of the number.
static Number sub(Number a, Number b)
          Returns the value of subtracting the first from the second number.
static Number tan(Number a)
          Returns the trigonometric tangent of the number.
static Number tanh(Number a)
          Returns the hyperbolic tangent of the number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

equals

public static boolean equals(Number a,
                             Number b)
Returns true if the two numbers are equal; false otherwise.

Parameters:
a - the first number
b - the second number
Returns:
true if the two numbers are equal; false otherwise

lessThan

public static boolean lessThan(Number a,
                               Number b)
Returns true if the first number is less than the second; false otherwise.

Parameters:
a - the first number
b - the second number
Returns:
true if the first number is less than the second; false otherwise

lessThanOrEqual

public static boolean lessThanOrEqual(Number a,
                                      Number b)
Returns true if the first number is less than or equal to the second; false otherwise.

Parameters:
a - the first number
b - the second number
Returns:
true if the first number is less than or equal to the second; false otherwise

greaterThan

public static boolean greaterThan(Number a,
                                  Number b)
Returns true if the first number is greater than the second; false otherwise.

Parameters:
a - the first number
b - the second number
Returns:
true if the first number is greater than the second; false otherwise

greaterThanOrEqual

public static boolean greaterThanOrEqual(Number a,
                                         Number b)
Returns true if the first number is greater than or equal to the second; false otherwise.

Parameters:
a - the first number
b - the second number
Returns:
true if the first number is greater than or equal to the second; false otherwise

add

public static Number add(Number a,
                         Number b)
Returns the value of adding the two numbers

Parameters:
a - the first number
b - the second number
Returns:
the value of adding the two numbers

sqrt

public static Number sqrt(Number a)
Returns the square root of the number. If the number is less than zero and function protection is enabled, this functions the square root of the absolute value of the number.

Parameters:
a - the number
Returns:
the square root of the number
See Also:
Math.sqrt(double)

pow

public static Number pow(Number a,
                         Number b)
Returns the value of the first number to the power of the second.

Parameters:
a - the first number
b - the second number
Returns:
the value of the first number to the power of the second
See Also:
Math.pow(double, double)

sub

public static Number sub(Number a,
                         Number b)
Returns the value of subtracting the first from the second number.

Parameters:
a - the first number
b - the second number
Returns:
the value of subtracting the first from the second number

mul

public static Number mul(Number a,
                         Number b)
Returns the value of multiplying the two numbers.

Parameters:
a - the first number
b - the second number
Returns:
the value of multiplying the two numbers

div

public static Number div(Number a,
                         Number b)
Returns the value of dividing the first number by the second. If the second argument is 0 and function protection is enabled, this function returns 1 regardless of the first argument's value.

Parameters:
a - the first number
b - the second number
Returns:
the value of dividing the first number by the second

mod

public static Number mod(Number a,
                         Number b)
Returns the remainder from dividing the first number by the second. If the second argument is 0 and function protection is enabled, this function returns 0 regardless of the first argument's value.

Parameters:
a - the first number
b - the second number
Returns:
the remainder from dividing the first number by the second

floor

public static Number floor(Number a)
Returns the largest integer value less than or equal to the given number.

Parameters:
a - the number
Returns:
the largest integer value less than or equal to the given number
See Also:
Math.floor(double)

ceil

public static Number ceil(Number a)
Returns the smallest integer value greater than or equal to the given number.

Parameters:
a - the number
Returns:
the smallest integer value greater than or equal to the given number
See Also:
Math.ceil(double)

round

public static Number round(Number a)
Returns the value of the number rounded to the nearest integer.

Parameters:
a - the number
Returns:
the value of the number rounded to the nearest integer
See Also:
Math.round(double)

abs

public static Number abs(Number a)
Returns the absolute value of the number.

Parameters:
a - the number
Returns:
the absolute value of the number
See Also:
Math.abs(long), Math.abs(double)

log

public static Number log(Number a)
Returns the natural logarithm of the number. If the numbers is negative and function protection is enabled, then this function returns the natural logarithm of the absolute value of the number. If the number is near zero and function protection is enabled, this function returns 0.0.

Parameters:
a - the number
Returns:
the natural logarithm of the number
See Also:
Math.log(double)

log10

public static Number log10(Number a)
Returns the base-10 logarithm of the number. If the numbers is negative and function protection is enabled, then this function returns the base-10 logarithm of the absolute value of the number. If the number is near zero and function protection is enabled, this function returns 0.0.

Parameters:
a - the number
Returns:
the base-10 logarithm of the number
See Also:
Math.log10(double)

exp

public static Number exp(Number a)
Returns the value from taking Euler's number e to the power of the given number.

Parameters:
a - the number
Returns:
the value from taking Euler's number e to the power of the given number
See Also:
Math.exp(double)

sin

public static Number sin(Number a)
Returns the trigonometric sine of the number.

Parameters:
a - the number
Returns:
the trigonometric sine of the number
See Also:
Math.sin(double)

cos

public static Number cos(Number a)
Returns the trigonometric cosine of the number.

Parameters:
a - the number
Returns:
the trigonometric cosine of the number
See Also:
Math.cos(double)

tan

public static Number tan(Number a)
Returns the trigonometric tangent of the number.

Parameters:
a - the number
Returns:
the trigonometric tangent of the number
See Also:
Math.tan(double)

asin

public static Number asin(Number a)
Returns the arc sine of the number.

Parameters:
a - the number
Returns:
the arc sine of the number
See Also:
Math.asin(double)

acos

public static Number acos(Number a)
Returns the arc cosine of the number.

Parameters:
a - the number
Returns:
the arc cosine of the number
See Also:
Math.acos(double)

atan

public static Number atan(Number a)
Returns the arc tangent of the number.

Parameters:
a - the number
Returns:
the arc tangent of the number
See Also:
Math.atan(double)

sinh

public static Number sinh(Number a)
Returns the hyperbolic sine of the number.

Parameters:
a - the number
Returns:
the hyperbolic sine of the number
See Also:
Math.sinh(double)

cosh

public static Number cosh(Number a)
Returns the hyperbolic cosine of the number.

Parameters:
a - the number
Returns:
the hyperbolic cosine of the number
See Also:
Math.cosh(double)

tanh

public static Number tanh(Number a)
Returns the hyperbolic tangent of the number.

Parameters:
a - the number
Returns:
the hyperbolic tangent of the number
See Also:
Math.tanh(double)

asinh

public static Number asinh(Number a)
Returns the hyperbolic arc sine of the number.

Parameters:
a - the number
Returns:
the hyperbolic arc sine of the number
See Also:
FastMath.asinh(double)

acosh

public static Number acosh(Number a)
Returns the hyperbolic arc cosine of the number.

Parameters:
a - the number
Returns:
the hyperbolic arc cosine of the number
See Also:
FastMath.acosh(double)

atanh

public static Number atanh(Number a)
Returns the hyperbolic arc tangent of the number.

Parameters:
a - the number
Returns:
the hyperbolic arc tangent of the number
See Also:
FastMath.atanh(double)

max

public static Number max(Number a,
                         Number b)
Returns the maximum value of two numbers.

Parameters:
a - the first number
b - the second number
Returns:
the maximum value of two numbers
See Also:
Math.min(long, long), Math.min(double, double)

min

public static Number min(Number a,
                         Number b)
Returns the minimum value of two numbers.

Parameters:
a - the first number
b - the second number
Returns:
the minimum value of two numbers
See Also:
Math.max(long, long), Math.max(double, double)

sign

public static Number sign(Number a)
Returns the sign of the number.

Parameters:
a - the number
Returns:
the sign of the number
See Also:
Long.signum(long), Math.signum(double)

isFloatingPoint

public static boolean isFloatingPoint(Number a)
Returns true if the number is a floating-point value; false otherwise.

Parameters:
a - the number
Returns:
true if the number is a floating-point value; false otherwise

MOEA Framework 2.12
API Specification

Copyright 2009-2016 MOEA Framework. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage. Visit us on Github!