Class MissingMath

java.lang.Object
org.ojalgo.function.special.MissingMath

public abstract class MissingMath extends Object
Math utilities missing from Math.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final BigDecimal[]
    Coefficients for the Taylor series expansion of the exponential function.
    private static final MathContext
    Binary 256 octuple precision roughly corresponds to 71.34 decimal digits.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    acosh(double arg)
     
    static double
    asinh(double arg)
     
    static double
    atan2(double y, double x)
    https://math.stackexchange.com/questions/1098487/atan2-faster-approximation/1105038
    static double
    atanh(double arg)
     
    static BigDecimal
     
    static BigDecimal
    divide(BigDecimal numerator, BigDecimal denominator)
     
    private static BigDecimal
     
    static BigDecimal
     
    static double
    factorial(int arg)
    13! does not fit in an int, and 21! does not fit in a long - that's why this method returns a double.
    (package private) static double
    factorialDouble(int arg)
     
    (package private) static int
    factorialInt(int arg)
     
    (package private) static long
    factorialLong(int arg)
     
    static int
    gcd(int[] vals)
     
    static int
    gcd(int val1, int val2)
    Greatest Common Denominator
    static int
    gcd(int val1, int... vals)
     
    static long
    gcd(long[] vals)
     
    static long
    gcd(long val1, long val2)
    Greatest Common Denominator
    static long
    gcd(long val1, long... vals)
     
    static double
    hypot(double arg1, double arg2)
     
    static BigDecimal
     
    static BigDecimal
     
    static double
    log10(double arg, double replacement)
    For very small arguments (regardless of sign) the replacement is returned instead
    static double
    logistic(double arg)
     
    static double
    logit(double arg)
     
    static int
    Returns a rough approximation of Math.log10(double) for BigDecimal.
    static double
    max(double... values)
     
    static double
    max(double a, double b)
     
    static double
    max(double a, double b, double c)
     
    static double
    max(double a, double b, double c, double d)
     
    static int
    max(int... values)
     
    static int
    max(int a, int b)
     
    static int
    max(int a, int b, int c)
     
    static int
    max(int a, int b, int c, int d)
     
    static long
    max(long... values)
     
    static long
    max(long a, long b)
     
    static long
    max(long a, long b, long c)
     
    static long
    max(long a, long b, long c, long d)
     
    static double
    min(double... values)
     
    static double
    min(double a, double b)
     
    static double
    min(double a, double b, double c)
     
    static double
    min(double a, double b, double c, double d)
     
    static int
    min(int... values)
     
    static int
    min(int a, int b)
     
    static int
    min(int a, int b, int c)
     
    static int
    min(int a, int b, int c, int d)
     
    static long
    min(long... values)
     
    static long
    min(long a, long b)
     
    static long
    min(long a, long b, long c)
     
    static long
    min(long a, long b, long c, long d)
     
    static double
    norm(double... values)
     
    static double
    norm(double a, double b)
     
    static double
    norm(double a, double b, double c)
     
    static double
    norm(double a, double b, double c, double d)
     
    static BigDecimal
    pow(BigDecimal arg1, BigDecimal arg2)
     
    static double
    power(double arg, int param)
     
    static long
    power(long arg, int param)
     
    static BigDecimal
    power(BigDecimal arg, int param)
     
    static double
    root(double arg, int param)
     
    static BigDecimal
    root(BigDecimal arg, int param)
     
    static int
    roundToInt(double value)
     
    static double
    scale(double arg, int param)
     
    static BigDecimal
     
    static BigDecimal
     
    static double
    sqrt1px2(double arg)
     
    static BigDecimal
     
    static int
    toMinIntExact(long... values)
     
    static int
    toMinIntExact(long a, long b)
     
    static int
    toMinIntExact(long a, long b, long c)
     
    static int
    toMinIntExact(long a, long b, long c, long d)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EXP_COEF

      private static final BigDecimal[] EXP_COEF
      Coefficients for the Taylor series expansion of the exponential function.
    • MC256

      private static final MathContext MC256
      Binary 256 octuple precision roughly corresponds to 71.34 decimal digits. Here we set it higher (for intermediate calculations) to enable end-results that are accurate to 71 decimal digits.

      https://en.wikipedia.org/wiki/IEEE_754

  • Constructor Details

    • MissingMath

      public MissingMath()
  • Method Details

    • acosh

      public static double acosh(double arg)
    • asinh

      public static double asinh(double arg)
    • atan2

      public static double atan2(double y, double x)

      https://math.stackexchange.com/questions/1098487/atan2-faster-approximation/1105038

      This is about 10x faster than Math.atan2(double, double)

    • atanh

      public static double atanh(double arg)
    • cos

      public static BigDecimal cos(BigDecimal arg)
    • divide

      public static BigDecimal divide(BigDecimal numerator, BigDecimal denominator)
    • exp

      public static BigDecimal exp(BigDecimal arg)
    • factorial

      public static double factorial(int arg)
      13! does not fit in an int, and 21! does not fit in a long - that's why this method returns a double.
    • gcd

      public static int gcd(int val1, int val2)
      Greatest Common Denominator
    • gcd

      public static int gcd(int val1, int... vals)
    • gcd

      public static int gcd(int[] vals)
    • gcd

      public static long gcd(long val1, long... vals)
    • gcd

      public static long gcd(long val1, long val2)
      Greatest Common Denominator
    • gcd

      public static long gcd(long[] vals)
    • hypot

      public static BigDecimal hypot(BigDecimal arg1, BigDecimal arg2)
    • hypot

      public static double hypot(double arg1, double arg2)
    • log

      public static BigDecimal log(BigDecimal arg)
    • log10

      public static double log10(double arg, double replacement)
      For very small arguments (regardless of sign) the replacement is returned instead
    • logistic

      public static double logistic(double arg)
    • logit

      public static double logit(double arg)
    • magnitude

      public static int magnitude(BigDecimal arg)
      Returns a rough approximation of Math.log10(double) for BigDecimal.
      • For numbers like 10^n it returns the exact correct number, n.
      • The magnitude of 0.0 is 0.
      • The error is [0.0,1.0) and the returned value is never more than the actual/correct value. For 999.0 the correct value is close to 3, but this method returns 2, as the implementation simply counts the digits.
      • Works for negative numbers as the sign is disregarded.
      • Works for fractional numbers 0.1, 0.0456, 1.2 or whatever.
    • max

      public static double max(double... values)
    • max

      public static double max(double a, double b)
    • max

      public static double max(double a, double b, double c)
    • max

      public static double max(double a, double b, double c, double d)
    • max

      public static int max(int... values)
    • max

      public static int max(int a, int b)
    • max

      public static int max(int a, int b, int c)
    • max

      public static int max(int a, int b, int c, int d)
    • max

      public static long max(long... values)
    • max

      public static long max(long a, long b)
    • max

      public static long max(long a, long b, long c)
    • max

      public static long max(long a, long b, long c, long d)
    • min

      public static double min(double... values)
    • min

      public static double min(double a, double b)
    • min

      public static double min(double a, double b, double c)
    • min

      public static double min(double a, double b, double c, double d)
    • min

      public static int min(int... values)
    • min

      public static int min(int a, int b)
    • min

      public static int min(int a, int b, int c)
    • min

      public static int min(int a, int b, int c, int d)
    • min

      public static long min(long... values)
    • min

      public static long min(long a, long b)
    • min

      public static long min(long a, long b, long c)
    • min

      public static long min(long a, long b, long c, long d)
    • norm

      public static double norm(double... values)
    • norm

      public static double norm(double a, double b)
    • norm

      public static double norm(double a, double b, double c)
    • norm

      public static double norm(double a, double b, double c, double d)
    • pow

      public static BigDecimal pow(BigDecimal arg1, BigDecimal arg2)
    • power

      public static BigDecimal power(BigDecimal arg, int param)
    • power

      public static double power(double arg, int param)
    • power

      public static long power(long arg, int param)
    • root

      public static BigDecimal root(BigDecimal arg, int param)
    • root

      public static double root(double arg, int param)
    • roundToInt

      public static int roundToInt(double value)
    • scale

      public static double scale(double arg, int param)
    • signum

      public static BigDecimal signum(BigDecimal arg)
    • sin

      public static BigDecimal sin(BigDecimal arg)
    • sqrt1px2

      public static double sqrt1px2(double arg)
    • tanh

      public static BigDecimal tanh(BigDecimal arg)
    • toMinIntExact

      public static int toMinIntExact(long... values)
    • toMinIntExact

      public static int toMinIntExact(long a, long b)
    • toMinIntExact

      public static int toMinIntExact(long a, long b, long c)
    • toMinIntExact

      public static int toMinIntExact(long a, long b, long c, long d)
    • doInternalCos

      private static BigDecimal doInternalCos(BigDecimal arg)
    • factorialDouble

      static double factorialDouble(int arg)
    • factorialInt

      static int factorialInt(int arg)
    • factorialLong

      static long factorialLong(int arg)