org.naokishibata.sleef
Class FastMath

java.lang.Object
  extended by org.naokishibata.sleef.FastMath

public class FastMath
extends java.lang.Object

FastMath class is a Java implementation of the SLEEF library. Some of the methods can be used as substitutions of the corresponding methods in Math class. They have slightly less accuracy, and some methods are faster compared to those methods in Math class. Please note that the methods in the standard Math class are JNI methods, and the SLEEF library is specialized for SIMD operations.


Nested Class Summary
static class FastMath.double2
          This class represents a vector of two double values.
 
Constructor Summary
FastMath()
           
 
Method Summary
static double acos(double d)
          This method calculates the arc cosine of x in radians.
static float acosf(float d)
          This method calculates the arc cosine of x in single precision.
static double acosh(double x)
          Returns the inverse hyperbolic cosine of x.
static double asin(double d)
          This method calculates the arc sine of x in radians.
static float asinf(float d)
          This method calculates the arc sine of x in single precision.
static double asinh(double x)
          Returns the inverse hyperbolic sine of x.
static double atan(double s)
          Returns the arc tangent of an angle.
static double atan2(double y, double x)
          This method calculates the arc tangent of y/x in radians, using the signs of the two arguments to determine the quadrant of the result.
static float atan2f(float y, float x)
          This method calculates the arc tangent of y/x in single precision.
static float atanf(float s)
          Returns the arc tangent of an angle in single precision.
static double atanh(double x)
          Returns the inverse hyperbolic tangent of x.
static double cbrt(double d)
          This function returns the cube root of the argument.
static float cbrtf(float d)
          This function returns the cube root of the argument in single precision.
static double cos(double d)
          Returns the trigonometric cosine of an angle.
static float cosf(float d)
          Returns the trigonometric cosine of an angle in single precision.
static double cosh(double x)
          Returns the hyperbolic cosine of x.
static double exp(double d)
          Returns the value of e raised to the power of the argument.
static double exp10(double a)
          Returns the value of 10 raised to the power of the argument.
static double exp2(double a)
          Returns the value of 2 raised to the power of the argument.
static float expf(float d)
          Returns the value of e raised to the power of the argument in single precision.
static double expm1(double a)
          Returns a value equivalent to exp(a)-1.
static double fabs(double d)
          Returns the absolute value of the argument
static double fma(double x, double y, double z)
          This function performs a fused multiply-accumulate operation.
static int ilogb(double d)
          Returns the exponent part of their argument as a signed integer
static boolean isinf(double d)
          Checks if the argument is either positive infinity or negative infinity.
static boolean isMinusZero(double x)
          Checks if the argument is -0.
static boolean isnan(double d)
          Checks if the argument is a NaN or not.
static boolean isPlusZero(double x)
          Checks if the argument is +0.
static double ldexp(double x, int q)
          Returns the result of multiplying the floating-point number x by 2 raised to the power q
static double log(double d)
          Returns the natural logarithm of the argument.
static double log10(double a)
          Returns the base 10 logarithm of the argument.
static double log1p(double a)
          Returns a value equivalent to log(1+a).
static float logf(float d)
          Returns the natural logarithm of the argument in single precision.
static double max(double x, double y)
          Returns the larger value of the two arguments.
static double pow(double x, double y)
          Returns the value of the first argument raised to the power of the second argument.
static double rint(double x)
          Returns the integer value that is closest to the argument.
static double sin(double d)
          Returns the trigonometric sine of an angle.
static FastMath.double2 sincos(double d)
          Returns the trigonometric sine and cosine of an angle at a time.
static float sinf(float d)
          Returns the trigonometric sine of an angle in single precision.
static double sinh(double x)
          Returns the hyperbolic sine of x.
static double sqrt(double d)
          This function returns the square root of the argument.
static double tan(double d)
          Returns the trigonometric tangent of an angle.
static float tanf(float d)
          Returns the trigonometric tangent of an angle in single precision.
static double tanh(double x)
          Returns the hyperbolic tangent of x.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FastMath

public FastMath()
Method Detail

fabs

public static double fabs(double d)
Returns the absolute value of the argument


max

public static double max(double x,
                         double y)
Returns the larger value of the two arguments. The result is undefined if denormal numbers are given.


isnan

public static boolean isnan(double d)
Checks if the argument is a NaN or not.


isinf

public static boolean isinf(double d)
Checks if the argument is either positive infinity or negative infinity.


rint

public static double rint(double x)
Returns the integer value that is closest to the argument. The result is undefined if a denormal number is given.


ldexp

public static double ldexp(double x,
                           int q)
Returns the result of multiplying the floating-point number x by 2 raised to the power q


ilogb

public static int ilogb(double d)
Returns the exponent part of their argument as a signed integer


isPlusZero

public static boolean isPlusZero(double x)
Checks if the argument is +0.


isMinusZero

public static boolean isMinusZero(double x)
Checks if the argument is -0.


atan2

public static double atan2(double y,
                           double x)
This method calculates the arc tangent of y/x in radians, using the signs of the two arguments to determine the quadrant of the result. The results may have maximum error of 2 ulps.


asin

public static double asin(double d)
This method calculates the arc sine of x in radians. The return value is in the range [-pi/2, pi/2]. The results may have maximum error of 3 ulps.


acos

public static double acos(double d)
This method calculates the arc cosine of x in radians. The return value is in the range [0, pi]. The results may have maximum error of 3 ulps.


atan

public static double atan(double s)
Returns the arc tangent of an angle. The results may have maximum error of 2 ulps.


sin

public static double sin(double d)
Returns the trigonometric sine of an angle. The results may have maximum error of 2 ulps.


cos

public static double cos(double d)
Returns the trigonometric cosine of an angle. The results may have maximum error of 2 ulps.


sincos

public static FastMath.double2 sincos(double d)
Returns the trigonometric sine and cosine of an angle at a time. The sine and cosine of an argument is returned by the x and y field of the return value, respectively. The results may have maximum error of 2 ulps.


tan

public static double tan(double d)
Returns the trigonometric tangent of an angle. The results may have maximum error of 3 ulps.


log

public static double log(double d)
Returns the natural logarithm of the argument. The results may have maximum error of 3 ulps.


exp

public static double exp(double d)
Returns the value of e raised to the power of the argument. The results may have maximum error of 1 ulps.


pow

public static double pow(double x,
                         double y)
Returns the value of the first argument raised to the power of the second argument. The results may have maximum error of 1 ulps.


sinh

public static double sinh(double x)
Returns the hyperbolic sine of x. The results may have maximum error of 2 ulps.


cosh

public static double cosh(double x)
Returns the hyperbolic cosine of x. The results may have maximum error of 2 ulps.


tanh

public static double tanh(double x)
Returns the hyperbolic tangent of x. The results may have maximum error of 2 ulps.


asinh

public static double asinh(double x)
Returns the inverse hyperbolic sine of x. The results may have maximum error of 2 ulps.


acosh

public static double acosh(double x)
Returns the inverse hyperbolic cosine of x. The results may have maximum error of 2 ulps.


atanh

public static double atanh(double x)
Returns the inverse hyperbolic tangent of x. The results may have maximum error of 2 ulps.


fma

public static double fma(double x,
                         double y,
                         double z)
This function performs a fused multiply-accumulate operation. This function computes x*y+z, with a single rounding. This implementation gives the exact result unless an overflow occurs.


sqrt

public static double sqrt(double d)
This function returns the square root of the argument. This implementation gives the exact result(less than or equal to 0.5 ulp of error).


cbrt

public static double cbrt(double d)
This function returns the cube root of the argument. The results may have maximum error of 2 ulps.


exp2

public static double exp2(double a)
Returns the value of 2 raised to the power of the argument. The results may have maximum error of 1 ulp.


exp10

public static double exp10(double a)
Returns the value of 10 raised to the power of the argument. The results may have maximum error of 1 ulp.


expm1

public static double expm1(double a)
Returns a value equivalent to exp(a)-1. The result is accurate even when the value of a is close to zero. The results may have maximum error of 1 ulp.


log10

public static double log10(double a)
Returns the base 10 logarithm of the argument. The results may have maximum error of 1 ulp.


log1p

public static double log1p(double a)
Returns a value equivalent to log(1+a). The result is accurate even when the value of a is close to zero. The results may have maximum error of 1 ulp.


cbrtf

public static float cbrtf(float d)
This function returns the cube root of the argument in single precision. The results may have maximum error of 2 ulps.


sinf

public static float sinf(float d)
Returns the trigonometric sine of an angle in single precision. The results may have maximum error of 3 ulps.


cosf

public static float cosf(float d)
Returns the trigonometric cosine of an angle in single precision. The results may have maximum error of 3 ulps.


tanf

public static float tanf(float d)
Returns the trigonometric tangent of an angle in single precision. The results may have maximum error of 4 ulps.


atanf

public static float atanf(float s)
Returns the arc tangent of an angle in single precision. The results may have maximum error of 3 ulps.


atan2f

public static float atan2f(float y,
                           float x)
This method calculates the arc tangent of y/x in single precision. It uses the signs of the two arguments to determine the quadrant of the result. The results may have maximum error of 3 ulps.


asinf

public static float asinf(float d)
This method calculates the arc sine of x in single precision. The results may have maximum error of 3 ulps.


acosf

public static float acosf(float d)
This method calculates the arc cosine of x in single precision. The results may have maximum error of 3 ulps.


logf

public static float logf(float d)
Returns the natural logarithm of the argument in single precision. The results may have maximum error of 3 ulps.


expf

public static float expf(float d)
Returns the value of e raised to the power of the argument in single precision. The results may have maximum error of 1 ulps.